Part of #21421: Refactor MAXIMUM_MAP_SIZE_TECHNICAL

This commit is contained in:
Claudio Tiecher committed 2024-03-25 16:17:32 +01:00
1 parent ef81a6376e
commit ffb8b4d44b
14 files changed
+49 -49

No files matched your search

+11 -11
View File
@@ -55,7 +55,7 @@ namespace OpenRCT2::Ui::Windows
return MapColour2((colour & 0xFF00) >> 8, PALETTE_INDEX_10);
}
constexpr int32_t MAP_WINDOW_MAP_SIZE = MAXIMUM_MAP_SIZE_TECHNICAL * 2;
constexpr int32_t MAP_WINDOW_MAP_SIZE = kMaximumMapSizeTechnical * 2;
static constexpr StringId WINDOW_TITLE = STR_MAP_LABEL;
static constexpr int32_t WH = 259;
@@ -131,10 +131,10 @@ static Widget window_map_widgets[] = {
// used in transforming viewport view coordinates to minimap coordinates
// rct2: 0x00981BBC
static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 0 },
{ 2 * MAXIMUM_MAP_SIZE_TECHNICAL - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 2 * MAXIMUM_MAP_SIZE_TECHNICAL },
{ 0 - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
{ kMaximumMapSizeTechnical - 8, 0 },
{ 2 * kMaximumMapSizeTechnical - 8, kMaximumMapSizeTechnical },
{ kMaximumMapSizeTechnical - 8, 2 * kMaximumMapSizeTechnical },
{ 0 - 8, kMaximumMapSizeTechnical },
};
// clang-format on
@@ -691,7 +691,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{
// The practical size is 2 lower than the technical size
size += 2;
size = std::clamp(size, kMinimumMapSizeTechnical, MAXIMUM_MAP_SIZE_TECHNICAL);
size = std::clamp(size, static_cast<int>(kMinimumMapSizeTechnical), static_cast<int>(kMaximumMapSizeTechnical));
TileCoordsXY newMapSize = GetGameState().MapSize;
if (_resizeDirection != ResizeDirection::X)
@@ -1069,7 +1069,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{
int32_t x = 0, y = 0, dx = 0, dy = 0;
int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + MAXIMUM_MAP_SIZE_TECHNICAL - 1;
int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + kMaximumMapSizeTechnical - 1;
auto destinationPosition = ScreenCoordsXY{ pos % MAP_WINDOW_MAP_SIZE, pos / MAP_WINDOW_MAP_SIZE };
auto destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
switch (GetCurrentRotation())
@@ -1100,7 +1100,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
break;
}
for (int32_t i = 0; i < MAXIMUM_MAP_SIZE_TECHNICAL; i++)
for (int32_t i = 0; i < kMaximumMapSizeTechnical; i++)
{
if (!MapIsEdge({ x, y }))
{
@@ -1125,7 +1125,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
}
_currentLine++;
if (_currentLine >= MAXIMUM_MAP_SIZE_TECHNICAL)
if (_currentLine >= kMaximumMapSizeTechnical)
_currentLine = 0;
}
@@ -1414,7 +1414,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
CoordsXY ScreenToMap(ScreenCoordsXY screenCoords)
{
screenCoords.x = ((screenCoords.x + 8) - MAXIMUM_MAP_SIZE_TECHNICAL) / 2;
screenCoords.x = ((screenCoords.x + 8) - kMaximumMapSizeTechnical) / 2;
screenCoords.y = ((screenCoords.y + 8)) / 2;
auto location = TileCoordsXY(screenCoords.y - screenCoords.x, screenCoords.x + screenCoords.y).ToCoordsXY();
@@ -1457,7 +1457,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
x /= 32;
y /= 32;
return { -x + y + MAXIMUM_MAP_SIZE_TECHNICAL - 8, x + y - 8 };
return { -x + y + kMaximumMapSizeTechnical - 8, x + y - 8 };
}
void ResizeMap()
+2 -2
View File
@@ -405,9 +405,9 @@ static uint64_t PressedWidgets[WINDOW_MAPGEN_PAGE_COUNT] = {
_resizeDirection = ResizeDirection::Both;
if (_resizeDirection != ResizeDirection::X)
_mapSize.y = std::clamp(_mapSize.y + sizeOffset, kMinimumMapSizeTechnical, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize.y = std::clamp(_mapSize.y + sizeOffset, static_cast<int>(kMinimumMapSizeTechnical), static_cast<int>(kMaximumMapSizeTechnical));
if (_resizeDirection != ResizeDirection::Y)
_mapSize.x = std::clamp(_mapSize.x + sizeOffset, kMinimumMapSizeTechnical, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize.x = std::clamp(_mapSize.x + sizeOffset, static_cast<int>(kMinimumMapSizeTechnical), static_cast<int>(kMaximumMapSizeTechnical));
}
void InputMapSize(WidgetIndex callingWidget, int32_t currentValue)
+1 -1
View File
@@ -2628,7 +2628,7 @@ static Widget _rideConstructionWidgets[] = {
auto& gameState = OpenRCT2::GetGameState();
auto preserveMapSize = gameState.MapSize;
gameState.MapSize = { MAXIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL };
gameState.MapSize = { kMaximumMapSizeTechnical, kMaximumMapSizeTechnical };
// Setup non changing parts of the temporary track tile element
tempTrackTileElement.SetType(TileElementType::Track);
+4 -4
View File
@@ -742,7 +742,7 @@ static uint64_t PageDisabledWidgets[] = {
{
case WIDX_SPINNER_X_INCREASE:
windowTileInspectorTile.x = std::min<int32_t>(
windowTileInspectorTile.x + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
windowTileInspectorTile.x + 1, kMaximumMapSizeTechnical - 1);
_toolMap.x = std::min<int32_t>(_toolMap.x + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
@@ -755,7 +755,7 @@ static uint64_t PageDisabledWidgets[] = {
case WIDX_SPINNER_Y_INCREASE:
windowTileInspectorTile.y = std::min<int32_t>(
windowTileInspectorTile.y + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
windowTileInspectorTile.y + 1, kMaximumMapSizeTechnical - 1);
_toolMap.y = std::min<int32_t>(_toolMap.y + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
@@ -2075,10 +2075,10 @@ static uint64_t PageDisabledWidgets[] = {
}
// X and Y spinners
SetWidgetDisabledAndInvalidate(
WIDX_SPINNER_X_INCREASE, !(_tileSelected && ((_toolMap.x / 32) < MAXIMUM_MAP_SIZE_TECHNICAL - 1)));
WIDX_SPINNER_X_INCREASE, !(_tileSelected && ((_toolMap.x / 32) < kMaximumMapSizeTechnical - 1)));
SetWidgetDisabledAndInvalidate(WIDX_SPINNER_X_DECREASE, !(_tileSelected && ((_toolMap.x / 32) > 0)));
SetWidgetDisabledAndInvalidate(
WIDX_SPINNER_Y_INCREASE, !(_tileSelected && ((_toolMap.y / 32) < MAXIMUM_MAP_SIZE_TECHNICAL - 1)));
WIDX_SPINNER_Y_INCREASE, !(_tileSelected && ((_toolMap.y / 32) < kMaximumMapSizeTechnical - 1)));
SetWidgetDisabledAndInvalidate(WIDX_SPINNER_Y_DECREASE, !(_tileSelected && ((_toolMap.y / 32) > 0)));
// Sort buttons
+2 -2
View File
@@ -450,9 +450,9 @@ static void FixInvalidSurfaces()
// Fixes broken saves where a surface element could be null
// and broken saves with incorrect invisible map border tiles
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
{
auto* surfaceElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y });
+1 -1
View File
@@ -35,7 +35,7 @@ void MapChangeSizeAction::Serialise(DataSerialiser& stream)
GameActions::Result MapChangeSizeAction::Query() const
{
if (_targetSize.x > MAXIMUM_MAP_SIZE_TECHNICAL || _targetSize.y > MAXIMUM_MAP_SIZE_TECHNICAL)
if (_targetSize.x > kMaximumMapSizeTechnical || _targetSize.y > kMaximumMapSizeTechnical)
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_NONE);
}
+3 -3
View File
@@ -44,7 +44,7 @@ static std::vector<EntityId> _freeIdList;
static bool _entityFlashingList[MAX_ENTITIES];
constexpr const uint32_t SPATIAL_INDEX_SIZE = (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) + 1;
constexpr const uint32_t SPATIAL_INDEX_SIZE = (kMaximumMapSizeTechnical * kMaximumMapSizeTechnical) + 1;
constexpr uint32_t SPATIAL_INDEX_LOCATION_NULL = SPATIAL_INDEX_SIZE - 1;
static std::array<std::vector<EntityId>, SPATIAL_INDEX_SIZE> gEntitySpatialIndex;
@@ -60,10 +60,10 @@ static constexpr size_t GetSpatialIndexOffset(const CoordsXY& loc)
const auto tileX = std::abs(loc.x) / COORDS_XY_STEP;
const auto tileY = std::abs(loc.y) / COORDS_XY_STEP;
if (tileX >= MAXIMUM_MAP_SIZE_TECHNICAL || tileY >= MAXIMUM_MAP_SIZE_TECHNICAL)
if (tileX >= kMaximumMapSizeTechnical || tileY >= kMaximumMapSizeTechnical)
return SPATIAL_INDEX_LOCATION_NULL;
return tileX * MAXIMUM_MAP_SIZE_TECHNICAL + tileY;
return tileX * kMaximumMapSizeTechnical + tileY;
}
constexpr bool EntityTypeIsMiscEntity(const EntityType type)
+3 -3
View File
@@ -17,7 +17,7 @@
// The number of elements in the GameState_t.StaffPatrolAreas array per staff member. Every bit in the array represents a 4x4
// square. Right now, it's a 32-bit array like in RCT2. 32 * 128 = 4096 bits, which is also the number of 4x4 squares on a
// 256x256 map.
constexpr size_t STAFF_PATROL_AREA_BLOCKS_PER_LINE = MAXIMUM_MAP_SIZE_TECHNICAL / 4;
constexpr size_t STAFF_PATROL_AREA_BLOCKS_PER_LINE = kMaximumMapSizeTechnical / 4;
constexpr size_t STAFF_PATROL_AREA_SIZE = (STAFF_PATROL_AREA_BLOCKS_PER_LINE * STAFF_PATROL_AREA_BLOCKS_PER_LINE) / 32;
class PatrolArea
@@ -32,8 +32,8 @@ private:
std::vector<TileCoordsXY> SortedTiles;
};
static constexpr auto CellColumns = (MAXIMUM_MAP_SIZE_TECHNICAL + (Cell::Width - 1)) / Cell::Width;
static constexpr auto CellRows = (MAXIMUM_MAP_SIZE_TECHNICAL + (Cell::Height - 1)) / Cell::Height;
static constexpr auto CellColumns = (kMaximumMapSizeTechnical + (Cell::Width - 1)) / Cell::Width;
static constexpr auto CellRows = (kMaximumMapSizeTechnical + (Cell::Height - 1)) / Cell::Height;
static constexpr auto NumCells = CellColumns * CellRows;
std::array<Cell, NumCells> Areas;
+2 -2
View File
@@ -121,9 +121,9 @@ struct TunnelEntry
uint8_t type;
};
// The maximum size must be MAXIMUM_MAP_SIZE_TECHNICAL multiplied by 2 because
// The maximum size must be kMaximumMapSizeTechnical multiplied by 2 because
// the quadrant index is based on the x and y components combined.
static constexpr int32_t MaxPaintQuadrants = MAXIMUM_MAP_SIZE_TECHNICAL * 2;
static constexpr int32_t MaxPaintQuadrants = kMaximumMapSizeTechnical * 2;
#define TUNNEL_MAX_COUNT 65
+2 -2
View File
@@ -1528,9 +1528,9 @@ namespace RCT1
std::vector<TileElement> tileElements;
const auto maxSize = _s4.MapSize == 0 ? Limits::MaxMapSize : _s4.MapSize;
for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++)
for (TileCoordsXY coords = { 0, 0 }; coords.y < kMaximumMapSizeTechnical; coords.y++)
{
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
for (coords.x = 0; coords.x < kMaximumMapSizeTechnical; coords.x++)
{
auto tileAdded = false;
if (coords.x < maxSize && coords.y < maxSize)
+2 -2
View File
@@ -1802,9 +1802,9 @@ namespace RCT2
bool nextElementInvisible = false;
bool restOfTileInvisible = false;
const auto maxSize = std::min(Limits::MaxMapSize, _s6.MapSize);
for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++)
for (TileCoordsXY coords = { 0, 0 }; coords.y < kMaximumMapSizeTechnical; coords.y++)
{
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
for (coords.x = 0; coords.x < kMaximumMapSizeTechnical; coords.x++)
{
nextElementInvisible = false;
restOfTileInvisible = false;
+1 -1
View File
@@ -2098,7 +2098,7 @@ void TrackDesignDrawPreview(TrackDesign* td6, uint8_t* pixels)
*/
static void TrackDesignPreviewClearMap()
{
auto numTiles = MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL;
auto numTiles = kMaximumMapSizeTechnical * kMaximumMapSizeTechnical;
GetGameState().MapSize = TRACK_DESIGN_PREVIEW_MAP_SIZE;
+10 -10
View File
@@ -152,7 +152,7 @@ void SetTileElements(std::vector<TileElement>&& tileElements)
auto& gameState = GetGameState();
gameState.TileElements = std::move(tileElements);
_tileIndex = TilePointerIndex<TileElement>(
MAXIMUM_MAP_SIZE_TECHNICAL, gameState.TileElements.data(), gameState.TileElements.size());
kMaximumMapSizeTechnical, gameState.TileElements.data(), gameState.TileElements.size());
_tileElementsInUse = gameState.TileElements.size();
}
@@ -177,9 +177,9 @@ std::vector<TileElement> GetReorganisedTileElementsWithoutGhosts()
{
std::vector<TileElement> newElements;
newElements.reserve(std::max(MIN_TILE_ELEMENTS, GetGameState().TileElements.size()));
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
{
auto oldSize = newElements.size();
@@ -217,9 +217,9 @@ static void ReorganiseTileElements(size_t capacity)
std::vector<TileElement> newElements;
newElements.reserve(std::max(MIN_TILE_ELEMENTS, capacity));
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
{
const auto* element = MapGetFirstElementAt(TileCoordsXY{ x, y });
if (element == nullptr)
@@ -336,8 +336,8 @@ void TileElementIteratorRestartForTile(TileElementIterator* it)
static bool IsTileLocationValid(const TileCoordsXY& coords)
{
const bool is_x_valid = coords.x < MAXIMUM_MAP_SIZE_TECHNICAL && coords.x >= 0;
const bool is_y_valid = coords.y < MAXIMUM_MAP_SIZE_TECHNICAL && coords.y >= 0;
const bool is_x_valid = coords.x < kMaximumMapSizeTechnical && coords.x >= 0;
const bool is_y_valid = coords.y < kMaximumMapSizeTechnical && coords.y >= 0;
return is_x_valid && is_y_valid;
}
@@ -454,7 +454,7 @@ BannerElement* MapGetBannerElementAt(const CoordsXYZ& bannerPos, uint8_t positio
*/
void MapInit(const TileCoordsXY& size)
{
auto numTiles = MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL;
auto numTiles = kMaximumMapSizeTechnical * kMaximumMapSizeTechnical;
SetTileElements(std::vector<TileElement>(numTiles, GetDefaultSurfaceElement()));
auto& gameState = GetGameState();
@@ -1420,7 +1420,7 @@ static void MapExtendBoundarySurfaceExtendTile(const SurfaceElement& sourceTile,
void MapExtendBoundarySurfaceY()
{
auto y = GetGameState().MapSize.y - 2;
for (auto x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
for (auto x = 0; x < kMaximumMapSizeTechnical; x++)
{
auto existingTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y - 1 });
auto newTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y });
@@ -1440,7 +1440,7 @@ void MapExtendBoundarySurfaceY()
void MapExtendBoundarySurfaceX()
{
auto x = GetGameState().MapSize.x - 2;
for (auto y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
for (auto y = 0; y < kMaximumMapSizeTechnical; y++)
{
auto existingTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x - 1, y });
auto newTileElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y });
+5 -5
View File
@@ -26,10 +26,10 @@ constexpr uint8_t kMaximumWaterHeight = 254;
constexpr uint8_t kMapBaseZ = 7;
constexpr uint8_t kMinimumMapSizeTechnical{ 5 };
#define MAXIMUM_MAP_SIZE_TECHNICAL 1001
constexpr uint16_t kMaximumMapSizeTechnical{ 1001 };
#define MINIMUM_MAP_SIZE_PRACTICAL (kMinimumMapSizeTechnical - 2)
#define MAXIMUM_MAP_SIZE_PRACTICAL (MAXIMUM_MAP_SIZE_TECHNICAL - 2)
constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * MAXIMUM_MAP_SIZE_TECHNICAL;
#define MAXIMUM_MAP_SIZE_PRACTICAL (kMaximumMapSizeTechnical - 2)
constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * kMaximumMapSizeTechnical;
constexpr int32_t MAXIMUM_TILE_START_XY = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP;
constexpr const int32_t LAND_HEIGHT_STEP = 2 * COORDS_Z_STEP;
constexpr const int32_t WATER_HEIGHT_STEP = 2 * COORDS_Z_STEP;
@@ -40,11 +40,11 @@ constexpr uint8_t ConstructionRightsClearanceSmall = 3;
// Same as previous, but in big coords.
constexpr const uint8_t ConstructionRightsClearanceBig = 3 * COORDS_Z_STEP;
#define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL)
#define MAP_MINIMUM_X_Y (-kMaximumMapSizeTechnical)
constexpr uint32_t MAX_TILE_ELEMENTS_WITH_SPARE_ROOM = 0x1000000;
constexpr uint32_t MAX_TILE_ELEMENTS = MAX_TILE_ELEMENTS_WITH_SPARE_ROOM - 512;
#define MAX_TILE_TILE_ELEMENT_POINTERS (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL)
#define MAX_TILE_TILE_ELEMENT_POINTERS (kMaximumMapSizeTechnical * kMaximumMapSizeTechnical)
#define TILE_UNDEFINED_TILE_ELEMENT NULL