diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 28a36c1ec9..f912fd3770 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -502,7 +502,7 @@ namespace OpenRCT2 viewport_init_all(); _gameState = std::make_unique(); - _gameState->InitAll({ 150, 150 }); + _gameState->InitAll(DEFAULT_MAP_SIZE); _titleScreen = std::make_unique(*_gameState); _uiContext->Initialise(); diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 31bf94c957..973c024c9d 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -206,7 +206,8 @@ namespace Editor */ static void SetAllLandOwned() { - MapRange range = { 64, 64, (gMapSize.x - 3) * 32, (gMapSize.y - 3) * 32 }; + MapRange range = { 2 * COORDS_XY_STEP, 2 * COORDS_XY_STEP, (gMapSize.x - 3) * COORDS_XY_STEP, + (gMapSize.y - 3) * COORDS_XY_STEP }; auto landSetRightsAction = LandSetRightsAction(range, LandSetRightSetting::SetForSale); landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND); GameActions::Execute(&landSetRightsAction); diff --git a/src/openrct2/actions/ChangeMapSizeAction.cpp b/src/openrct2/actions/ChangeMapSizeAction.cpp index 44b490e21e..67aa9cd0c9 100644 --- a/src/openrct2/actions/ChangeMapSizeAction.cpp +++ b/src/openrct2/actions/ChangeMapSizeAction.cpp @@ -15,7 +15,7 @@ #include "../ui/WindowManager.h" #include "../windows/Intent.h" -ChangeMapSizeAction::ChangeMapSizeAction(const TileCoordsXY targetSize) +ChangeMapSizeAction::ChangeMapSizeAction(const TileCoordsXY& targetSize) : _targetSize(targetSize) { } @@ -37,7 +37,7 @@ GameActions::Result ChangeMapSizeAction::Query() const { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_NONE); } - if (_targetSize.x < 16 || _targetSize.y < 16) + if (_targetSize.x < MINIMUM_MAP_SIZE_TECHNICAL || _targetSize.y < MINIMUM_MAP_SIZE_TECHNICAL) { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_NONE); } diff --git a/src/openrct2/actions/ChangeMapSizeAction.h b/src/openrct2/actions/ChangeMapSizeAction.h index 332dd4cec6..0ef780a4dc 100644 --- a/src/openrct2/actions/ChangeMapSizeAction.h +++ b/src/openrct2/actions/ChangeMapSizeAction.h @@ -16,7 +16,7 @@ class ChangeMapSizeAction final : public GameActionBase= mapSizeUnits.x || _loc.y >= mapSizeUnits.y) + auto mapSizeUnits = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }; + if (!LocationValid(_loc) || _loc.x <= COORDS_XY_STEP || _loc.y <= COORDS_XY_STEP || _loc.x >= mapSizeUnits.x + || _loc.y >= mapSizeUnits.y) { return GameActions::Result( GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP); diff --git a/src/openrct2/actions/SetCheatAction.cpp b/src/openrct2/actions/SetCheatAction.cpp index d271c4c692..8719fb552c 100644 --- a/src/openrct2/actions/SetCheatAction.cpp +++ b/src/openrct2/actions/SetCheatAction.cpp @@ -683,8 +683,8 @@ void SetCheatAction::SetStaffSpeed(uint8_t value) const void SetCheatAction::OwnAllLand() const { - const auto min = CoordsXY{ 32, 32 }; - const auto max = GetMapSizeUnits() - CoordsXY{ 32, 32 }; + const auto min = CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }; + const auto max = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP }; for (CoordsXY coords = min; coords.y <= max.y; coords.y += COORDS_XY_STEP) { diff --git a/src/openrct2/cmdline/BenchSpriteSort.cpp b/src/openrct2/cmdline/BenchSpriteSort.cpp index 48d57cb4af..1c8704f292 100644 --- a/src/openrct2/cmdline/BenchSpriteSort.cpp +++ b/src/openrct2/cmdline/BenchSpriteSort.cpp @@ -87,8 +87,8 @@ static std::vector extract_paint_session(std::string_view gIntroState = IntroState::None; gScreenFlags = SCREEN_FLAGS_PLAYING; - int32_t resolutionWidth = (gMapSize.x * 32 * 2); - int32_t resolutionHeight = (gMapSize.y * 32 * 1); + int32_t resolutionWidth = (gMapSize.x * COORDS_XY_STEP * 2); + int32_t resolutionHeight = (gMapSize.y * COORDS_XY_STEP * 1); resolutionWidth += 8; resolutionHeight += 128; @@ -102,15 +102,11 @@ static std::vector extract_paint_session(std::string_view viewport.var_11 = 0; viewport.flags = 0; - int32_t customX = (gMapSize.x / 2) * 32 + 16; - int32_t customY = (gMapSize.y / 2) * 32 + 16; + auto customXY = TileCoordsXY(gMapSize.x / 2, gMapSize.y / 2).ToCoordsXY().ToTileCentre(); + auto customXYZ = CoordsXYZ(customXY, tile_element_height(customXY)); + auto screenXY = translate_3d_to_2d_with_z(0, customXYZ); - int32_t x = 0, y = 0; - int32_t z = tile_element_height({ customX, customY }); - x = customY - customX; - y = ((customX + customY) / 2) - z; - - viewport.viewPos = { x - ((viewport.view_width) / 2), y - ((viewport.view_height) / 2) }; + viewport.viewPos = { screenXY.x - (viewport.view_width / 2), screenXY.y - (viewport.view_height / 2) }; viewport.zoom = ZoomLevel{ 0 }; gCurrentRotation = 0; diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index a303b05cc0..1bcf1b2422 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -217,8 +217,8 @@ enum class EdgeType static CoordsXY GetEdgeTile(TileCoordsXY mapSize, int32_t rotation, EdgeType edgeType, bool visible) { // TODO - int32_t lower = (visible ? 1 : 0) * 32; - int32_t upper = (visible ? mapSize.x - 2 : mapSize.x - 1) * 32; + int32_t lower = (visible ? 1 : 0) * COORDS_XY_STEP; + int32_t upper = (visible ? mapSize.x - 2 : mapSize.x - 1) * COORDS_XY_STEP; switch (edgeType) { default: @@ -688,8 +688,8 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption const auto& mapSize = gMapSize; if (resolutionWidth == 0 || resolutionHeight == 0) { - resolutionWidth = (mapSize.x * 32 * 2) >> customZoom; - resolutionHeight = (mapSize.y * 32 * 1) >> customZoom; + resolutionWidth = (mapSize.x * COORDS_XY_STEP * 2) >> customZoom; + resolutionHeight = (mapSize.y * COORDS_XY_STEP * 1) >> customZoom; resolutionWidth += 8; resolutionHeight += 128; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 1468aac1a6..9c56c87b7a 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -29,6 +29,7 @@ constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * MAXIMUM_MAP_SIZE 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; constexpr const int32_t MINIMUM_LAND_HEIGHT_BIG = MINIMUM_LAND_HEIGHT * COORDS_Z_STEP; +constexpr const TileCoordsXY DEFAULT_MAP_SIZE = { 150, 150 }; #define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL)