diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index fbcef9ac90..c9a6de1d09 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -1620,11 +1620,11 @@ void InputScrollViewport(const ScreenCoordsXY& scrollScreenCoords) } // Clamp to the map maximum value (scenario specific) - if (mapCoord.x > gMapSizeMinus2 || mapCoord.y > gMapSizeMinus2) + if (mapCoord.x > GetMapSizeMinus2() || mapCoord.y > GetMapSizeMinus2()) { at_map_edge = 1; } - if (mapCoord_dy.x > gMapSizeMinus2 || mapCoord_dy.y > gMapSizeMinus2) + if (mapCoord_dy.x > GetMapSizeMinus2() || mapCoord_dy.y > GetMapSizeMinus2()) { at_map_edge_dy = 1; } diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 5023985340..c16fc37bcb 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1373,9 +1373,6 @@ static void map_window_increase_map_size() } gMapSize++; - gMapSizeUnits = (gMapSize - 1) * 32; - gMapSizeMinus2 = (gMapSize * 32) + MAXIMUM_MAP_SIZE_PRACTICAL; - gMapSizeMaxXY = ((gMapSize - 1) * 32) - 1; map_extend_boundary_surface(); window_map_init_map(); window_map_centre_on_view_point(); @@ -1395,9 +1392,6 @@ static void map_window_decrease_map_size() } gMapSize--; - gMapSizeUnits = (gMapSize - 1) * 32; - gMapSizeMinus2 = (gMapSize * 32) + MAXIMUM_MAP_SIZE_PRACTICAL; - gMapSizeMaxXY = ((gMapSize - 1) * 32) - 1; map_remove_out_of_range_elements(); window_map_init_map(); window_map_centre_on_view_point(); @@ -1575,7 +1569,7 @@ static void map_window_set_pixels(rct_window* w) for (int32_t i = 0; i < MAXIMUM_MAP_SIZE_TECHNICAL; i++) { - if (x > 0 && y > 0 && x < gMapSizeUnits && y < gMapSizeUnits) + if (x > 0 && y > 0 && x < GetMapSizeUnits() && y < GetMapSizeUnits()) { switch (w->selected_tab) { diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 5bef40dac5..951f8d321b 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2390,15 +2390,9 @@ static void sub_6CBCE2( if (ride == nullptr) return; - int16_t preserveMapSizeUnits = gMapSizeUnits; - int16_t preserveMapSizeMinus2 = gMapSizeMinus2; - int16_t preserveMapSize = gMapSize; - int16_t preserveMapSizeMaxXY = gMapSizeMaxXY; + int32_t preserveMapSize = gMapSize; - gMapSizeUnits = MAXIMUM_TILE_START_XY; - gMapSizeMinus2 = ((MAXIMUM_MAP_SIZE_TECHNICAL - 1) * 32) + 286; gMapSize = MAXIMUM_MAP_SIZE_TECHNICAL; - gMapSizeMaxXY = MAXIMUM_MAP_SIZE_BIG - 1; auto trackBlock = TrackBlocks[trackType]; while (trackBlock->index != 255) @@ -2458,10 +2452,7 @@ static void sub_6CBCE2( trackBlock++; } - gMapSizeUnits = preserveMapSizeUnits; - gMapSizeMinus2 = preserveMapSizeMinus2; gMapSize = preserveMapSize; - gMapSizeMaxXY = preserveMapSizeMaxXY; PaintSessionArrange(session); PaintDrawStructs(session); diff --git a/src/openrct2/actions/ClearAction.cpp b/src/openrct2/actions/ClearAction.cpp index e866d14dea..cfeea2f993 100644 --- a/src/openrct2/actions/ClearAction.cpp +++ b/src/openrct2/actions/ClearAction.cpp @@ -72,8 +72,8 @@ GameActions::Result::Ptr ClearAction::QueryExecute(bool executing) const auto x0 = std::max(_range.GetLeft(), 32); auto y0 = std::max(_range.GetTop(), 32); - auto x1 = std::min(_range.GetRight(), static_cast(gMapSizeMaxXY)); - auto y1 = std::min(_range.GetBottom(), static_cast(gMapSizeMaxXY)); + auto x1 = std::min(_range.GetRight(), GetMapSizeMaxXY()); + auto y1 = std::min(_range.GetBottom(), GetMapSizeMaxXY()); for (int32_t y = y0; y <= y1; y += COORDS_XY_STEP) { diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index 42cf8ad919..8b8af8aec7 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -388,10 +388,10 @@ void FootpathPlaceAction::AutomaticallySetPeepSpawn() const if (_loc.x != 32) { direction++; - if (_loc.y != gMapSizeUnits - 32) + if (_loc.y != GetMapSizeUnits() - 32) { direction++; - if (_loc.x != gMapSizeUnits - 32) + if (_loc.x != GetMapSizeUnits() - 32) { direction++; if (_loc.y != 32) diff --git a/src/openrct2/actions/LandBuyRightsAction.cpp b/src/openrct2/actions/LandBuyRightsAction.cpp index 9590ce9b61..473090d47d 100644 --- a/src/openrct2/actions/LandBuyRightsAction.cpp +++ b/src/openrct2/actions/LandBuyRightsAction.cpp @@ -66,9 +66,9 @@ GameActions::Result::Ptr LandBuyRightsAction::QueryExecute(bool isExecuting) con MapRange normRange = _range.Normalise(); // Keep big coordinates within map boundaries auto aX = std::max(32, normRange.GetLeft()); - auto bX = std::min(gMapSizeMaxXY, normRange.GetRight()); + auto bX = std::min(GetMapSizeMaxXY(), normRange.GetRight()); auto aY = std::max(32, normRange.GetTop()); - auto bY = std::min(gMapSizeMaxXY, normRange.GetBottom()); + auto bY = std::min(GetMapSizeMaxXY(), normRange.GetBottom()); MapRange validRange = MapRange{ aX, aY, bX, bY }; diff --git a/src/openrct2/actions/LandLowerAction.cpp b/src/openrct2/actions/LandLowerAction.cpp index 8d1e558063..a4267544d0 100644 --- a/src/openrct2/actions/LandLowerAction.cpp +++ b/src/openrct2/actions/LandLowerAction.cpp @@ -64,9 +64,9 @@ GameActions::Result::Ptr LandLowerAction::QueryExecute(bool isExecuting) const // Keep big coordinates within map boundaries auto aX = std::max(32, _range.GetLeft()); - auto bX = std::min(gMapSizeMaxXY, _range.GetRight()); + auto bX = std::min(GetMapSizeMaxXY(), _range.GetRight()); auto aY = std::max(32, _range.GetTop()); - auto bY = std::min(gMapSizeMaxXY, _range.GetBottom()); + auto bY = std::min(GetMapSizeMaxXY(), _range.GetBottom()); MapRange validRange = MapRange{ aX, aY, bX, bY }; diff --git a/src/openrct2/actions/LandRaiseAction.cpp b/src/openrct2/actions/LandRaiseAction.cpp index 4808860903..0dab4932f9 100644 --- a/src/openrct2/actions/LandRaiseAction.cpp +++ b/src/openrct2/actions/LandRaiseAction.cpp @@ -65,9 +65,9 @@ GameActions::Result::Ptr LandRaiseAction::QueryExecute(bool isExecuting) const // Keep big coordinates within map boundaries auto aX = std::max(32, _range.GetLeft()); - auto bX = std::min(gMapSizeMaxXY, _range.GetRight()); + auto bX = std::min(GetMapSizeMaxXY(), _range.GetRight()); auto aY = std::max(32, _range.GetTop()); - auto bY = std::min(gMapSizeMaxXY, _range.GetBottom()); + auto bY = std::min(GetMapSizeMaxXY(), _range.GetBottom()); MapRange validRange = MapRange{ aX, aY, bX, bY }; diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index 0287891163..29bb8336ac 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -184,7 +184,7 @@ rct_string_id LandSetHeightAction::CheckParameters() const return STR_OFF_EDGE_OF_MAP; } - if (_coords.x > gMapSizeMaxXY || _coords.y > gMapSizeMaxXY) + if (_coords.x > GetMapSizeMaxXY() || _coords.y > GetMapSizeMaxXY()) { return STR_OFF_EDGE_OF_MAP; } diff --git a/src/openrct2/actions/LandSetRightsAction.cpp b/src/openrct2/actions/LandSetRightsAction.cpp index 4f82ebec6d..604df551c5 100644 --- a/src/openrct2/actions/LandSetRightsAction.cpp +++ b/src/openrct2/actions/LandSetRightsAction.cpp @@ -71,9 +71,9 @@ GameActions::Result::Ptr LandSetRightsAction::QueryExecute(bool isExecuting) con MapRange normRange = _range.Normalise(); // Keep big coordinates within map boundaries auto aX = std::max(32, normRange.GetLeft()); - auto bX = std::min(gMapSizeMaxXY, normRange.GetRight()); + auto bX = std::min(GetMapSizeMaxXY(), normRange.GetRight()); auto aY = std::max(32, normRange.GetTop()); - auto bY = std::min(gMapSizeMaxXY, normRange.GetBottom()); + auto bY = std::min(GetMapSizeMaxXY(), normRange.GetBottom()); MapRange validRange = MapRange{ aX, aY, bX, bY }; diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index ea9c3b86f6..7a12cf19f8 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -185,7 +185,7 @@ GameActions::Result::Ptr LargeSceneryPlaceAction::Query() const res->GroundFlags = tempSceneryGroundFlags; - if (!LocationValid(curTile) || curTile.x >= gMapSizeUnits || curTile.y >= gMapSizeUnits) + if (!LocationValid(curTile) || curTile.x >= GetMapSizeUnits() || curTile.y >= GetMapSizeUnits()) { return std::make_unique(GameActions::Status::Disallowed, STR_OFF_EDGE_OF_MAP); } diff --git a/src/openrct2/actions/LargeScenerySetColourAction.cpp b/src/openrct2/actions/LargeScenerySetColourAction.cpp index 313b07961e..717cef7823 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.cpp +++ b/src/openrct2/actions/LargeScenerySetColourAction.cpp @@ -53,7 +53,7 @@ GameActions::Result::Ptr LargeScenerySetColourAction::QueryExecute(bool isExecut res->Position.z = tile_element_height(_loc); res->ErrorTitle = STR_CANT_REPAINT_THIS; - if (_loc.x < 0 || _loc.y < 0 || _loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY) + if (_loc.x < 0 || _loc.y < 0 || _loc.x > GetMapSizeMaxXY() || _loc.y > GetMapSizeMaxXY()) { log_error("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y); return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); diff --git a/src/openrct2/actions/PlaceParkEntranceAction.cpp b/src/openrct2/actions/PlaceParkEntranceAction.cpp index 661a69e1b9..e19a26cdaa 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.cpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.cpp @@ -56,8 +56,8 @@ GameActions::Result::Ptr PlaceParkEntranceAction::Query() const GameActions::Status::NoFreeElements, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); } - if (!LocationValid(_loc) || _loc.x <= 32 || _loc.y <= 32 || _loc.x >= (gMapSizeUnits - 32) - || _loc.y >= (gMapSizeUnits - 32)) + if (!LocationValid(_loc) || _loc.x <= 32 || _loc.y <= 32 || _loc.x >= (GetMapSizeUnits() - 32) + || _loc.y >= (GetMapSizeUnits() - 32)) { return std::make_unique( GameActions::Status::InvalidParameters, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP); diff --git a/src/openrct2/actions/PlacePeepSpawnAction.cpp b/src/openrct2/actions/PlacePeepSpawnAction.cpp index c332f27ef8..914c1e5615 100644 --- a/src/openrct2/actions/PlacePeepSpawnAction.cpp +++ b/src/openrct2/actions/PlacePeepSpawnAction.cpp @@ -53,8 +53,8 @@ GameActions::Result::Ptr PlacePeepSpawnAction::Query() const GameActions::Status::NoFreeElements, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); } - if (!LocationValid(_location) || _location.x <= 16 || _location.y <= 16 || _location.x >= (gMapSizeUnits - 16) - || _location.y >= (gMapSizeUnits - 16)) + if (!LocationValid(_location) || _location.x <= 16 || _location.y <= 16 || _location.x >= (GetMapSizeUnits() - 16) + || _location.y >= (GetMapSizeUnits() - 16)) { return std::make_unique( GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_OFF_EDGE_OF_MAP); diff --git a/src/openrct2/actions/SetCheatAction.cpp b/src/openrct2/actions/SetCheatAction.cpp index 79bea5407f..63c069f95e 100644 --- a/src/openrct2/actions/SetCheatAction.cpp +++ b/src/openrct2/actions/SetCheatAction.cpp @@ -682,7 +682,7 @@ void SetCheatAction::SetStaffSpeed(uint8_t value) const void SetCheatAction::OwnAllLand() const { const int32_t min = 32; - const int32_t max = gMapSizeUnits - 32; + const int32_t max = GetMapSizeUnits() - 32; for (CoordsXY coords = { min, min }; coords.y <= max; coords.y += COORDS_XY_STEP) { diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index e8701443de..a5ad4c1cbb 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -122,7 +122,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Query() const return MakeResult(GameActions::Status::InvalidParameters); } - if (!byte_9D8150 && (_loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY)) + if (!byte_9D8150 && (_loc.x > GetMapSizeMaxXY() || _loc.y > GetMapSizeMaxXY())) { return std::make_unique(GameActions::Status::InvalidParameters); } diff --git a/src/openrct2/actions/SurfaceSetStyleAction.cpp b/src/openrct2/actions/SurfaceSetStyleAction.cpp index 7847228cd1..47c1a32108 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.cpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.cpp @@ -42,8 +42,8 @@ GameActions::Result::Ptr SurfaceSetStyleAction::Query() const auto normRange = _range.Normalise(); auto x0 = std::max(normRange.GetLeft(), 32); auto y0 = std::max(normRange.GetTop(), 32); - auto x1 = std::min(normRange.GetRight(), static_cast(gMapSizeMaxXY)); - auto y1 = std::min(normRange.GetBottom(), static_cast(gMapSizeMaxXY)); + auto x1 = std::min(normRange.GetRight(), GetMapSizeMaxXY()); + auto y1 = std::min(normRange.GetBottom(), GetMapSizeMaxXY()); MapRange validRange{ x0, y0, x1, y1 }; @@ -160,8 +160,8 @@ GameActions::Result::Ptr SurfaceSetStyleAction::Execute() const auto normRange = _range.Normalise(); auto x0 = std::max(normRange.GetLeft(), 32); auto y0 = std::max(normRange.GetTop(), 32); - auto x1 = std::min(normRange.GetRight(), static_cast(gMapSizeMaxXY)); - auto y1 = std::min(normRange.GetBottom(), static_cast(gMapSizeMaxXY)); + auto x1 = std::min(normRange.GetRight(), GetMapSizeMaxXY()); + auto y1 = std::min(normRange.GetBottom(), GetMapSizeMaxXY()); MapRange validRange{ x0, y0, x1, y1 }; diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index 7adaff2f90..ace33ade23 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -125,7 +125,7 @@ GameActions::Result::Ptr WallPlaceAction::Query() const return std::make_unique(GameActions::Status::NotOwned); } } - else if (!byte_9D8150 && (_loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY)) + else if (!byte_9D8150 && (_loc.x > GetMapSizeMaxXY() || _loc.y > GetMapSizeMaxXY())) { log_error("Invalid x/y coordinates. x = %d y = %d", _loc.x, _loc.y); return std::make_unique(GameActions::Status::InvalidParameters); diff --git a/src/openrct2/actions/WaterLowerAction.cpp b/src/openrct2/actions/WaterLowerAction.cpp index 0403fc2bcc..2bd0e66a66 100644 --- a/src/openrct2/actions/WaterLowerAction.cpp +++ b/src/openrct2/actions/WaterLowerAction.cpp @@ -46,9 +46,9 @@ GameActions::Result::Ptr WaterLowerAction::QueryExecute(bool isExecuting) const // Keep big coordinates within map boundaries auto aX = std::max(32, _range.GetLeft()); - auto bX = std::min(gMapSizeMaxXY, _range.GetRight()); + auto bX = std::min(GetMapSizeMaxXY(), _range.GetRight()); auto aY = std::max(32, _range.GetTop()); - auto bY = std::min(gMapSizeMaxXY, _range.GetBottom()); + auto bY = std::min(GetMapSizeMaxXY(), _range.GetBottom()); MapRange validRange = MapRange{ aX, aY, bX, bY }; diff --git a/src/openrct2/actions/WaterRaiseAction.cpp b/src/openrct2/actions/WaterRaiseAction.cpp index 231ef43027..dbf10f83d6 100644 --- a/src/openrct2/actions/WaterRaiseAction.cpp +++ b/src/openrct2/actions/WaterRaiseAction.cpp @@ -46,9 +46,9 @@ GameActions::Result::Ptr WaterRaiseAction::QueryExecute(bool isExecuting) const // Keep big coordinates within map boundaries auto aX = std::max(32, _range.GetLeft()); - auto bX = std::min(gMapSizeMaxXY, _range.GetRight()); + auto bX = std::min(GetMapSizeMaxXY(), _range.GetRight()); auto aY = std::max(32, _range.GetTop()); - auto bY = std::min(gMapSizeMaxXY, _range.GetBottom()); + auto bY = std::min(GetMapSizeMaxXY(), _range.GetBottom()); MapRange validRange = MapRange{ aX, aY, bX, bY }; diff --git a/src/openrct2/actions/WaterSetHeightAction.cpp b/src/openrct2/actions/WaterSetHeightAction.cpp index 43d41bfe87..bf4eb860c2 100644 --- a/src/openrct2/actions/WaterSetHeightAction.cpp +++ b/src/openrct2/actions/WaterSetHeightAction.cpp @@ -133,7 +133,7 @@ GameActions::Result::Ptr WaterSetHeightAction::Execute() const rct_string_id WaterSetHeightAction::CheckParameters() const { - if (_coords.x > gMapSizeMaxXY || _coords.y > gMapSizeMaxXY) + if (_coords.x > GetMapSizeMaxXY() || _coords.y > GetMapSizeMaxXY()) { return STR_OFF_EDGE_OF_MAP; } diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index fd22cc8cd6..b1aadef8ad 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -105,11 +105,11 @@ struct rct_gx struct rct_drawpixelinfo { uint8_t* bits{}; - int16_t x{}; - int16_t y{}; - int16_t width{}; - int16_t height{}; - int16_t pitch{}; // note: this is actually (pitch - width) + int32_t x{}; + int32_t y{}; + int32_t width{}; + int32_t height{}; + int32_t pitch{}; // note: this is actually (pitch - width) ZoomLevel zoom_level{}; /** diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index b99c5534f8..a15d57a082 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -224,7 +224,7 @@ void viewports_invalidate(int32_t left, int32_t top, int32_t right, int32_t bott */ CoordsXYZ viewport_adjust_for_map_height(const ScreenCoordsXY& startCoords) { - int16_t height = 0; + int32_t height = 0; uint32_t rotation = get_current_rotation(); CoordsXY pos{}; @@ -235,7 +235,7 @@ CoordsXYZ viewport_adjust_for_map_height(const ScreenCoordsXY& startCoords) // HACK: This is to prevent the x and y values being set to values outside // of the map. This can happen when the height is larger than the map size. - int16_t max = gMapSizeMinus2; + auto max = GetMapSizeMinus2(); if (pos.x > max && pos.y > max) { const CoordsXY corr[] = { { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } }; @@ -326,10 +326,10 @@ static void viewport_redraw_after_shift( } else { - int16_t left = viewport->pos.x; - int16_t right = viewport->pos.x + viewport->width; - int16_t top = viewport->pos.y; - int16_t bottom = viewport->pos.y + viewport->height; + auto left = viewport->pos.x; + auto right = viewport->pos.x + viewport->width; + auto top = viewport->pos.y; + auto bottom = viewport->pos.y + viewport->height; // if moved more than the viewport size if (abs(coords.x) < viewport->width && abs(coords.y) < viewport->height) @@ -340,14 +340,14 @@ static void viewport_redraw_after_shift( if (coords.x > 0) { // draw left - int16_t _right = viewport->pos.x + coords.x; + auto _right = viewport->pos.x + coords.x; window_draw_all(dpi, left, top, _right, bottom); left += coords.x; } else if (coords.x < 0) { // draw right - int16_t _left = viewport->pos.x + viewport->width + coords.x; + auto _left = viewport->pos.x + viewport->width + coords.x; window_draw_all(dpi, _left, top, right, bottom); right += coords.x; } @@ -374,7 +374,7 @@ static void viewport_redraw_after_shift( } static void viewport_shift_pixels( - rct_drawpixelinfo* dpi, rct_window* window, rct_viewport* viewport, int16_t x_diff, int16_t y_diff) + rct_drawpixelinfo* dpi, rct_window* window, rct_viewport* viewport, int32_t x_diff, int32_t y_diff) { auto it = window_get_iterator(window); for (; it != g_window_list.end(); it++) @@ -428,8 +428,8 @@ static void viewport_move(const ScreenCoordsXY& coords, rct_window* w, rct_viewp // Note: do not do the subtraction and then divide! // Note: Due to arithmetic shift != /zoom a shift will have to be used // hopefully when 0x006E7FF3 is finished this can be converted to /zoom. - int16_t x_diff = (viewport->viewPos.x / viewport->zoom) - (coords.x / viewport->zoom); - int16_t y_diff = (viewport->viewPos.y / viewport->zoom) - (coords.y / viewport->zoom); + auto x_diff = (viewport->viewPos.x / viewport->zoom) - (coords.x / viewport->zoom); + auto y_diff = (viewport->viewPos.y / viewport->zoom) - (coords.y / viewport->zoom); viewport->viewPos = coords; @@ -577,14 +577,14 @@ void viewport_update_position(rct_window* window) } // Clamp to the map maximum value (scenario specific) - if (mapCoord.x > gMapSizeMinus2) + if (mapCoord.x > GetMapSizeMinus2()) { - mapCoord.x = gMapSizeMinus2; + mapCoord.x = GetMapSizeMinus2(); at_map_edge = 1; } - if (mapCoord.y > gMapSizeMinus2) + if (mapCoord.y > GetMapSizeMinus2()) { - mapCoord.y = gMapSizeMinus2; + mapCoord.y = GetMapSizeMinus2(); at_map_edge = 1; } @@ -921,13 +921,13 @@ static void viewport_paint_column(paint_session* session) * ebp: bottom */ void viewport_paint( - const rct_viewport* viewport, rct_drawpixelinfo* dpi, int16_t left, int16_t top, int16_t right, int16_t bottom, + const rct_viewport* viewport, rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, std::vector* recorded_sessions) { uint32_t viewFlags = viewport->flags; - uint16_t width = right - left; - uint16_t height = bottom - top; - uint16_t bitmask = viewport->zoom >= 0 ? 0xFFFF & (0xFFFF * viewport->zoom) : 0xFFFF; + uint32_t width = right - left; + uint32_t height = bottom - top; + uint32_t bitmask = viewport->zoom >= 0 ? 0xFFFFFFFF & (0xFFFFFFFF * viewport->zoom) : 0xFFFFFFFF; width &= bitmask; height &= bitmask; @@ -936,11 +936,11 @@ void viewport_paint( right = left + width; bottom = top + height; - int16_t x = static_cast(left - static_cast(viewport->viewPos.x & bitmask)); + auto x = left - static_cast(viewport->viewPos.x & bitmask); x = x / viewport->zoom; x += viewport->pos.x; - int16_t y = static_cast(top - static_cast(viewport->viewPos.y & bitmask)); + auto y = top - static_cast(viewport->viewPos.y & bitmask); y = y / viewport->zoom; y += viewport->pos.y; @@ -956,10 +956,10 @@ void viewport_paint( dpi1.remX = std::max(0, dpi->x - x); dpi1.remY = std::max(0, dpi->y - y); - // make sure, the compare operation is done in int16_t to avoid the loop becoming an infiniteloop. + // make sure, the compare operation is done in int32_t to avoid the loop becoming an infiniteloop. // this as well as the [x += 32] in the loop causes signed integer overflow -> undefined behaviour. - const int16_t rightBorder = dpi1.x + dpi1.width; - const int16_t alignedX = floor2(dpi1.x, 32); + auto rightBorder = dpi1.x + dpi1.width; + auto alignedX = floor2(dpi1.x, 32); _paintColumns.clear(); @@ -977,8 +977,8 @@ void viewport_paint( size_t index = 0; if (recorded_sessions != nullptr) { - const uint16_t columnSize = rightBorder - alignedX; - const uint16_t columnCount = (columnSize + 31) / 32; + auto columnSize = rightBorder - alignedX; + auto columnCount = (columnSize + 31) / 32; recorded_sessions->resize(columnCount); } @@ -991,17 +991,17 @@ void viewport_paint( rct_drawpixelinfo& dpi2 = session->DPI; if (x >= dpi2.x) { - int16_t leftPitch = x - dpi2.x; + auto leftPitch = x - dpi2.x; dpi2.width -= leftPitch; dpi2.bits += leftPitch / dpi2.zoom_level; dpi2.pitch += leftPitch / dpi2.zoom_level; dpi2.x = x; } - int16_t paintRight = dpi2.x + dpi2.width; + auto paintRight = dpi2.x + dpi2.width; if (paintRight >= x + 32) { - int16_t rightPitch = paintRight - x - 32; + auto rightPitch = paintRight - x - 32; paintRight -= rightPitch; dpi2.pitch += rightPitch / dpi2.zoom_level; } @@ -1063,8 +1063,8 @@ std::optional screen_pos_to_map_pos(const ScreenCoordsXY& screenCoords } else { - int16_t mod_x = mapCoords->x & 0x1F; - int16_t mod_y = mapCoords->y & 0x1F; + auto mod_x = mapCoords->x & 0x1F; + auto mod_y = mapCoords->y & 0x1F; if (mod_x <= 16) { if (mod_y < 16) @@ -1337,9 +1337,9 @@ static bool is_pixel_present_bmp( /** * rct2: 0x0067933B, 0x00679788, 0x00679C4A, 0x0067A117 */ -static bool is_pixel_present_rle(const uint8_t* esi, int16_t x_start_point, int16_t y_start_point, int32_t round) +static bool is_pixel_present_rle(const uint8_t* esi, int32_t x_start_point, int32_t y_start_point, int32_t round) { - uint16_t start_offset = esi[y_start_point * 2] | (esi[y_start_point * 2 + 1] << 8); + uint32_t start_offset = esi[y_start_point * 2] | (esi[y_start_point * 2 + 1] << 8); const uint8_t* ebx = esi + start_offset; uint8_t last_data_line = 0; @@ -1450,8 +1450,8 @@ static bool is_sprite_interacted_with_palette_set( // TODO: SAR in dpi done with `>> 1`, in coordinates with `/ 2` rct_drawpixelinfo zoomed_dpi = { /* .bits = */ dpi->bits, - /* .x = */ static_cast(dpi->x >> 1), - /* .y = */ static_cast(dpi->y >> 1), + /* .x = */ dpi->x >> 1, + /* .y = */ dpi->y >> 1, /* .height = */ dpi->height, /* .width = */ dpi->width, /* .pitch = */ dpi->pitch, @@ -1472,8 +1472,8 @@ static bool is_sprite_interacted_with_palette_set( } origin.y += g1->y_offset; - int16_t yStartPoint = 0; - int16_t height = g1->height; + int32_t yStartPoint = 0; + int32_t height = g1->height; if (dpi->zoom_level != 0) { if (height % 2) @@ -1498,7 +1498,7 @@ static bool is_sprite_interacted_with_palette_set( } origin.y = floor2(origin.y, round); - int16_t yEndPoint = height; + int32_t yEndPoint = height; origin.y -= dpi->y; if (origin.y < 0) { @@ -1523,8 +1523,8 @@ static bool is_sprite_interacted_with_palette_set( } } - int16_t xStartPoint = 0; - int16_t xEndPoint = g1->width; + int32_t xStartPoint = 0; + int32_t xEndPoint = g1->width; origin.x += g1->x_offset; origin.x = floor2(origin.x, round); @@ -1813,7 +1813,7 @@ std::optional screen_get_map_xy(const ScreenCoordsXY& screenCoords, rc * * rct2: 0x006894D4 */ -std::optional screen_get_map_xy_with_z(const ScreenCoordsXY& screenCoords, int16_t z) +std::optional screen_get_map_xy_with_z(const ScreenCoordsXY& screenCoords, int32_t z) { rct_viewport* viewport = viewport_find_from_point(screenCoords); if (viewport == nullptr) @@ -1849,7 +1849,7 @@ std::optional screen_get_map_xy_quadrant(const ScreenCoordsXY& screenC * * rct2: 0x0068964B */ -std::optional screen_get_map_xy_quadrant_with_z(const ScreenCoordsXY& screenCoords, int16_t z, uint8_t* quadrant) +std::optional screen_get_map_xy_quadrant_with_z(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* quadrant) { auto mapCoords = screen_get_map_xy_with_z(screenCoords, z); if (!mapCoords) @@ -1877,7 +1877,7 @@ std::optional screen_get_map_xy_side(const ScreenCoordsXY& screenCoord * * rct2: 0x006896DC */ -std::optional screen_get_map_xy_side_with_z(const ScreenCoordsXY& screenCoords, int16_t z, uint8_t* side) +std::optional screen_get_map_xy_side_with_z(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* side) { auto mapCoords = screen_get_map_xy_with_z(screenCoords, z); if (!mapCoords) @@ -1910,7 +1910,7 @@ uint8_t get_current_rotation() return rotation_masked; } -int16_t get_height_marker_offset() +int32_t get_height_marker_offset() { // Height labels in units if (gConfigGeneral.show_height_as_units) diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index d62da72b0c..c914255145 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -118,7 +118,7 @@ void viewport_render( rct_drawpixelinfo* dpi, const rct_viewport* viewport, int32_t left, int32_t top, int32_t right, int32_t bottom, std::vector* sessions = nullptr); void viewport_paint( - const rct_viewport* viewport, rct_drawpixelinfo* dpi, int16_t left, int16_t top, int16_t right, int16_t bottom, + const rct_viewport* viewport, rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom, std::vector* sessions = nullptr); CoordsXYZ viewport_adjust_for_map_height(const ScreenCoordsXY& startCoords); @@ -151,14 +151,14 @@ void sub_68B2B7(paint_session* session, const CoordsXY& mapCoords); void viewport_invalidate(const rct_viewport* viewport, int32_t left, int32_t top, int32_t right, int32_t bottom); std::optional screen_get_map_xy(const ScreenCoordsXY& screenCoords, rct_viewport** viewport); -std::optional screen_get_map_xy_with_z(const ScreenCoordsXY& screenCoords, int16_t z); +std::optional screen_get_map_xy_with_z(const ScreenCoordsXY& screenCoords, int32_t z); std::optional screen_get_map_xy_quadrant(const ScreenCoordsXY& screenCoords, uint8_t* quadrant); -std::optional screen_get_map_xy_quadrant_with_z(const ScreenCoordsXY& screenCoords, int16_t z, uint8_t* quadrant); +std::optional screen_get_map_xy_quadrant_with_z(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* quadrant); std::optional screen_get_map_xy_side(const ScreenCoordsXY& screenCoords, uint8_t* side); -std::optional screen_get_map_xy_side_with_z(const ScreenCoordsXY& screenCoords, int16_t z, uint8_t* side); +std::optional screen_get_map_xy_side_with_z(const ScreenCoordsXY& screenCoords, int32_t z, uint8_t* side); uint8_t get_current_rotation(); -int16_t get_height_marker_offset(); +int32_t get_height_marker_offset(); void viewport_set_saved_view(); diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index ff3854a11a..5e6413de44 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -733,7 +733,7 @@ void window_push_others_right(rct_window* window) w->Invalidate(); if (window->windowPos.x + window->width + 13 >= context_get_width()) return; - uint16_t push_amount = window->windowPos.x + window->width - w->windowPos.x + 3; + auto push_amount = window->windowPos.x + window->width - w->windowPos.x + 3; w->windowPos.x += push_amount; w->Invalidate(); if (w->viewport != nullptr) @@ -835,15 +835,15 @@ void window_scroll_to_location(rct_window* w, const CoordsXYZ& coords) bool found = false; while (!found) { - int16_t x2 = w->viewport->pos.x + static_cast(w->viewport->width * window_scroll_locations[i][0]); - int16_t y2 = w->viewport->pos.y + static_cast(w->viewport->height * window_scroll_locations[i][1]); + auto x2 = w->viewport->pos.x + static_cast(w->viewport->width * window_scroll_locations[i][0]); + auto y2 = w->viewport->pos.y + static_cast(w->viewport->height * window_scroll_locations[i][1]); auto it = window_get_iterator(w); for (; it != g_window_list.end(); it++) { auto w2 = (*it).get(); - int16_t x1 = w2->windowPos.x - 10; - int16_t y1 = w2->windowPos.y - 10; + auto x1 = w2->windowPos.x - 10; + auto y1 = w2->windowPos.y - 10; if (x2 >= x1 && x2 <= w2->width + x1 + 20) { if (y2 >= y1 && y2 <= w2->height + y1 + 20) @@ -872,8 +872,8 @@ void window_scroll_to_location(rct_window* w, const CoordsXYZ& coords) if (!(w->flags & WF_NO_SCROLLING)) { w->savedViewPos = screenCoords - - ScreenCoordsXY{ static_cast(w->viewport->view_width * window_scroll_locations[i][0]), - static_cast(w->viewport->view_height * window_scroll_locations[i][1]) }; + - ScreenCoordsXY{ static_cast(w->viewport->view_width * window_scroll_locations[i][0]), + static_cast(w->viewport->view_height * window_scroll_locations[i][1]) }; w->flags |= WF_SCROLLING_TO_LOCATION; } } @@ -941,7 +941,7 @@ void window_rotate_camera(rct_window* w, int32_t direction) } void window_viewport_get_map_coords_by_cursor( - rct_window* w, int16_t* map_x, int16_t* map_y, int16_t* offset_x, int16_t* offset_y) + rct_window* w, int32_t* map_x, int32_t* map_y, int32_t* offset_x, int32_t* offset_y) { // Get mouse position to offset against. auto mouseCoords = context_get_cursor_position_scaled(); @@ -972,7 +972,7 @@ void window_viewport_get_map_coords_by_cursor( *offset_y = (w->savedViewPos.y - (centreLoc->y + rebased_y)) * w->viewport->zoom; } -void window_viewport_centre_tile_around_cursor(rct_window* w, int16_t map_x, int16_t map_y, int16_t offset_x, int16_t offset_y) +void window_viewport_centre_tile_around_cursor(rct_window* w, int32_t map_x, int32_t map_y, int32_t offset_x, int32_t offset_y) { // Get viewport coordinates centring around the tile. int32_t z = tile_element_height({ map_x, map_y }); @@ -1020,10 +1020,10 @@ void window_zoom_set(rct_window* w, ZoomLevel zoomLevel, bool atCursor) return; // Zooming to cursor? Remember where we're pointing at the moment. - int16_t saved_map_x = 0; - int16_t saved_map_y = 0; - int16_t offset_x = 0; - int16_t offset_y = 0; + int32_t saved_map_x = 0; + int32_t saved_map_y = 0; + int32_t offset_x = 0; + int32_t offset_y = 0; if (gConfigGeneral.zoom_to_cursor && atCursor) { window_viewport_get_map_coords_by_cursor(w, &saved_map_x, &saved_map_y, &offset_x, &offset_y); @@ -1282,8 +1282,8 @@ void window_resize(rct_window* w, int32_t dw, int32_t dh) w->Invalidate(); // Clamp new size to minimum and maximum - w->width = std::clamp(w->width + dw, w->min_width, w->max_width); - w->height = std::clamp(w->height + dh, w->min_height, w->max_height); + w->width = std::clamp(w->width + dw, w->min_width, w->max_width); + w->height = std::clamp(w->height + dh, w->min_height, w->max_height); window_event_resize_call(w); window_event_invalidate_call(w); @@ -2091,7 +2091,7 @@ bool window_is_visible(rct_window* w) * right (dx) * bottom (bp) */ -void window_draw_all(rct_drawpixelinfo* dpi, int16_t left, int16_t top, int16_t right, int16_t bottom) +void window_draw_all(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom) { auto windowDPI = dpi->Crop({ left, top }, { right - left, bottom - top }); window_visit_each([&windowDPI, left, top, right, bottom](rct_window* w) { diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 08038d3884..d84bea4ae4 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -146,12 +146,12 @@ struct rct_widget */ struct rct_viewport { - int16_t width; - int16_t height; + int32_t width; + int32_t height; ScreenCoordsXY pos; ScreenCoordsXY viewPos; - int16_t view_width; - int16_t view_height; + int32_t view_width; + int32_t view_height; uint32_t flags; ZoomLevel zoom; uint8_t var_11; @@ -764,8 +764,8 @@ rct_window* window_get_main(); void window_scroll_to_location(rct_window* w, const CoordsXYZ& coords); void window_rotate_camera(rct_window* w, int32_t direction); void window_viewport_get_map_coords_by_cursor( - rct_window* w, int16_t* map_x, int16_t* map_y, int16_t* offset_x, int16_t* offset_y); -void window_viewport_centre_tile_around_cursor(rct_window* w, int16_t map_x, int16_t map_y, int16_t offset_x, int16_t offset_y); + rct_window* w, int32_t* map_x, int32_t* map_y, int32_t* offset_x, int32_t* offset_y); +void window_viewport_centre_tile_around_cursor(rct_window* w, int32_t map_x, int32_t map_y, int32_t offset_x, int32_t offset_y); void window_check_all_valid_zoom(); void window_zoom_set(rct_window* w, ZoomLevel zoomLevel, bool atCursor); void window_zoom_in(rct_window* w, bool atCursor); @@ -774,7 +774,7 @@ void main_window_zoom(bool zoomIn, bool atCursor); void window_show_textinput(rct_window* w, rct_widgetindex widgetIndex, uint16_t title, uint16_t text, int32_t value); -void window_draw_all(rct_drawpixelinfo* dpi, int16_t left, int16_t top, int16_t right, int16_t bottom); +void window_draw_all(rct_drawpixelinfo* dpi, int32_t left, int32_t top, int32_t right, int32_t bottom); void window_draw(rct_drawpixelinfo* dpi, rct_window* w, int32_t left, int32_t top, int32_t right, int32_t bottom); void WindowDrawWidgets(rct_window* w, rct_drawpixelinfo* dpi); void window_draw_viewport(rct_drawpixelinfo* dpi, rct_window* w); diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 9129d226cd..6685743190 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -1,4 +1,4 @@ -/***************************************************************************** +/***************************************************************************** * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md @@ -52,13 +52,13 @@ bool gPaintBoundingBoxes; bool gPaintBlockedTiles; static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t viewFlags); -static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int16_t x, int16_t y); -static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int16_t x, int16_t y); +static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int32_t x, int32_t y); +static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int32_t x, int32_t y); static uint32_t PaintPSColourifyImage(uint32_t imageId, ViewportInteractionItem spriteType, uint32_t viewFlags); static constexpr int32_t CalculatePositionHash(const paint_struct& ps, uint8_t rotation) { - auto pos = CoordsXY{ static_cast(ps.bounds.x), static_cast(ps.bounds.y) }.Rotate(rotation); + auto pos = CoordsXY{ ps.bounds.x, ps.bounds.y }.Rotate(rotation); switch (rotation) { case 0: @@ -187,8 +187,7 @@ static paint_struct* CreateNormalPaintStruct( template void PaintSessionGenerateRotate(paint_session* session) { // Optimised modified version of viewport_coord_to_map_coord - ScreenCoordsXY screenCoord = { static_cast((session->DPI.x) & 0xFFE0), - static_cast((session->DPI.y - 16) & 0xFFE0) }; + ScreenCoordsXY screenCoord = { floor2(session->DPI.x, 32), floor2((session->DPI.y - 16), 32) }; CoordsXY mapTile = { screenCoord.y - screenCoord.x / 2, screenCoord.y + screenCoord.x / 2 }; mapTile = mapTile.Rotate(direction); @@ -443,8 +442,8 @@ static void PaintDrawStruct(paint_session* session, paint_struct* ps) { rct_drawpixelinfo* dpi = &session->DPI; - int16_t x = ps->x; - int16_t y = ps->y; + auto x = ps->x; + auto y = ps->y; if (ps->sprite_type == ViewportInteractionItem::Entity) { @@ -520,7 +519,7 @@ static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t v } } -static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int16_t x, int16_t y) +static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int32_t x, int32_t y) { const uint8_t colour = BoundBoxDebugColours[EnumValue(ps->sprite_type)]; const uint8_t rotation = get_current_rotation(); @@ -606,7 +605,7 @@ static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* gfx_draw_line(dpi, { screenCoordFrontTop, screenCoordRightTop }, colour); } -static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int16_t x, int16_t y) +static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t imageId, int32_t x, int32_t y) { if (ps->flags & PAINT_STRUCT_FLAG_IS_MASKED) { @@ -698,8 +697,8 @@ paint_struct* PaintAddImageAsParent( } paint_struct* PaintAddImageAsParent( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset) + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset) { return PaintAddImageAsParent( session, image_id, { x_offset, y_offset, z_offset }, { bound_box_length_x, bound_box_length_y, bound_box_length_z }); @@ -722,9 +721,9 @@ paint_struct* PaintAddImageAsParent( */ // Track Pieces, Shops. paint_struct* PaintAddImageAsParent( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z) + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z) { session->LastPS = nullptr; session->LastAttachedPS = nullptr; @@ -762,12 +761,12 @@ paint_struct* PaintAddImageAsParent( * Creates a paint struct but does not allocate to a paint quadrant. Result cannot be ignored! */ [[nodiscard]] paint_struct* PaintAddImageAsOrphan( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z) + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z) { - assert(static_cast(bound_box_length_x) == static_cast(bound_box_length_x)); - assert(static_cast(bound_box_length_y) == static_cast(bound_box_length_y)); + assert(bound_box_length_x > 0); + assert(bound_box_length_y > 0); session->LastPS = nullptr; session->LastAttachedPS = nullptr; @@ -826,12 +825,12 @@ paint_struct* PaintAddImageAsChild( } paint_struct* PaintAddImageAsChild( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z) + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z) { - assert(static_cast(bound_box_length_x) == static_cast(bound_box_length_x)); - assert(static_cast(bound_box_length_y) == static_cast(bound_box_length_y)); + assert(bound_box_length_x > 0); + assert(bound_box_length_y > 0); return PaintAddImageAsChild( session, image_id, { x_offset, y_offset, z_offset }, { bound_box_length_x, bound_box_length_y, bound_box_length_z }, { bound_box_offset_x, bound_box_offset_y, bound_box_offset_z }); @@ -845,7 +844,7 @@ paint_struct* PaintAddImageAsChild( * @param y (cx) * @return (!CF) success */ -bool PaintAttachToPreviousAttach(paint_session* session, uint32_t image_id, int16_t x, int16_t y) +bool PaintAttachToPreviousAttach(paint_session* session, uint32_t image_id, int32_t x, int32_t y) { if (session->NoPaintStructsAvailable()) { @@ -878,7 +877,7 @@ bool PaintAttachToPreviousAttach(paint_session* session, uint32_t image_id, int1 * @param y (cx) * @return (!CF) success */ -bool PaintAttachToPreviousPS(paint_session* session, uint32_t image_id, int16_t x, int16_t y) +bool PaintAttachToPreviousPS(paint_session* session, uint32_t image_id, int32_t x, int32_t y) { if (session->NoPaintStructsAvailable()) { @@ -915,7 +914,7 @@ bool PaintAttachToPreviousPS(paint_session* session, uint32_t image_id, int16_t * @param rotation (ebp) */ void PaintFloatingMoneyEffect( - paint_session* session, money64 amount, rct_string_id string_id, int16_t y, int16_t z, int8_t y_offsets[], int16_t offset_x, + paint_session* session, money64 amount, rct_string_id string_id, int32_t y, int32_t z, int8_t y_offsets[], int32_t offset_x, uint32_t rotation) { if (session->NoPaintStructsAvailable()) diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 45eb21f98c..75b4e52168 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -19,21 +19,20 @@ struct TileElement; enum class ViewportInteractionItem : uint8_t; #pragma pack(push, 1) -/* size 0x12 */ struct attached_paint_struct { - uint32_t image_id; // 0x00 + uint32_t image_id; union { uint32_t tertiary_colour; // If masked image_id is masked_id uint32_t colour_image_id; }; - int16_t x; // 0x08 - int16_t y; // 0x0A - uint8_t flags; // 0x0C + int32_t x; + int32_t y; + uint8_t flags; uint8_t pad_0D; - attached_paint_struct* next; // 0x0E + attached_paint_struct* next; }; #ifdef PLATFORM_32BIT // TODO: drop packing from this when all rendering is done. @@ -57,31 +56,30 @@ struct paint_struct_bound_box uint16_t z_end; }; -/* size 0x34 */ struct paint_struct { - uint32_t image_id; // 0x00 + uint32_t image_id; union { - uint32_t tertiary_colour; // 0x04 + uint32_t tertiary_colour; // If masked image_id is masked_id - uint32_t colour_image_id; // 0x04 + uint32_t colour_image_id; }; - paint_struct_bound_box bounds; // 0x08 - int16_t x; // 0x14 - int16_t y; // 0x16 + paint_struct_bound_box bounds; + int32_t x; + int32_t y; uint16_t quadrant_index; uint8_t flags; uint8_t quadrant_flags; - attached_paint_struct* attached_ps; // 0x1C + attached_paint_struct* attached_ps; paint_struct* children; - paint_struct* next_quadrant_ps; // 0x24 - ViewportInteractionItem sprite_type; // 0x28 + paint_struct* next_quadrant_ps; + ViewportInteractionItem sprite_type; uint8_t var_29; uint16_t pad_2A; - uint16_t map_x; // 0x2C - uint16_t map_y; // 0x2E - TileElement* tileElement; // 0x30 (or sprite pointer) + int32_t map_x; + int32_t map_y; + TileElement* tileElement; }; #ifdef PLATFORM_32BIT // TODO: drop packing from this when all rendering is done. @@ -217,44 +215,44 @@ extern bool gPaintBlockedTiles; extern bool gPaintWidePathsAsGhost; paint_struct* PaintAddImageAsParent( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset); + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset); paint_struct* PaintAddImageAsParent( paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize); paint_struct* PaintAddImageAsParent( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z); + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z); [[nodiscard]] paint_struct* PaintAddImageAsOrphan( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z); + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z); paint_struct* PaintAddImageAsChild( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z); + paint_session* session, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z); paint_struct* PaintAddImageAsChild( paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength, const CoordsXYZ& boundBoxOffset); paint_struct* PaintAddImageAsParentRotated( - paint_session* session, uint8_t direction, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset); + paint_session* session, uint8_t direction, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset); paint_struct* PaintAddImageAsParentRotated( - paint_session* session, uint8_t direction, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z); + paint_session* session, uint8_t direction, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z); paint_struct* PaintAddImageAsChildRotated( - paint_session* session, uint8_t direction, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z); + paint_session* session, uint8_t direction, uint32_t image_id, int32_t x_offset, int32_t y_offset, int32_t bound_box_length_x, + int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, int32_t bound_box_offset_x, + int32_t bound_box_offset_y, int32_t bound_box_offset_z); void paint_util_push_tunnel_rotated(paint_session* session, uint8_t direction, uint16_t height, uint8_t type); -bool PaintAttachToPreviousAttach(paint_session* session, uint32_t image_id, int16_t x, int16_t y); -bool PaintAttachToPreviousPS(paint_session* session, uint32_t image_id, int16_t x, int16_t y); +bool PaintAttachToPreviousAttach(paint_session* session, uint32_t image_id, int32_t x, int32_t y); +bool PaintAttachToPreviousPS(paint_session* session, uint32_t image_id, int32_t x, int32_t y); void PaintFloatingMoneyEffect( - paint_session* session, money64 amount, rct_string_id string_id, int16_t y, int16_t z, int8_t y_offsets[], int16_t offset_x, + paint_session* session, money64 amount, rct_string_id string_id, int32_t y, int32_t z, int8_t y_offsets[], int32_t offset_x, uint32_t rotation); paint_session* PaintSessionAlloc(rct_drawpixelinfo* dpi, uint32_t viewFlags); diff --git a/src/openrct2/paint/PaintHelpers.cpp b/src/openrct2/paint/PaintHelpers.cpp index e50c12f97e..bc934fc77e 100644 --- a/src/openrct2/paint/PaintHelpers.cpp +++ b/src/openrct2/paint/PaintHelpers.cpp @@ -12,8 +12,8 @@ #include "Paint.h" paint_struct* PaintAddImageAsParentRotated( - paint_session* session, uint8_t direction, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset) + paint_session* session, uint8_t direction, uint32_t image_id, int32_t x_offset, int32_t y_offset, + int32_t bound_box_length_x, int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset) { if (direction & 1) { @@ -30,9 +30,9 @@ paint_struct* PaintAddImageAsParentRotated( } paint_struct* PaintAddImageAsParentRotated( - paint_session* session, uint8_t direction, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z) + paint_session* session, uint8_t direction, uint32_t image_id, int32_t x_offset, int32_t y_offset, + int32_t bound_box_length_x, int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, + int32_t bound_box_offset_x, int32_t bound_box_offset_y, int32_t bound_box_offset_z) { if (direction & 1) { @@ -49,9 +49,9 @@ paint_struct* PaintAddImageAsParentRotated( } paint_struct* PaintAddImageAsChildRotated( - paint_session* session, uint8_t direction, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z) + paint_session* session, uint8_t direction, uint32_t image_id, int32_t x_offset, int32_t y_offset, + int32_t bound_box_length_x, int32_t bound_box_length_y, int32_t bound_box_length_z, int32_t z_offset, + int32_t bound_box_offset_x, int32_t bound_box_offset_y, int32_t bound_box_offset_z) { if (direction & 1) { diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index a9c77d1e11..3f4eb58852 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -48,7 +48,7 @@ const int32_t SEGMENTS_ALL = SEGMENT_B4 | SEGMENT_B8 | SEGMENT_BC | SEGMENT_C0 | */ void tile_element_paint_setup(paint_session* session, int32_t x, int32_t y) { - if (x < gMapSizeUnits && y < gMapSizeUnits && x >= 32 && y >= 32) + if (x < GetMapSizeUnits() && y < GetMapSizeUnits() && x >= 32 && y >= 32) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_force_set_general_support_height(session, -1, 0); @@ -69,7 +69,7 @@ void tile_element_paint_setup(paint_session* session, int32_t x, int32_t y) */ void sub_68B2B7(paint_session* session, const CoordsXY& mapCoords) { - if (mapCoords.x < gMapSizeUnits && mapCoords.y < gMapSizeUnits && mapCoords.x >= 32 && mapCoords.y >= 32) + if (mapCoords.x < GetMapSizeUnits() && mapCoords.y < GetMapSizeUnits() && mapCoords.x >= 32 && mapCoords.y >= 32) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_force_set_general_support_height(session, -1, 0); diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 8015ca0ba7..b141ccf33b 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -344,10 +344,7 @@ public: gCash = DECRYPT_MONEY(_s6.cash); // pad_013587FC gParkRatingCasualtyPenalty = _s6.park_rating_casualty_penalty; - gMapSizeUnits = _s6.map_size_units; - gMapSizeMinus2 = _s6.map_size_minus_2; gMapSize = _s6.map_size; - gMapSizeMaxXY = _s6.map_max_xy; gSamePriceThroughoutPark = _s6.same_price_throughout | (static_cast(_s6.same_price_throughout_extended) << 32); _suggestedGuestMaximum = _s6.suggested_max_guests; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index e8f345ef39..4cd075e076 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -66,17 +66,6 @@ using namespace OpenRCT2; using namespace OpenRCT2::Drawing; -struct map_backup -{ - TileElement tile_elements[MAX_TILE_ELEMENTS]; - TileElement* tile_pointers[MAX_TILE_TILE_ELEMENT_POINTERS]; - TileElement* next_free_tile_element; - uint16_t map_size_units; - uint16_t map_size_units_minus_2; - uint16_t map_size; - uint8_t current_rotation; -}; - TrackDesign* gActiveTrackDesign; bool gTrackDesignSceneryToggle; static CoordsXYZ _trackPreviewMin; @@ -2088,8 +2077,6 @@ static void track_design_preview_clear_map() { auto numTiles = MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL; - gMapSizeUnits = 255 * COORDS_XY_STEP; - gMapSizeMinus2 = (264 * 32) - 2; gMapSize = 256; // Reserve ~8 elements per tile diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 8597cca5bf..ecd164fb1c 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -95,11 +95,8 @@ uint8_t gMapGroundFlags; TileCoordsXY gWidePathTileLoopPosition; uint16_t gGrassSceneryTileLoopPosition; -int16_t gMapSizeUnits; -int16_t gMapSizeMinus2; -int16_t gMapSize; -int16_t gMapSizeMaxXY; -int16_t gMapBaseZ; +int32_t gMapSize; +int32_t gMapBaseZ; std::vector gMapSelectionTiles; std::vector gPeepSpawns; @@ -110,8 +107,8 @@ bool gClearSmallScenery; bool gClearLargeScenery; bool gClearFootpath; -uint16_t gLandRemainingOwnershipSales; -uint16_t gLandRemainingConstructionSales; +uint32_t gLandRemainingOwnershipSales; +uint32_t gLandRemainingConstructionSales; bool gMapLandRightsUpdateSuccess; @@ -119,8 +116,6 @@ static TilePointerIndex _tileIndex; static std::vector _tileElements; static TilePointerIndex _tileIndexStash; static std::vector _tileElementsStash; -static int32_t _mapSizeUnitsStash; -static int32_t _mapSizeMinus2Stash; static int32_t _mapSizeStash; static int32_t _currentRotationStash; @@ -128,8 +123,6 @@ void StashMap() { _tileIndexStash = std::move(_tileIndex); _tileElementsStash = std::move(_tileElements); - _mapSizeUnitsStash = gMapSizeUnits; - _mapSizeMinus2Stash = gMapSizeMinus2; _mapSizeStash = gMapSize; _currentRotationStash = gCurrentRotation; } @@ -138,8 +131,6 @@ void UnstashMap() { _tileIndex = std::move(_tileIndexStash); _tileElements = std::move(_tileElementsStash); - gMapSizeUnits = _mapSizeUnitsStash; - gMapSizeMinus2 = _mapSizeMinus2Stash; gMapSize = _mapSizeStash; gCurrentRotation = _currentRotationStash; } @@ -381,10 +372,7 @@ void map_init(int32_t size) gGrassSceneryTileLoopPosition = 0; gWidePathTileLoopPosition = {}; - gMapSizeUnits = size * 32 - 32; - gMapSizeMinus2 = size * 32 - 2; gMapSize = size; - gMapSizeMaxXY = size * 32 - 33; gMapBaseZ = 7; map_remove_out_of_range_elements(); AutoCreateMapAnimations(); @@ -730,7 +718,7 @@ bool map_is_location_valid(const CoordsXY& coords) bool map_is_edge(const CoordsXY& coords) { - return (coords.x < 32 || coords.y < 32 || coords.x >= gMapSizeUnits || coords.y >= gMapSizeUnits); + return (coords.x < 32 || coords.y < 32 || coords.x >= GetMapSizeUnits() || coords.y >= GetMapSizeUnits()); } bool map_can_build_at(const CoordsXYZ& loc) @@ -916,8 +904,8 @@ int32_t tile_element_get_corner_height(const SurfaceElement* surfaceElement, int uint8_t map_get_lowest_land_height(const MapRange& range) { MapRange validRange = { std::max(range.GetLeft(), 32), std::max(range.GetTop(), 32), - std::min(range.GetRight(), static_cast(gMapSizeMaxXY)), - std::min(range.GetBottom(), static_cast(gMapSizeMaxXY)) }; + std::min(range.GetRight(), GetMapSizeMaxXY()), + std::min(range.GetBottom(), GetMapSizeMaxXY()) }; uint8_t min_height = 0xFF; for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += COORDS_XY_STEP) @@ -946,8 +934,8 @@ uint8_t map_get_lowest_land_height(const MapRange& range) uint8_t map_get_highest_land_height(const MapRange& range) { MapRange validRange = { std::max(range.GetLeft(), 32), std::max(range.GetTop(), 32), - std::min(range.GetRight(), static_cast(gMapSizeMaxXY)), - std::min(range.GetBottom(), static_cast(gMapSizeMaxXY)) }; + std::min(range.GetRight(), GetMapSizeMaxXY()), + std::min(range.GetBottom(), GetMapSizeMaxXY()) }; uint8_t max_height = 0; for (int32_t yi = validRange.GetTop(); yi <= validRange.GetBottom(); yi += COORDS_XY_STEP) @@ -1296,7 +1284,7 @@ std::unique_ptr MapCanConstructWithClearAt( res->GroundFlags = ELEMENT_IS_ABOVE_GROUND; bool canBuildCrossing = false; - if (pos.x >= gMapSizeUnits || pos.y >= gMapSizeUnits || pos.x < 32 || pos.y < 32) + if (pos.x >= GetMapSizeUnits() || pos.y >= GetMapSizeUnits() || pos.x < 32 || pos.y < 32) { res->Error = GameActions::Status::InvalidParameters; res->ErrorMessage = STR_OFF_EDGE_OF_MAP; @@ -1590,7 +1578,7 @@ void map_restore_provisional_elements() */ void map_remove_out_of_range_elements() { - int32_t mapMaxXY = gMapSizeMaxXY; + int32_t mapMaxXY = GetMapSizeMaxXY(); // Ensure that we can remove elements // diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index b9c95380e7..c2fb176c1d 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -23,7 +23,7 @@ #define MAXIMUM_WATER_HEIGHT 58 #define MINIMUM_MAP_SIZE_TECHNICAL 15 -#define MAXIMUM_MAP_SIZE_TECHNICAL 256 +#define MAXIMUM_MAP_SIZE_TECHNICAL 1001 #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; @@ -33,7 +33,7 @@ constexpr const int32_t MINIMUM_LAND_HEIGHT_BIG = MINIMUM_LAND_HEIGHT * COORDS_Z #define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL) -constexpr const uint32_t MAX_TILE_ELEMENTS_WITH_SPARE_ROOM = 0x100000; +constexpr const uint32_t MAX_TILE_ELEMENTS_WITH_SPARE_ROOM = 0x1000000; constexpr const 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_PEEP_SPAWNS 2 @@ -101,11 +101,12 @@ extern const TileCoordsXY TileDirectionDelta[]; extern TileCoordsXY gWidePathTileLoopPosition; extern uint16_t gGrassSceneryTileLoopPosition; -extern int16_t gMapSizeUnits; -extern int16_t gMapSizeMinus2; -extern int16_t gMapSize; -extern int16_t gMapSizeMaxXY; -extern int16_t gMapBaseZ; +extern int32_t gMapSize; +extern int32_t gMapBaseZ; + +inline int32_t GetMapSizeUnits() { return (gMapSize - 1) * COORDS_XY_STEP; } +inline int32_t GetMapSizeMinus2() { return (gMapSize * COORDS_XY_STEP) + MAXIMUM_MAP_SIZE_PRACTICAL; } +inline int32_t GetMapSizeMaxXY() { return GetMapSizeUnits() - 1; } extern uint16_t gMapSelectFlags; extern uint16_t gMapSelectType; @@ -128,8 +129,8 @@ extern bool gClearSmallScenery; extern bool gClearLargeScenery; extern bool gClearFootpath; -extern uint16_t gLandRemainingOwnershipSales; -extern uint16_t gLandRemainingConstructionSales; +extern uint32_t gLandRemainingOwnershipSales; +extern uint32_t gLandRemainingConstructionSales; extern bool gMapLandRightsUpdateSuccess; diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index 554177b0a7..d5c2d22557 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -33,7 +33,6 @@ rct_sprite* sprite_list = RCT2_ADDRESS(0x010E63BC, rct_sprite); bool gCheatsEnableAllDrawableTrackPieces = false; Ride gRideList[MAX_RIDES]; -int16_t gMapSizeUnits; int16_t gMapBaseZ; bool gTrackDesignSaveMode = false; ride_id_t gTrackDesignSaveRideIndex = RIDE_ID_NULL; @@ -212,7 +211,7 @@ TileElement* map_get_first_element_at(const CoordsXY& elementPos) return gTileElementTilePointers[tileElementPos.x + tileElementPos.y * 256]; } -int16_t get_height_marker_offset() +int32_t get_height_marker_offset() { return 0; }