diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 47afa39d56..eecf6c6c89 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -775,7 +775,7 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC if (slope & RAISE_FOOTPATH_FLAG) { slope &= ~RAISE_FOOTPATH_FLAG; - z += (2 * 8); + z += PATH_HEIGHT_STEP; } int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); @@ -822,10 +822,10 @@ static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY s uint8_t slope = tileElement->AsSurface()->GetSlope(); if (slope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) { - z += (2 * 8); + z += PATH_HEIGHT_STEP; } // Add 2 for a slope if (slope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) - z += (2 * 8); // Add another 2 for a steep slope + z += PATH_HEIGHT_STEP; // Add another 2 for a steep slope } gMapSelectArrowPosition.z = z; @@ -878,7 +878,7 @@ static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords) if (currentType & RAISE_FOOTPATH_FLAG) { currentType &= ~RAISE_FOOTPATH_FLAG; - z += (2 * 8); + z += PATH_HEIGHT_STEP; } selectedType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); @@ -926,12 +926,12 @@ static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords) if (slope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) { // Steep diagonal slope - z += (4 * 8); + z += 2 * PATH_HEIGHT_STEP; } else if (slope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) { // Normal slope - z += (2 * 8); + z += PATH_HEIGHT_STEP; } } else @@ -943,7 +943,7 @@ static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords) { if (direction == (tileElement->AsPath()->GetSlopeDirection())) { - z += (2 * 8); + z += PATH_HEIGHT_STEP; } } } @@ -1002,7 +1002,7 @@ static void window_footpath_construct() // already is lowered if we are building a downwards slope. if (gFootpathConstructSlope == 2) { - gFootpathConstructFromPosition.z += (2 * 8); + gFootpathConstructFromPosition.z += PATH_HEIGHT_STEP; } } window_footpath_set_enabled_and_pressed_widgets(); @@ -1023,7 +1023,7 @@ static void footpath_remove_tile_element(TileElement* tileElement) slopeDirection = direction_reverse(slopeDirection); if (slopeDirection == gFootpathConstructDirection) { - z += (2 * 8); + z += PATH_HEIGHT_STEP; } } @@ -1229,7 +1229,7 @@ static void footpath_get_next_path_info(int32_t* type, CoordsXYZ& footpathLoc, i *slope = gFootpathConstructDirection | TILE_ELEMENT_SLOPE_S_CORNER_UP; if (gFootpathConstructSlope != 2) { - footpathLoc.z -= (2 * 8); + footpathLoc.z -= PATH_HEIGHT_STEP; *slope ^= TILE_ELEMENT_SLOPE_E_CORNER_UP; } } diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 40bda3d30d..efbabcf911 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -566,8 +566,8 @@ static void window_map_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t static void window_map_scrollmousedown(rct_window* w, int32_t scrollIndex, ScreenCoordsXY screenCoords) { CoordsXY c = map_window_screen_to_map(screenCoords); - int32_t mapX = std::clamp(c.x, 0, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1); - int32_t mapY = std::clamp(c.y, 0, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1); + int32_t mapX = std::clamp(c.x, 0, MAXIMUM_MAP_SIZE_BIG - 1); + int32_t mapY = std::clamp(c.y, 0, MAXIMUM_MAP_SIZE_BIG - 1); int32_t mapZ = tile_element_height({ mapX, mapY }); rct_window* mainWindow = window_get_main(); @@ -1021,15 +1021,15 @@ static MapCoordsXY window_map_transform_to_map_coords(CoordsXY c) { case 3: std::swap(x, y); - x = MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - x; + x = MAXIMUM_MAP_SIZE_BIG - 1 - x; break; case 2: - x = MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - x; - y = MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - y; + x = MAXIMUM_MAP_SIZE_BIG - 1 - x; + y = MAXIMUM_MAP_SIZE_BIG - 1 - y; break; case 1: std::swap(x, y); - y = MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - y; + y = MAXIMUM_MAP_SIZE_BIG - 1 - y; break; case 0: break; @@ -1641,27 +1641,27 @@ static void map_window_set_pixels(rct_window* w) switch (get_current_rotation()) { case 0: - x = _currentLine * 32; + x = _currentLine * COORDS_XY_STEP; y = 0; dx = 0; - dy = 32; + dy = COORDS_XY_STEP; break; case 1: - x = (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32; - y = _currentLine * 32; - dx = -32; + x = MAXIMUM_TILE_START_XY; + y = _currentLine * COORDS_XY_STEP; + dx = -COORDS_XY_STEP; dy = 0; break; case 2: - x = ((MAXIMUM_MAP_SIZE_TECHNICAL - 1) - _currentLine) * 32; - y = (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32; + x = MAXIMUM_MAP_SIZE_BIG - ((_currentLine + 1) * COORDS_XY_STEP); + y = MAXIMUM_TILE_START_XY; dx = 0; - dy = -32; + dy = -COORDS_XY_STEP; break; case 3: x = 0; - y = ((MAXIMUM_MAP_SIZE_TECHNICAL - 1) - _currentLine) * 32; - dx = 32; + y = MAXIMUM_MAP_SIZE_BIG - ((_currentLine + 1) * COORDS_XY_STEP); + dx = COORDS_XY_STEP; dy = 0; break; } @@ -1706,11 +1706,11 @@ static CoordsXY map_window_screen_to_map(ScreenCoordsXY screenCoords) case 0: return { x, y }; case 1: - return { MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - y, x }; + return { MAXIMUM_MAP_SIZE_BIG - 1 - y, x }; case 2: - return { MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - x, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - y }; + return { MAXIMUM_MAP_SIZE_BIG - 1 - x, MAXIMUM_MAP_SIZE_BIG - 1 - y }; case 3: - return { y, MAXIMUM_MAP_SIZE_TECHNICAL * 32 - 1 - x }; + return { y, MAXIMUM_MAP_SIZE_BIG - 1 - x }; } return { 0, 0 }; // unreachable diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 461a4872af..f12b309035 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2420,10 +2420,10 @@ static void sub_6CBCE2( int16_t preserveMapSize = gMapSize; int16_t preserveMapSizeMaxXY = gMapSizeMaxXY; - gMapSizeUnits = (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32; + gMapSizeUnits = MAXIMUM_TILE_START_XY; gMapSizeMinus2 = ((MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32) + 286; gMapSize = MAXIMUM_MAP_SIZE_TECHNICAL; - gMapSizeMaxXY = (MAXIMUM_MAP_SIZE_TECHNICAL * 32) - 1; + gMapSizeMaxXY = MAXIMUM_MAP_SIZE_BIG - 1; auto trackBlock = get_track_def_from_ride(ride, trackType); while (trackBlock->index != 255) @@ -2433,7 +2433,7 @@ static void sub_6CBCE2( CoordsXY coords = originCoords + offsets.Rotate(trackDirection); int32_t baseZ = originZ + trackBlock->z; - int32_t clearanceZ = trackBlock->var_07 + RideData5[ride->type].clearance_height + baseZ + (4 * 8); + int32_t clearanceZ = trackBlock->var_07 + RideData5[ride->type].clearance_height + baseZ + (4 * COORDS_Z_STEP); auto centreTileCoords = TileCoordsXY{ coords }; auto eastTileCoords = centreTileCoords + TileDirectionDelta[TILE_ELEMENT_DIRECTION_EAST]; diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 672f6a95d3..84bcb37a23 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1002,8 +1002,7 @@ static void window_tile_inspector_mousedown(rct_window* w, rct_widgetindex widge { case WIDX_SPINNER_X_INCREASE: windowTileInspectorTileX = std::min(windowTileInspectorTileX + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1); - windowTileInspectorToolMap.x = std::min( - windowTileInspectorToolMap.x + 32, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32); + windowTileInspectorToolMap.x = std::min(windowTileInspectorToolMap.x + 32, MAXIMUM_TILE_START_XY); window_tile_inspector_load_tile(w, nullptr); break; case WIDX_SPINNER_X_DECREASE: @@ -1013,8 +1012,7 @@ static void window_tile_inspector_mousedown(rct_window* w, rct_widgetindex widge break; case WIDX_SPINNER_Y_INCREASE: windowTileInspectorTileY = std::min(windowTileInspectorTileY + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1); - windowTileInspectorToolMap.y = std::min( - windowTileInspectorToolMap.y + 32, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32); + windowTileInspectorToolMap.y = std::min(windowTileInspectorToolMap.y + 32, MAXIMUM_TILE_START_XY); window_tile_inspector_load_tile(w, nullptr); break; case WIDX_SPINNER_Y_DECREASE: diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 600a949423..0789e35b39 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -508,8 +508,8 @@ void game_fix_save_vars() // At this point, we can be sure that surfaceElement is not NULL. if (x == 0 || x == gMapSize - 1 || y == 0 || y == gMapSize - 1) { - surfaceElement->base_height = 2; - surfaceElement->clearance_height = 2; + surfaceElement->SetBaseZ(2 * COORDS_Z_STEP); + surfaceElement->SetClearanceZ(2 * COORDS_Z_STEP); surfaceElement->SetSlope(0); surfaceElement->SetWaterHeight(0); } diff --git a/src/openrct2/actions/BannerPlaceAction.hpp b/src/openrct2/actions/BannerPlaceAction.hpp index 667712e145..2a5a59786e 100644 --- a/src/openrct2/actions/BannerPlaceAction.hpp +++ b/src/openrct2/actions/BannerPlaceAction.hpp @@ -77,7 +77,7 @@ public: return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK); } - uint8_t baseHeight = _loc.z + (2 * 8); + uint8_t baseHeight = _loc.z + PATH_HEIGHT_STEP; BannerElement* existingBannerElement = map_get_banner_element_at({ _loc.x, _loc.y, baseHeight }, _loc.direction); if (existingBannerElement != nullptr) { @@ -184,7 +184,7 @@ private: auto pathElement = tileElement->AsPath(); - if (pathElement->GetBaseZ() != _loc.z && pathElement->GetBaseZ() != _loc.z - (2 * 8)) + if (pathElement->GetBaseZ() != _loc.z && pathElement->GetBaseZ() != _loc.z - PATH_HEIGHT_STEP) continue; if (!(pathElement->GetEdges() & (1 << _loc.direction))) diff --git a/src/openrct2/actions/ClearAction.hpp b/src/openrct2/actions/ClearAction.hpp index c5648e14ed..38977683ae 100644 --- a/src/openrct2/actions/ClearAction.hpp +++ b/src/openrct2/actions/ClearAction.hpp @@ -98,9 +98,9 @@ private: auto x1 = std::min(_range.GetRight(), (int32_t)gMapSizeMaxXY); auto y1 = std::min(_range.GetBottom(), (int32_t)gMapSizeMaxXY); - for (int32_t y = y0; y <= y1; y += 32) + for (int32_t y = y0; y <= y1; y += COORDS_XY_STEP) { - for (int32_t x = x0; x <= x1; x += 32) + for (int32_t x = x0; x <= x1; x += COORDS_XY_STEP) { if (MapCanClearAt(x, y)) { diff --git a/src/openrct2/actions/LandBuyRightsAction.hpp b/src/openrct2/actions/LandBuyRightsAction.hpp index 5eb478d5fb..7f7867396e 100644 --- a/src/openrct2/actions/LandBuyRightsAction.hpp +++ b/src/openrct2/actions/LandBuyRightsAction.hpp @@ -99,9 +99,9 @@ private: res->Expenditure = ExpenditureType::LandPurchase; // Game command modified to accept selection size - for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto result = map_buy_land_rights_for_tile({ x, y }, isExecuting); if (result->Error == GA_ERROR::OK) diff --git a/src/openrct2/actions/LandLowerAction.hpp b/src/openrct2/actions/LandLowerAction.hpp index a1f76a5afe..30d919c420 100644 --- a/src/openrct2/actions/LandLowerAction.hpp +++ b/src/openrct2/actions/LandLowerAction.hpp @@ -93,9 +93,9 @@ private: uint8_t maxHeight = map_get_highest_land_height(validRange); - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(CoordsXY{ x, y }); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/LandRaiseAction.hpp b/src/openrct2/actions/LandRaiseAction.hpp index 502d1df6d4..365fafc01b 100644 --- a/src/openrct2/actions/LandRaiseAction.hpp +++ b/src/openrct2/actions/LandRaiseAction.hpp @@ -94,9 +94,9 @@ private: uint8_t minHeight = map_get_lowest_land_height(validRange); - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(CoordsXY{ x, y }); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/LandSetRightsAction.hpp b/src/openrct2/actions/LandSetRightsAction.hpp index 18bfd477e7..a42a75604d 100644 --- a/src/openrct2/actions/LandSetRightsAction.hpp +++ b/src/openrct2/actions/LandSetRightsAction.hpp @@ -108,9 +108,9 @@ private: } // Game command modified to accept selection size - for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (auto y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (auto x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto result = map_buy_land_rights_for_tile({ x, y }, isExecuting); if (result->Error == GA_ERROR::OK) diff --git a/src/openrct2/actions/LandSmoothAction.hpp b/src/openrct2/actions/LandSmoothAction.hpp index baf0524c9d..8352ab7afe 100644 --- a/src/openrct2/actions/LandSmoothAction.hpp +++ b/src/openrct2/actions/LandSmoothAction.hpp @@ -346,8 +346,8 @@ private: // Cap bounds to map auto l = std::max(normRange.GetLeft(), 32); auto t = std::max(normRange.GetTop(), 32); - auto r = std::clamp(normRange.GetRight(), 0, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32); - auto b = std::clamp(normRange.GetBottom(), 0, (MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32); + auto r = std::clamp(normRange.GetRight(), 0, MAXIMUM_TILE_START_XY); + auto b = std::clamp(normRange.GetBottom(), 0, MAXIMUM_TILE_START_XY); auto validRange = MapRange{ l, t, r, b }; int32_t centreZ = tile_element_height(_coords); @@ -409,7 +409,7 @@ private: // Smooth the edges int32_t z1, z2; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { auto surfaceElement = map_get_surface_element_at(CoordsXY{ validRange.GetLeft(), y }); if (surfaceElement != nullptr) @@ -428,7 +428,7 @@ private: } } - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto surfaceElement = map_get_surface_element_at(CoordsXY{ x, validRange.GetTop() }); if (surfaceElement != nullptr) diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 92eaf69669..b5058289d0 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -732,9 +732,9 @@ private: const int32_t min = 32; const int32_t max = gMapSizeUnits - 32; - for (CoordsXY coords = { min, min }; coords.y <= max; coords.y += 32) + for (CoordsXY coords = { min, min }; coords.y <= max; coords.y += COORDS_XY_STEP) { - for (coords.x = min; coords.x <= max; coords.x += 32) + for (coords.x = min; coords.x <= max; coords.x += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(coords); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp index e5ba6a75aa..7bcd14f26b 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -89,9 +89,9 @@ public: gStaffModes[peep->staff_id] |= (1 << 1); } - for (int32_t y = 0; y < 4 * 32; y += 32) + for (int32_t y = 0; y < 4 * 32; y += COORDS_XY_STEP) { - for (int32_t x = 0; x < 4 * 32; x += 32) + for (int32_t x = 0; x < 4 * 32; x += COORDS_XY_STEP) { map_invalidate_tile_full({ (_loc.x & 0x1F80) + x, (_loc.y & 0x1F80) + y }); } diff --git a/src/openrct2/actions/SurfaceSetStyleAction.hpp b/src/openrct2/actions/SurfaceSetStyleAction.hpp index 50eaf7773d..47f47666a7 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.hpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.hpp @@ -114,9 +114,9 @@ public: money32 surfaceCost = 0; money32 edgeCost = 0; - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) { @@ -185,9 +185,9 @@ public: money32 surfaceCost = 0; money32 edgeCost = 0; - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) { diff --git a/src/openrct2/actions/WaterLowerAction.hpp b/src/openrct2/actions/WaterLowerAction.hpp index f77434a08b..69cd9a58fe 100644 --- a/src/openrct2/actions/WaterLowerAction.hpp +++ b/src/openrct2/actions/WaterLowerAction.hpp @@ -74,9 +74,9 @@ private: uint8_t minHeight = GetLowestHeight(validRange); bool hasChanged = false; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(CoordsXY{ x, y }); if (surfaceElement == nullptr) @@ -123,9 +123,9 @@ private: { // The lowest height to lower the water to is the highest water level in the selection uint8_t minHeight{ 0 }; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(CoordsXY{ x, y }); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/WaterRaiseAction.hpp b/src/openrct2/actions/WaterRaiseAction.hpp index e7392731ff..b8752a56db 100644 --- a/src/openrct2/actions/WaterRaiseAction.hpp +++ b/src/openrct2/actions/WaterRaiseAction.hpp @@ -75,9 +75,9 @@ private: uint8_t maxHeight = GetHighestHeight(validRange); bool hasChanged = false; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto surfaceElement = map_get_surface_element_at(CoordsXY{ x, y }); if (surfaceElement == nullptr) @@ -130,9 +130,9 @@ private: { // The highest height to raise the water to is the lowest water level in the selection uint8_t maxHeight{ 255 }; - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(CoordsXY{ x, y }); if (surfaceElement == nullptr) diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index 32ef8dddea..4a191c476a 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -317,7 +317,7 @@ void lightfx_prepare_light_list() } int32_t minDist = 0; - int32_t baseHeight = (-999) * 8; + int32_t baseHeight = (-999) * COORDS_Z_STEP; if (interactionType != VIEWPORT_INTERACTION_ITEM_SPRITE && tileElement) { diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index f4599bd1e0..e1367cc327 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1269,7 +1269,7 @@ static int32_t cc_for_date([[maybe_unused]] InteractiveConsole& console, [[maybe // All cases involve providing a year, so grab that first year = atoi(argv[0].c_str()); - if (year < 1 || year > 8192) + if (year < 1 || year > MAX_YEAR) { return -1; } diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 3b7ba59ae4..d00fea053a 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -297,11 +297,11 @@ static int32_t GetHighestBaseClearanceZ(CoordsXY location) { do { - z = std::max(z, element->base_height); - z = std::max(z, element->clearance_height); + z = std::max(z, element->GetBaseZ()); + z = std::max(z, element->GetClearanceZ()); } while (!(element++)->IsLastForTile()); } - return z * 8; + return z; } static int32_t GetTallestVisibleTileTop(int32_t mapSize, int32_t rotation) @@ -311,7 +311,7 @@ static int32_t GetTallestVisibleTileTop(int32_t mapSize, int32_t rotation) { for (int32_t x = 1; x < mapSize - 1; x++) { - auto location = CoordsXY(x * 32, y * 32); + auto location = TileCoordsXY(x, y).ToCoordsXY(); int32_t z = GetHighestBaseClearanceZ(location); int32_t viewY = translate_3d_to_2d_with_z(rotation, CoordsXYZ(location, z)).y; minViewY = std::min(minViewY, viewY); diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 0b200ac7de..69d4c048e0 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -1924,9 +1924,9 @@ std::bitset Guest::FindRidesToGoOn() constexpr auto radius = 10 * 32; int32_t cx = floor2(x, 32); int32_t cy = floor2(y, 32); - for (int32_t tileX = cx - radius; tileX <= cx + radius; tileX += 32) + for (int32_t tileX = cx - radius; tileX <= cx + radius; tileX += COORDS_XY_STEP) { - for (int32_t tileY = cy - radius; tileY <= cy + radius; tileY += 32) + for (int32_t tileY = cy - radius; tileY <= cy + radius; tileY += COORDS_XY_STEP) { if (map_is_location_valid({ tileX, tileY })) { @@ -2941,12 +2941,12 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre int16_t initial_x = std::max(centre_x - 160, 0); int16_t initial_y = std::max(centre_y - 160, 0); - int16_t final_x = std::min(centre_x + 160, 8192); - int16_t final_y = std::min(centre_y + 160, 8192); + int16_t final_x = std::min(centre_x + 160, MAXIMUM_MAP_SIZE_BIG); + int16_t final_y = std::min(centre_y + 160, MAXIMUM_MAP_SIZE_BIG); - for (int16_t x = initial_x; x < final_x; x += 32) + for (int16_t x = initial_x; x < final_x; x += COORDS_XY_STEP) { - for (int16_t y = initial_y; y < final_y; y += 32) + for (int16_t y = initial_y; y < final_y; y += COORDS_XY_STEP) { TileElement* tileElement = map_get_first_element_at({ x, y }); if (tileElement == nullptr) @@ -3181,9 +3181,9 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co constexpr auto searchRadius = 10 * 32; int32_t cx = floor2(peep->x, 32); int32_t cy = floor2(peep->y, 32); - for (auto x = cx - searchRadius; x <= cx + searchRadius; x += 32) + for (auto x = cx - searchRadius; x <= cx + searchRadius; x += COORDS_XY_STEP) { - for (auto y = cy - searchRadius; y <= cy + searchRadius; y += 32) + for (auto y = cy - searchRadius; y <= cy + searchRadius; y += COORDS_XY_STEP) { if (map_is_location_valid({ x, y })) { diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 9b6083a1ac..15e0c570a2 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -114,7 +114,7 @@ static int32_t peep_move_one_tile(Direction direction, Peep* peep) x += CoordsDirectionDelta[direction].x; y += CoordsDirectionDelta[direction].y; - if (x >= 8192 || y >= 8192) + if (x >= MAXIMUM_MAP_SIZE_BIG || y >= MAXIMUM_MAP_SIZE_BIG) { // This could loop! return guest_surface_path_finding(peep); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 73749e97de..2fa480778b 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2126,10 +2126,10 @@ void Ride::UpdateChairlift() return; auto bullwheelLoc = ChairliftBullwheelLocation[0].ToCoordsXYZ(); - map_invalidate_tile_zoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * 8) }); + map_invalidate_tile_zoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * COORDS_Z_STEP) }); bullwheelLoc = ChairliftBullwheelLocation[1].ToCoordsXYZ(); - map_invalidate_tile_zoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * 8) }); + map_invalidate_tile_zoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * COORDS_Z_STEP) }); } /** diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index f339433f2b..204e1e1381 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -354,9 +354,9 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride) // x is defined here as we can start the search // on tile start_x, start_y but then the next row // must restart on 0 - for (int32_t y = startLoc.y, x = startLoc.y; y < 8192; y += 32) + for (int32_t y = startLoc.y, x = startLoc.y; y < MAXIMUM_MAP_SIZE_BIG; y += COORDS_XY_STEP) { - for (; x < 8192; x += 32) + for (; x < MAXIMUM_MAP_SIZE_BIG; x += COORDS_XY_STEP) { auto tileElement = map_get_first_element_at({ x, y }); do @@ -460,9 +460,9 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride) CoordsXYE TrackDesign::MazeGetFirstElement(const Ride& ride) { CoordsXYE tile{}; - for (tile.y = 0; tile.y < 8192; tile.y += 32) + for (tile.y = 0; tile.y < MAXIMUM_MAP_SIZE_BIG; tile.y += COORDS_XY_STEP) { - for (tile.x = 0; tile.x < 8192; tile.x += 32) + for (tile.x = 0; tile.x < MAXIMUM_MAP_SIZE_BIG; tile.x += COORDS_XY_STEP) { tile.element = map_get_first_element_at({ tile.x, tile.y }); do diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 5399fa5358..3602b7f0db 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -190,7 +190,7 @@ money32 footpath_provisional_set(int32_t type, CoordsXYZ footpathLoc, int32_t sl else { // Going up in the world! - virtual_floor_set_height(gFootpathProvisionalPosition.z + (2 * 8)); + virtual_floor_set_height(gFootpathProvisionalPosition.z + LAND_HEIGHT_STEP); } } diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index b70004143e..42a6552f2b 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -23,6 +23,7 @@ enum constexpr auto FootpathMaxHeight = 248; constexpr auto FootpathMinHeight = 2; +constexpr auto PATH_HEIGHT_STEP = 2 * COORDS_Z_STEP; #define FOOTPATH_ELEMENT_INSERT_QUEUE 0x80 diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index 8915efa94d..c1ad33c55c 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -16,6 +16,9 @@ #define LOCATION_NULL ((int16_t)(uint16_t)0x8000) #define RCT_XY8_UNDEFINED 0xFFFF +constexpr const int32_t COORDS_XY_STEP = 32; +constexpr const int32_t COORDS_Z_STEP = 8; + constexpr const auto NumOrthogonalDirections = 4; #pragma pack(push, 1) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index ec3bcce776..9d38798451 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -628,12 +628,12 @@ void map_update_path_wide_flags() footpath_update_path_wide_flags(x, y); // Next x, y tile - x += 32; - if (x >= MAXIMUM_MAP_SIZE_TECHNICAL * 32) + x += COORDS_XY_STEP; + if (x >= MAXIMUM_MAP_SIZE_BIG) { x = 0; - y += 32; - if (y >= MAXIMUM_MAP_SIZE_TECHNICAL * 32) + y += COORDS_XY_STEP; + if (y >= MAXIMUM_MAP_SIZE_BIG) { y = 0; } @@ -668,8 +668,8 @@ int32_t map_height_from_slope(const CoordsXY& coords, int32_t slope, bool isSlop bool map_is_location_valid(const CoordsXY& coords) { - const bool is_x_valid = coords.x < (MAXIMUM_MAP_SIZE_TECHNICAL * 32) && coords.x >= 0; - const bool is_y_valid = coords.y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32) && coords.y >= 0; + const bool is_x_valid = coords.x < MAXIMUM_MAP_SIZE_BIG && coords.x >= 0; + const bool is_y_valid = coords.y < MAXIMUM_MAP_SIZE_BIG && coords.y >= 0; return is_x_valid && is_y_valid; } @@ -706,7 +706,7 @@ bool map_is_location_owned(const CoordsXYZ& loc) if (surfaceElement->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) { - if (loc.z < surfaceElement->GetBaseZ() || loc.z - (2 * 8) > surfaceElement->GetBaseZ()) + if (loc.z < surfaceElement->GetBaseZ() || loc.z - LAND_HEIGHT_STEP > surfaceElement->GetBaseZ()) return true; } } @@ -865,9 +865,9 @@ uint8_t map_get_lowest_land_height(const MapRange& range) std::min(range.GetBottom(), (int32_t)gMapSizeMaxXY) }; uint8_t min_height = 0xFF; - for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += 32) + for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += COORDS_XY_STEP) { - for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += 32) + for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(CoordsXY{ xi, yi }); if (surfaceElement != nullptr && min_height > surfaceElement->base_height) @@ -886,9 +886,9 @@ uint8_t map_get_highest_land_height(const MapRange& range) std::min(range.GetBottom(), (int32_t)gMapSizeMaxXY) }; uint8_t max_height = 0; - for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += 32) + for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += COORDS_XY_STEP) { - for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += 32) + for (int32_t xi = validRange.GetLeft(); xi <= validRange.GetRight(); xi += COORDS_XY_STEP) { auto* surfaceElement = map_get_surface_element_at(CoordsXY{ xi, yi }); if (surfaceElement != nullptr) @@ -908,8 +908,7 @@ uint8_t map_get_highest_land_height(const MapRange& range) bool map_is_location_at_edge(const CoordsXY& loc) { - return loc.x < 32 || loc.y < 32 || loc.x >= ((MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32) - || loc.y >= ((MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32); + return loc.x < 32 || loc.y < 32 || loc.x >= (MAXIMUM_TILE_START_XY) || loc.y >= (MAXIMUM_TILE_START_XY); } /** @@ -1540,9 +1539,9 @@ void map_remove_out_of_range_elements() bool buildState = gCheatsBuildInPauseMode; gCheatsBuildInPauseMode = true; - for (int32_t y = 0; y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); y += 32) + for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_BIG; y += COORDS_XY_STEP) { - for (int32_t x = 0; x < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); x += 32) + for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_BIG; x += COORDS_XY_STEP) { if (x == 0 || y == 0 || x >= mapMaxXY || y >= mapMaxXY) { @@ -2113,9 +2112,9 @@ bool map_surface_is_blocked(CoordsXY mapCoords) /* Clears all map elements, to be used before generating a new map */ void map_clear_all_elements() { - for (int32_t y = 0; y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); y += 32) + for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_BIG; y += COORDS_XY_STEP) { - for (int32_t x = 0; x < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); x += 32) + for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_BIG; x += COORDS_XY_STEP) { clear_elements_at({ x, y }); } diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 22220bd9ce..57c403f15b 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -26,6 +26,9 @@ #define MAXIMUM_MAP_SIZE_TECHNICAL 256 #define MINIMUM_MAP_SIZE_PRACTICAL (MINIMUM_MAP_SIZE_TECHNICAL - 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; +constexpr const int32_t MAXIMUM_TILE_START_XY = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP; +constexpr const int32_t LAND_HEIGHT_STEP = 2 * COORDS_Z_STEP; #define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL) diff --git a/src/openrct2/world/Surface.cpp b/src/openrct2/world/Surface.cpp index c17167fbc5..51bb5c9ae2 100644 --- a/src/openrct2/world/Surface.cpp +++ b/src/openrct2/world/Surface.cpp @@ -122,9 +122,9 @@ void SurfaceElement::UpdateGrassLength(CoordsXY coords) // if there is an object placed on top of it. int32_t zLow = GetBaseZ(); - int32_t zHigh = GetBaseZ() + (2 * 8); + int32_t zHigh = GetBaseZ() + LAND_HEIGHT_STEP; if (Slope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) - zHigh += (2 * 8); + zHigh += LAND_HEIGHT_STEP; // Check objects above grass TileElement* tileElementAbove = (TileElement*)this;