From 6b72b0992d7e9dcd74dc281b82f8b71bdfc77ba8 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 12 Dec 2019 09:58:27 +0000 Subject: [PATCH 1/5] Removal of LocationXY and simplify --- src/openrct2-ui/windows/Map.cpp | 7 ++----- src/openrct2/actions/GameActionCompat.cpp | 10 +++------- src/openrct2/world/Duck.cpp | 2 +- src/openrct2/world/Entrance.cpp | 6 ++---- src/openrct2/world/Entrance.h | 5 ++--- src/openrct2/world/MoneyEffect.cpp | 2 +- 6 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index a6ea721a07..8cf681db49 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1257,16 +1257,13 @@ static void window_map_place_park_entrance_tool_update(ScreenCoordsXY screenCoor gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT | MAP_SELECT_FLAG_ENABLE_ARROW; map_invalidate_map_selection_tiles(); - if (gParkEntranceGhostExists && parkEntrancePosition.x == gParkEntranceGhostPosition.x - && parkEntrancePosition.y == gParkEntranceGhostPosition.y - && parkEntrancePosition.direction == gParkEntranceGhostDirection) + if (gParkEntranceGhostExists && parkEntrancePosition == gParkEntranceGhostPosition) { return; } park_entrance_remove_ghost(); - park_entrance_place_ghost( - parkEntrancePosition.x, parkEntrancePosition.y, parkEntrancePosition.z / 16, parkEntrancePosition.direction); + park_entrance_place_ghost(parkEntrancePosition); } /** diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index 48099396d8..f17fd9806d 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -21,25 +21,21 @@ #include "WallRemoveAction.hpp" #pragma region PlaceParkEntranceAction - /** * * rct2: 0x00666F4E */ -money32 park_entrance_place_ghost(int32_t x, int32_t y, int32_t z, int32_t direction) +money32 park_entrance_place_ghost(CoordsXYZD entranceLoc) { park_entrance_remove_ghost(); - auto gameAction = PlaceParkEntranceAction({ x, y, z * 16, (Direction)direction }); + auto gameAction = PlaceParkEntranceAction(entranceLoc); gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST); auto result = GameActions::Execute(&gameAction); if (result->Error == GA_ERROR::OK) { - gParkEntranceGhostPosition.x = x; - gParkEntranceGhostPosition.y = y; - gParkEntranceGhostPosition.z = z; - gParkEntranceGhostDirection = direction; + gParkEntranceGhostPosition = entranceLoc; gParkEntranceGhostExists = true; } return result->Cost; diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index eae41e922e..ab49675139 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -30,7 +30,7 @@ enum DUCK_STATE }; constexpr const int32_t DUCK_MAX_STATES = 5; -static constexpr const LocationXY16 DuckMoveOffset[] = +static constexpr const CoordsXY DuckMoveOffset[] = { { -1, 0 }, { 0, 1 }, diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 7ffce18957..d50145a2d2 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -29,8 +29,7 @@ #include bool gParkEntranceGhostExists = false; -LocationXYZ16 gParkEntranceGhostPosition = { 0, 0, 0 }; -uint8_t gParkEntranceGhostDirection = 0; +CoordsXYZD gParkEntranceGhostPosition = { 0, 0, 0, 0 }; std::vector gParkEntrances; CoordsXYZD gRideEntranceExitGhostPosition; @@ -56,8 +55,7 @@ void park_entrance_remove_ghost() if (gParkEntranceGhostExists) { gParkEntranceGhostExists = false; - auto parkEntranceRemoveAction = ParkEntranceRemoveAction( - { gParkEntranceGhostPosition.x, gParkEntranceGhostPosition.y, gParkEntranceGhostPosition.z * 16 }); + auto parkEntranceRemoveAction = ParkEntranceRemoveAction(gParkEntranceGhostPosition); parkEntranceRemoveAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); GameActions::Execute(&parkEntranceRemoveAction); } diff --git a/src/openrct2/world/Entrance.h b/src/openrct2/world/Entrance.h index 18cf42ef6f..c3c048a95c 100644 --- a/src/openrct2/world/Entrance.h +++ b/src/openrct2/world/Entrance.h @@ -29,8 +29,7 @@ assert_struct_size(rct_entrance_type, 8); struct TileElement; extern bool gParkEntranceGhostExists; -extern LocationXYZ16 gParkEntranceGhostPosition; -extern uint8_t gParkEntranceGhostDirection; +extern CoordsXYZD gParkEntranceGhostPosition; #define MAX_PARK_ENTRANCES 4 @@ -42,7 +41,7 @@ extern CoordsXYZD gRideEntranceExitGhostPosition; extern uint8_t gRideEntranceExitGhostStationIndex; void park_entrance_remove_ghost(); -money32 park_entrance_place_ghost(int32_t x, int32_t y, int32_t z, int32_t direction); +money32 park_entrance_place_ghost(CoordsXYZD entranceLoc); void reset_park_entrance(); void maze_entrance_hedge_replacement(int32_t x, int32_t y, TileElement* tileElement); diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index 0385908e2d..b3c50569af 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -16,7 +16,7 @@ #include "Map.h" #include "Sprite.h" -static constexpr const LocationXY16 _moneyEffectMoveOffset[] = { { 1, -1 }, { 1, 1 }, { -1, 1 }, { -1, -1 } }; +static constexpr const CoordsXY _moneyEffectMoveOffset[] = { { 1, -1 }, { 1, 1 }, { -1, 1 }, { -1, -1 } }; bool rct_sprite::IsMoneyEffect() { From 1f80dee4df7bba1847f45baf55435d1e26e1b5fc Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 12 Dec 2019 10:21:05 +0000 Subject: [PATCH 2/5] Refactor footpath.cpp to remove LocationXY and use CoordsXY --- .../interface/ViewportInteraction.cpp | 2 +- src/openrct2-ui/windows/Footpath.cpp | 70 ++++++++----------- src/openrct2/world/Footpath.cpp | 24 +++---- src/openrct2/world/Footpath.h | 8 +-- src/openrct2/world/Map.cpp | 4 +- 5 files changed, 48 insertions(+), 60 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index af4458c04a..79ad2e548b 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -534,7 +534,7 @@ static void viewport_interaction_remove_footpath(TileElement* tileElement, Coord { if (tileElement2->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement2->base_height == z) { - footpath_remove(mapCoords.x, mapCoords.y, z, GAME_COMMAND_FLAG_APPLY); + footpath_remove({ mapCoords, z }, GAME_COMMAND_FLAG_APPLY); break; } } while (!(tileElement2++)->IsLastForTile()); diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index f78662d7aa..05ea3e71fe 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -183,7 +183,7 @@ static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords); static void window_footpath_construct(); static void window_footpath_remove(); static void window_footpath_set_enabled_and_pressed_widgets(); -static void footpath_get_next_path_info(int32_t* type, int32_t* x, int32_t* y, int32_t* z, int32_t* slope); +static void footpath_get_next_path_info(int32_t* type, CoordsXYZ& footpathLoc, int32_t* slope); static bool footpath_select_default(); /** @@ -463,7 +463,7 @@ static void window_footpath_toolup(rct_window* w, rct_widgetindex widgetIndex, S */ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window* w) { - int32_t type, x, y, z, slope; + int32_t type, slope; if (gFootpathConstructionMode != PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL) { @@ -480,8 +480,9 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window* // Update provisional bridge mode path if (!(gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1)) { - footpath_get_next_path_info(&type, &x, &y, &z, &slope); - _window_footpath_cost = footpath_provisional_set(type, x, y, z, slope); + CoordsXYZ footpathLoc; + footpath_get_next_path_info(&type, footpathLoc, &slope); + _window_footpath_cost = footpath_provisional_set(type, footpathLoc, slope); widget_invalidate(w, WIDX_CONSTRUCT); } @@ -490,10 +491,11 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window* { _window_footpath_provisional_path_arrow_timer = 5; gFootpathProvisionalFlags ^= PROVISIONAL_PATH_FLAG_SHOW_ARROW; - footpath_get_next_path_info(&type, &x, &y, &z, &slope); - gMapSelectArrowPosition.x = x; - gMapSelectArrowPosition.y = y; - gMapSelectArrowPosition.z = z * 8; + CoordsXYZ footpathLoc; + footpath_get_next_path_info(&type, footpathLoc, &slope); + gMapSelectArrowPosition.x = footpathLoc.x; + gMapSelectArrowPosition.y = footpathLoc.y; + gMapSelectArrowPosition.z = footpathLoc.z; gMapSelectArrowDirection = gFootpathConstructDirection; if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_SHOW_ARROW) { @@ -503,7 +505,7 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window* { gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; } - map_invalidate_tile_full(x, y); + map_invalidate_tile_full(footpathLoc.x, footpathLoc.y); } } @@ -729,7 +731,7 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC { // Check for change if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == mapCoord.x - && gFootpathProvisionalPosition.y == mapCoord.y && gFootpathProvisionalPosition.z == tileElement->base_height) + && gFootpathProvisionalPosition.y == mapCoord.y && gFootpathProvisionalPosition.z / 8 == tileElement->base_height) { return; } @@ -779,7 +781,7 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC } int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); - _window_footpath_cost = footpath_provisional_set(pathType, mapCoord.x, mapCoord.y, z, slope); + _window_footpath_cost = footpath_provisional_set(pathType, { mapCoord, z * 8 }, slope); window_invalidate_by_class(WC_FOOTPATH); } } @@ -971,11 +973,12 @@ static void window_footpath_construct() _window_footpath_cost = MONEY32_UNDEFINED; footpath_provisional_update(); - int32_t type, x, y, z, slope; - footpath_get_next_path_info(&type, &x, &y, &z, &slope); + int32_t type, slope; + CoordsXYZ footpathLoc; + footpath_get_next_path_info(&type, footpathLoc, &slope); gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE; - auto footpathPlaceAction = FootpathPlaceAction({ x, y, z * 8 }, slope, type, gFootpathConstructDirection); + auto footpathPlaceAction = FootpathPlaceAction(footpathLoc, slope, type, gFootpathConstructDirection); footpathPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { if (result->Error == GA_ERROR::OK) { @@ -995,20 +998,14 @@ static void window_footpath_construct() viewport_set_visibility(1); } + gFootpathConstructFromPosition = footpathLoc; // If we have just built an upwards slope, the next path to construct is // a bit higher. Note that the z returned by footpath_get_next_path_info // already is lowered if we are building a downwards slope. if (gFootpathConstructSlope == 2) { - gFootpathConstructFromPosition.z = (z + 2) * 8; + gFootpathConstructFromPosition.z += 2 * 8; } - else - { - gFootpathConstructFromPosition.z = z * 8; - } - - gFootpathConstructFromPosition.x = x; - gFootpathConstructFromPosition.y = y; } window_footpath_set_enabled_and_pressed_widgets(); }); @@ -1021,9 +1018,7 @@ static void window_footpath_construct() */ static void footpath_remove_tile_element(TileElement* tileElement) { - int32_t x, y, z; - - z = tileElement->base_height; + auto z = tileElement->base_height; if (tileElement->AsPath()->IsSloped()) { uint8_t slopeDirection = tileElement->AsPath()->GetSlopeDirection(); @@ -1053,18 +1048,15 @@ static void footpath_remove_tile_element(TileElement* tileElement) } } + gFootpathConstructFromPosition.z = tileElement->base_height * 8; // Remove path - footpath_remove( - gFootpathConstructFromPosition.x, gFootpathConstructFromPosition.y, tileElement->base_height, GAME_COMMAND_FLAG_APPLY); + footpath_remove(gFootpathConstructFromPosition, GAME_COMMAND_FLAG_APPLY); // Move selection - edge = direction_reverse(edge); - x = gFootpathConstructFromPosition.x - CoordsDirectionDelta[edge].x; - y = gFootpathConstructFromPosition.y - CoordsDirectionDelta[edge].y; - gFootpathConstructFromPosition.x = x; - gFootpathConstructFromPosition.y = y; - gFootpathConstructFromPosition.z = z << 3; - gFootpathConstructDirection = edge; + gFootpathConstructFromPosition.x -= CoordsDirectionDelta[edge].x; + gFootpathConstructFromPosition.y -= CoordsDirectionDelta[edge].y; + gFootpathConstructFromPosition.z = z * 8; + gFootpathConstructDirection = direction_reverse(edge); gFootpathConstructValidDirections = 255; } @@ -1223,14 +1215,14 @@ static void window_footpath_set_enabled_and_pressed_widgets() * * rct2: 0x006A7B20 */ -static void footpath_get_next_path_info(int32_t* type, int32_t* x, int32_t* y, int32_t* z, int32_t* slope) +static void footpath_get_next_path_info(int32_t* type, CoordsXYZ& footpathLoc, int32_t* slope) { int32_t direction; direction = gFootpathConstructDirection; - *x = gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x; - *y = gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y; - *z = gFootpathConstructFromPosition.z / 8; + footpathLoc.x = gFootpathConstructFromPosition.x + CoordsDirectionDelta[direction].x; + footpathLoc.y = gFootpathConstructFromPosition.y + CoordsDirectionDelta[direction].y; + footpathLoc.z = gFootpathConstructFromPosition.z; *type = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); *slope = TILE_ELEMENT_SLOPE_FLAT; if (gFootpathConstructSlope != 0) @@ -1238,7 +1230,7 @@ static void footpath_get_next_path_info(int32_t* type, int32_t* x, int32_t* y, i *slope = gFootpathConstructDirection | TILE_ELEMENT_SLOPE_S_CORNER_UP; if (gFootpathConstructSlope != 2) { - *z -= 2; + footpathLoc.z -= 2 * 8; *slope ^= TILE_ELEMENT_SLOPE_E_CORNER_UP; } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 21ea776817..d2677d70cf 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -38,13 +38,13 @@ void footpath_update_queue_entrance_banner(int32_t x, int32_t y, TileElement* tileElement); uint8_t gFootpathProvisionalFlags; -LocationXYZ16 gFootpathProvisionalPosition; +CoordsXYZ gFootpathProvisionalPosition; uint8_t gFootpathProvisionalType; uint8_t gFootpathProvisionalSlope; uint8_t gFootpathConstructionMode; uint16_t gFootpathSelectedId; uint8_t gFootpathSelectedType; -LocationXYZ16 gFootpathConstructFromPosition; +CoordsXYZ gFootpathConstructFromPosition; uint8_t gFootpathConstructDirection; uint8_t gFootpathConstructSlope; uint8_t gFootpathConstructValidDirections; @@ -125,9 +125,9 @@ TileElement* map_get_footpath_element(int32_t x, int32_t y, int32_t z) return nullptr; } -money32 footpath_remove(int32_t x, int32_t y, int32_t z, int32_t flags) +money32 footpath_remove(CoordsXYZ footpathLoc, int32_t flags) { - auto action = FootpathRemoveAction({ x, y, z * 8 }); + auto action = FootpathRemoveAction(footpathLoc); action.SetFlags(flags); if (flags & GAME_COMMAND_FLAG_APPLY) @@ -143,22 +143,20 @@ money32 footpath_remove(int32_t x, int32_t y, int32_t z, int32_t flags) * * rct2: 0x006A76FF */ -money32 footpath_provisional_set(int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope) +money32 footpath_provisional_set(int32_t type, CoordsXYZ footpathLoc, int32_t slope) { money32 cost; footpath_provisional_remove(); - auto footpathPlaceAction = FootpathPlaceAction({ x, y, z * 8 }, slope, type); + auto footpathPlaceAction = FootpathPlaceAction(footpathLoc, slope, type); footpathPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); auto res = GameActions::Execute(&footpathPlaceAction); cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; if (res->Error == GA_ERROR::OK) { gFootpathProvisionalType = type; - gFootpathProvisionalPosition.x = x; - gFootpathProvisionalPosition.y = y; - gFootpathProvisionalPosition.z = z & 0xFF; + gFootpathProvisionalPosition = footpathLoc; gFootpathProvisionalSlope = slope; gFootpathProvisionalFlags |= PROVISIONAL_PATH_FLAG_1; @@ -184,15 +182,15 @@ money32 footpath_provisional_set(int32_t type, int32_t x, int32_t y, int32_t z, } else if ( gFootpathConstructSlope == TILE_ELEMENT_SLOPE_FLAT - || gFootpathProvisionalPosition.z * 8 < gFootpathConstructFromPosition.z) + || gFootpathProvisionalPosition.z < gFootpathConstructFromPosition.z) { // Going either straight on, or down. - virtual_floor_set_height(gFootpathProvisionalPosition.z * 8); + virtual_floor_set_height(gFootpathProvisionalPosition.z); } else { // Going up in the world! - virtual_floor_set_height((gFootpathProvisionalPosition.z + 2) * 8); + virtual_floor_set_height(gFootpathProvisionalPosition.z + 2 * 8); } } @@ -210,7 +208,7 @@ void footpath_provisional_remove() gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_1; footpath_remove( - gFootpathProvisionalPosition.x, gFootpathProvisionalPosition.y, gFootpathProvisionalPosition.z, + gFootpathProvisionalPosition, GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); } diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 6694159858..b93b5ee2d1 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -155,13 +155,13 @@ enum }; extern uint8_t gFootpathProvisionalFlags; -extern LocationXYZ16 gFootpathProvisionalPosition; +extern CoordsXYZ gFootpathProvisionalPosition; extern uint8_t gFootpathProvisionalType; extern uint8_t gFootpathProvisionalSlope; extern uint8_t gFootpathConstructionMode; extern uint16_t gFootpathSelectedId; extern uint8_t gFootpathSelectedType; -extern LocationXYZ16 gFootpathConstructFromPosition; +extern CoordsXYZ gFootpathConstructFromPosition; extern uint8_t gFootpathConstructDirection; extern uint8_t gFootpathConstructSlope; extern uint8_t gFootpathConstructValidDirections; @@ -176,8 +176,8 @@ TileElement* map_get_footpath_element(int32_t x, int32_t y, int32_t z); struct PathElement; PathElement* map_get_footpath_element_slope(int32_t x, int32_t y, int32_t z, int32_t slope); void footpath_interrupt_peeps(int32_t x, int32_t y, int32_t z); -money32 footpath_remove(int32_t x, int32_t y, int32_t z, int32_t flags); -money32 footpath_provisional_set(int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope); +money32 footpath_remove(CoordsXYZ footpathLoc, int32_t flags); +money32 footpath_provisional_set(int32_t type, CoordsXYZ footpathLoc, int32_t slope); void footpath_provisional_remove(); void footpath_provisional_update(); void footpath_get_coordinates_from_pos( diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 6452fa425f..54d9f14116 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1506,9 +1506,7 @@ void map_restore_provisional_elements() if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) { gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_1; - footpath_provisional_set( - gFootpathProvisionalType, gFootpathProvisionalPosition.x, gFootpathProvisionalPosition.y, - gFootpathProvisionalPosition.z, gFootpathProvisionalSlope); + footpath_provisional_set(gFootpathProvisionalType, gFootpathProvisionalPosition, gFootpathProvisionalSlope); } if (window_find_by_class(WC_RIDE_CONSTRUCTION) != nullptr) { From f346e439fc182c2780d5297b68f48291407ec92d Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 12 Dec 2019 11:04:40 +0000 Subject: [PATCH 3/5] Change type of map selection a and b --- src/openrct2-ui/windows/Footpath.cpp | 6 ++---- src/openrct2-ui/windows/Map.cpp | 3 +-- src/openrct2-ui/windows/RideConstruction.cpp | 6 ++---- src/openrct2-ui/windows/TileInspector.cpp | 6 ++---- src/openrct2-ui/windows/ViewClipping.cpp | 3 +-- src/openrct2/paint/VirtualFloor.cpp | 16 ++++++++-------- src/openrct2/world/Map.cpp | 6 +++--- src/openrct2/world/Map.h | 6 +++--- 8 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 05ea3e71fe..ff61b85bdf 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -739,10 +739,8 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC // Set map selection gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; gMapSelectType = MAP_SELECT_TYPE_FULL; - gMapSelectPositionA.x = mapCoord.x; - gMapSelectPositionA.y = mapCoord.y; - gMapSelectPositionB.x = mapCoord.x; - gMapSelectPositionB.y = mapCoord.y; + gMapSelectPositionA = mapCoord; + gMapSelectPositionB = mapCoord; footpath_provisional_update(); diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 8cf681db49..201b99fd4c 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1179,8 +1179,7 @@ static void window_map_set_land_rights_tool_update(ScreenCoordsXY screenCoords) int32_t radius = (landRightsToolSize * 16) - 16; mapCoords->x = (mapCoords->x - radius) & 0xFFE0; mapCoords->y = (mapCoords->y - radius) & 0xFFE0; - gMapSelectPositionA.x = mapCoords->x; - gMapSelectPositionA.y = mapCoords->y; + gMapSelectPositionA = *mapCoords; gMapSelectPositionB.x = mapCoords->x + size; gMapSelectPositionB.y = mapCoords->y + size; map_invalidate_selection_rect(); diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index cedb58d69b..b3ce358a58 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3704,10 +3704,8 @@ void ride_construction_toolupdate_entrance_exit(ScreenCoordsXY screenCoords) gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; gMapSelectType = MAP_SELECT_TYPE_FULL; - gMapSelectPositionA.x = entranceOrExitCoords.x; - gMapSelectPositionA.y = entranceOrExitCoords.y; - gMapSelectPositionB.x = entranceOrExitCoords.x; - gMapSelectPositionB.y = entranceOrExitCoords.y; + gMapSelectPositionA = entranceOrExitCoords; + gMapSelectPositionB = entranceOrExitCoords; gMapSelectArrowDirection = direction_reverse(entranceOrExitCoords.direction); gMapSelectArrowPosition.x = entranceOrExitCoords.x; gMapSelectArrowPosition.y = entranceOrExitCoords.y; diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 99ee1fa44f..a4b5b98430 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1237,13 +1237,11 @@ static void window_tile_inspector_tool_update(rct_window* w, rct_widgetindex wid if (mapCoords.x != LOCATION_NULL) { - gMapSelectPositionA.x = gMapSelectPositionB.x = mapCoords.x; - gMapSelectPositionA.y = gMapSelectPositionB.y = mapCoords.y; + gMapSelectPositionA = gMapSelectPositionB = mapCoords; } else if (windowTileInspectorTileSelected) { - gMapSelectPositionA.x = gMapSelectPositionB.x = windowTileInspectorToolMap.x; - gMapSelectPositionA.y = gMapSelectPositionB.y = windowTileInspectorToolMap.y; + gMapSelectPositionA = gMapSelectPositionB = windowTileInspectorToolMap; } else { diff --git a/src/openrct2-ui/windows/ViewClipping.cpp b/src/openrct2-ui/windows/ViewClipping.cpp index 39d5ab4751..18c1797ef6 100644 --- a/src/openrct2-ui/windows/ViewClipping.cpp +++ b/src/openrct2-ui/windows/ViewClipping.cpp @@ -323,8 +323,7 @@ static void window_view_clipping_tool_update(rct_window* w, rct_widgetindex widg { gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; map_invalidate_tile_full(gMapSelectPositionA.x, gMapSelectPositionA.y); - gMapSelectPositionA.x = gMapSelectPositionB.x = mapCoords.x; - gMapSelectPositionA.y = gMapSelectPositionB.y = mapCoords.y; + gMapSelectPositionA = gMapSelectPositionB = mapCoords; map_invalidate_tile_full(mapCoords.x, mapCoords.y); gMapSelectType = MAP_SELECT_TYPE_FULL; } diff --git a/src/openrct2/paint/VirtualFloor.cpp b/src/openrct2/paint/VirtualFloor.cpp index ff86d15680..0c70e399dc 100644 --- a/src/openrct2/paint/VirtualFloor.cpp +++ b/src/openrct2/paint/VirtualFloor.cpp @@ -94,8 +94,8 @@ void virtual_floor_disable() void virtual_floor_invalidate() { // First, let's figure out how big our selection is. - LocationXY16 min_position = { std::numeric_limits::max(), std::numeric_limits::max() }; - LocationXY16 max_position = { std::numeric_limits::lowest(), std::numeric_limits::lowest() }; + CoordsXY min_position = { std::numeric_limits::max(), std::numeric_limits::max() }; + CoordsXY max_position = { std::numeric_limits::lowest(), std::numeric_limits::lowest() }; if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { @@ -107,10 +107,10 @@ void virtual_floor_invalidate() { for (const auto& tile : gMapSelectionTiles) { - min_position.x = std::min(min_position.x, tile.x); - min_position.y = std::min(min_position.y, tile.y); - max_position.x = std::max(max_position.x, tile.x); - max_position.y = std::max(max_position.y, tile.y); + min_position.x = std::min(min_position.x, tile.x); + min_position.y = std::min(min_position.y, tile.y); + max_position.x = std::max(max_position.x, tile.x); + max_position.y = std::max(max_position.y, tile.y); } } @@ -126,8 +126,8 @@ void virtual_floor_invalidate() && _virtualFloorLastMaxPos.x != std::numeric_limits::lowest() && _virtualFloorLastMaxPos.y != std::numeric_limits::lowest()) { - LocationXY16 prevMins = { _virtualFloorLastMinPos.x, _virtualFloorLastMinPos.y }; - LocationXY16 prevMaxs = { _virtualFloorLastMaxPos.x, _virtualFloorLastMaxPos.y }; + CoordsXY prevMins = { _virtualFloorLastMinPos.x, _virtualFloorLastMinPos.y }; + CoordsXY prevMaxs = { _virtualFloorLastMaxPos.x, _virtualFloorLastMaxPos.y }; if (prevMins.x != min_position.x || prevMins.y != min_position.y || prevMaxs.x != max_position.x || prevMaxs.y != max_position.y || (_virtualFloorFlags & VIRTUAL_FLOOR_FORCE_INVALIDATION) != 0) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 54d9f14116..e1e2120e39 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -71,8 +71,8 @@ const TileCoordsXY TileDirectionDelta[] = { { -1, 0 }, { 0, +1 }, { +1, 0 }, uint16_t gMapSelectFlags; uint16_t gMapSelectType; -LocationXY16 gMapSelectPositionA; -LocationXY16 gMapSelectPositionB; +CoordsXY gMapSelectPositionA; +CoordsXY gMapSelectPositionB; LocationXYZ16 gMapSelectArrowPosition; uint8_t gMapSelectArrowDirection; @@ -2018,7 +2018,7 @@ void map_invalidate_element(int32_t x, int32_t y, TileElement* tileElement) map_invalidate_tile(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); } -void map_invalidate_region(const LocationXY16& mins, const LocationXY16& maxs) +void map_invalidate_region(const CoordsXY& mins, const CoordsXY& maxs) { int32_t x0, y0, x1, y1, left, right, top, bottom; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index ece6b008e9..ff2228f866 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -97,8 +97,8 @@ extern int16_t gMapBaseZ; extern uint16_t gMapSelectFlags; extern uint16_t gMapSelectType; -extern LocationXY16 gMapSelectPositionA; -extern LocationXY16 gMapSelectPositionB; +extern CoordsXY gMapSelectPositionA; +extern CoordsXY gMapSelectPositionB; extern LocationXYZ16 gMapSelectArrowPosition; extern uint8_t gMapSelectArrowDirection; @@ -213,7 +213,7 @@ void map_invalidate_tile_zoom1(int32_t x, int32_t y, int32_t z0, int32_t z1); void map_invalidate_tile_zoom0(int32_t x, int32_t y, int32_t z0, int32_t z1); void map_invalidate_tile_full(int32_t x, int32_t y); void map_invalidate_element(int32_t x, int32_t y, TileElement* tileElement); -void map_invalidate_region(const LocationXY16& mins, const LocationXY16& maxs); +void map_invalidate_region(const CoordsXY& mins, const CoordsXY& maxs); int32_t map_get_tile_side(int32_t mapX, int32_t mapY); int32_t map_get_tile_quadrant(int32_t mapX, int32_t mapY); From b34defa907b9463ca008026e440c6b9ff1b2202e Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 19 Dec 2019 08:40:21 +0000 Subject: [PATCH 4/5] Fix testpaint --- test/testpaint/Compat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index c73715dc9d..23f1b6ea77 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -91,8 +91,8 @@ int object_entry_group_counts[] = { GeneralConfiguration gConfigGeneral; uint16_t gMapSelectFlags; uint16_t gMapSelectType; -LocationXY16 gMapSelectPositionA; -LocationXY16 gMapSelectPositionB; +CoordsXY gMapSelectPositionA; +CoordsXY gMapSelectPositionB; LocationXYZ16 gMapSelectArrowPosition; uint8_t gMapSelectArrowDirection; From 521e5db4c20bdb26116a47264111c7bbac41e973 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 21 Dec 2019 12:22:59 +0000 Subject: [PATCH 5/5] Make constant values more explicit. Fix mistake in z coordinate conversion --- src/openrct2-ui/interface/ViewportInteraction.cpp | 2 +- src/openrct2-ui/windows/Footpath.cpp | 4 ++-- src/openrct2/world/Footpath.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 79ad2e548b..7099bf636a 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -534,7 +534,7 @@ static void viewport_interaction_remove_footpath(TileElement* tileElement, Coord { if (tileElement2->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement2->base_height == z) { - footpath_remove({ mapCoords, z }, GAME_COMMAND_FLAG_APPLY); + footpath_remove({ mapCoords, z * 8 }, GAME_COMMAND_FLAG_APPLY); break; } } while (!(tileElement2++)->IsLastForTile()); diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index ff61b85bdf..46ebbfe30b 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -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 += (2 * 8); } } window_footpath_set_enabled_and_pressed_widgets(); @@ -1228,7 +1228,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 -= (2 * 8); *slope ^= TILE_ELEMENT_SLOPE_E_CORNER_UP; } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index d2677d70cf..59470aee35 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 + (2 * 8)); } }