diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index c6a3928c78..92350fbcaa 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1912,11 +1912,10 @@ static void window_ride_init_viewport(rct_window* w) } } while (count >= 0); - auto location = ride->stations[stationIndex].Start; - - focus.coordinate.x = location.x * 32; - focus.coordinate.y = location.y * 32; - focus.coordinate.z = ride->stations[stationIndex].GetBaseZ(); + auto location = ride->stations[stationIndex].GetStart(); + focus.coordinate.x = location.x; + focus.coordinate.y = location.y; + focus.coordinate.z = location.z; focus.sprite.type |= VIEWPORT_FOCUS_TYPE_COORDINATE; } else diff --git a/src/openrct2/actions/BannerSetStyleAction.hpp b/src/openrct2/actions/BannerSetStyleAction.hpp index 1346efa3b3..9abba7f52e 100644 --- a/src/openrct2/actions/BannerSetStyleAction.hpp +++ b/src/openrct2/actions/BannerSetStyleAction.hpp @@ -66,9 +66,8 @@ public: auto banner = GetBanner(_bannerIndex); res->Expenditure = ExpenditureType::Landscaping; - res->Position.x = banner->position.x * 32 + 16; - res->Position.y = banner->position.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = banner->position.ToCoordsXY().ToTileCentre(); + res->Position = { location, tile_element_height(location) }; TileElement* tileElement = banner_get_tile_element(_bannerIndex); @@ -116,9 +115,8 @@ public: auto banner = GetBanner(_bannerIndex); res->Expenditure = ExpenditureType::Landscaping; - res->Position.x = banner->position.x * 32 + 16; - res->Position.y = banner->position.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = banner->position.ToCoordsXY().ToTileCentre(); + res->Position = { location, tile_element_height(location) }; TileElement* tileElement = banner_get_tile_element(_bannerIndex); diff --git a/src/openrct2/actions/MazePlaceTrackAction.hpp b/src/openrct2/actions/MazePlaceTrackAction.hpp index 664e9cc97b..14160e2ea6 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.hpp +++ b/src/openrct2/actions/MazePlaceTrackAction.hpp @@ -193,8 +193,7 @@ public: if (ride->maze_tiles == 1) { - auto tileStartLoc = TileCoordsXY{ startLoc }; - ride->overall_view = tileStartLoc; + ride->overall_view = startLoc; } return res; diff --git a/src/openrct2/actions/MazeSetTrackAction.hpp b/src/openrct2/actions/MazeSetTrackAction.hpp index ebce59eb8f..d6807a94ce 100644 --- a/src/openrct2/actions/MazeSetTrackAction.hpp +++ b/src/openrct2/actions/MazeSetTrackAction.hpp @@ -233,8 +233,7 @@ public: if (_initialPlacement && !(flags & GAME_COMMAND_FLAG_GHOST)) { - auto tileStartLoc = TileCoordsXY{ startLoc }; - ride->overall_view = tileStartLoc; + ride->overall_view = startLoc; } } diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 1913447aff..8339aa398a 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -241,11 +241,8 @@ private: if (!ride->overall_view.isNull()) { - int32_t x = (ride->overall_view.x * 32) + 16; - int32_t y = (ride->overall_view.y * 32) + 16; - int32_t z = tile_element_height({ x, y }); - - res->Position = { x, y, z }; + auto xy = ride->overall_view.ToTileCentre(); + res->Position = { xy, tile_element_height(xy) }; } ride->Delete(); @@ -369,11 +366,8 @@ private: if (!ride->overall_view.isNull()) { - int32_t x = (ride->overall_view.x * 32) + 16; - int32_t y = (ride->overall_view.y * 32) + 16; - int32_t z = tile_element_height({ x, y }); - - res->Position = { x, y, z }; + auto location = ride->overall_view.ToTileCentre(); + res->Position = { location, tile_element_height(location) }; } window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, _rideIndex); diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp index 1dffab2496..2f40e62476 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp @@ -88,8 +88,7 @@ public: if (!location.isNull()) { - auto rideEntranceExitRemove = RideEntranceExitRemoveAction( - { location.x * 32, location.y * 32 }, _rideIndex, _stationNum, _isExit); + auto rideEntranceExitRemove = RideEntranceExitRemoveAction(location.ToCoordsXY(), _rideIndex, _stationNum, _isExit); rideEntranceExitRemove.SetFlags(GetFlags()); auto result = GameActions::QueryNested(&rideEntranceExitRemove); @@ -155,8 +154,7 @@ public: : ride_get_entrance_location(ride, _stationNum); if (!location.isNull()) { - auto rideEntranceExitRemove = RideEntranceExitRemoveAction( - { location.x * 32, location.y * 32 }, _rideIndex, _stationNum, _isExit); + auto rideEntranceExitRemove = RideEntranceExitRemoveAction(location.ToCoordsXY(), _rideIndex, _stationNum, _isExit); rideEntranceExitRemove.SetFlags(GetFlags()); auto result = GameActions::ExecuteNested(&rideEntranceExitRemove); diff --git a/src/openrct2/actions/RideSetAppearanceAction.hpp b/src/openrct2/actions/RideSetAppearanceAction.hpp index 0770cb62c7..1999065fb4 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.hpp +++ b/src/openrct2/actions/RideSetAppearanceAction.hpp @@ -161,9 +161,8 @@ public: auto res = std::make_unique(); if (!ride->overall_view.isNull()) { - res->Position.x = ride->overall_view.x * 32 + 16; - res->Position.y = ride->overall_view.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = ride->overall_view.ToTileCentre(); + res->Position = { location, tile_element_height(location) }; } return res; diff --git a/src/openrct2/actions/RideSetName.hpp b/src/openrct2/actions/RideSetName.hpp index a4cb2e6bcb..9a2c6291b8 100644 --- a/src/openrct2/actions/RideSetName.hpp +++ b/src/openrct2/actions/RideSetName.hpp @@ -95,9 +95,8 @@ public: windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST)); auto res = std::make_unique(); - res->Position.x = ride->overall_view.x * 32 + 16; - res->Position.y = ride->overall_view.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = ride->overall_view.ToTileCentre(); + res->Position = { location, tile_element_height(location) }; return res; } diff --git a/src/openrct2/actions/RideSetPriceAction.hpp b/src/openrct2/actions/RideSetPriceAction.hpp index 4e0d364c3c..0e1d27e2c8 100644 --- a/src/openrct2/actions/RideSetPriceAction.hpp +++ b/src/openrct2/actions/RideSetPriceAction.hpp @@ -95,9 +95,8 @@ public: if (!ride->overall_view.isNull()) { - res->Position.x = ride->overall_view.x * 32 + 16; - res->Position.y = ride->overall_view.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = ride->overall_view.ToTileCentre(); + res->Position = { location, tile_element_height(location) }; } uint32_t shopItem; diff --git a/src/openrct2/actions/RideSetSetting.hpp b/src/openrct2/actions/RideSetSetting.hpp index 204607739d..4ee121e621 100644 --- a/src/openrct2/actions/RideSetSetting.hpp +++ b/src/openrct2/actions/RideSetSetting.hpp @@ -245,9 +245,8 @@ public: auto res = std::make_unique(); if (!ride->overall_view.isNull()) { - res->Position.x = ride->overall_view.x * 32 + 16; - res->Position.y = ride->overall_view.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = ride->overall_view.ToTileCentre(); + res->Position = { location, tile_element_height(location) }; } window_invalidate_by_number(WC_RIDE, _rideIndex); return res; diff --git a/src/openrct2/actions/RideSetStatus.hpp b/src/openrct2/actions/RideSetStatus.hpp index 3bdd193f4e..46a9fe4602 100644 --- a/src/openrct2/actions/RideSetStatus.hpp +++ b/src/openrct2/actions/RideSetStatus.hpp @@ -122,9 +122,8 @@ public: ride->FormatNameTo(res->ErrorMessageArgs.data() + 6); if (!ride->overall_view.isNull()) { - res->Position.x = ride->overall_view.x * 32 + 16; - res->Position.y = ride->overall_view.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = ride->overall_view.ToTileCentre(); + res->Position = { location, tile_element_height(res->Position) }; } switch (_status) diff --git a/src/openrct2/actions/RideSetVehiclesAction.hpp b/src/openrct2/actions/RideSetVehiclesAction.hpp index a16d7276d4..1cc95dd29c 100644 --- a/src/openrct2/actions/RideSetVehiclesAction.hpp +++ b/src/openrct2/actions/RideSetVehiclesAction.hpp @@ -203,9 +203,8 @@ public: auto res = std::make_unique(); if (!ride->overall_view.isNull()) { - res->Position.x = ride->overall_view.x * 32 + 16; - res->Position.y = ride->overall_view.y * 32 + 16; - res->Position.z = tile_element_height(res->Position); + auto location = ride->overall_view.ToTileCentre(); + res->Position = { location, tile_element_height(res->Position) }; } auto intent = Intent(INTENT_ACTION_RIDE_PAINT_RESET_VEHICLE); diff --git a/src/openrct2/actions/TrackPlaceAction.hpp b/src/openrct2/actions/TrackPlaceAction.hpp index 0f86d1d081..4d97ad7ba2 100644 --- a/src/openrct2/actions/TrackPlaceAction.hpp +++ b/src/openrct2/actions/TrackPlaceAction.hpp @@ -580,8 +580,7 @@ public: if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN || ride->overall_view.isNull()) { - ride->overall_view.x = mapLoc.x / 32; - ride->overall_view.y = mapLoc.y / 32; + ride->overall_view = mapLoc; } auto tileElement = tile_element_insert( diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 6fcf746c4f..f9390803ec 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -720,12 +720,11 @@ viewport_focus viewport_update_smart_guest_follow(rct_window* window, Peep* peep auto ride = get_ride(peep->current_ride); if (ride != nullptr) { - auto x = (int32_t)ride->overall_view.x * 32 + 16; - auto y = (int32_t)ride->overall_view.y * 32 + 16; + auto xy = ride->overall_view.ToTileCentre(); focus.type = VIEWPORT_FOCUS_TYPE_COORDINATE; - focus.coordinate.x = x; - focus.coordinate.y = y; - focus.coordinate.z = tile_element_height({ x, y }) + 32; + focus.coordinate.x = xy.x; + focus.coordinate.y = xy.y; + focus.coordinate.z = tile_element_height(xy) + (4 * COORDS_Z_STEP); focus.sprite.type |= VIEWPORT_FOCUS_TYPE_COORDINATE; } } diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index 3704076616..980e749cef 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -222,8 +222,8 @@ void news_item_get_subject_location(int32_t type, int32_t subject, int32_t* x, i *x = LOCATION_NULL; break; } - *x = ride->overall_view.x * 32 + 16; - *y = ride->overall_view.y * 32 + 16; + *x = ride->overall_view.x + 16; + *y = ride->overall_view.y + 16; *z = tile_element_height({ *x, *y }); break; case NEWS_ITEM_PEEP_ON_RIDE: diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 36d6d75698..331fe6d380 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -746,7 +746,7 @@ private: } else { - dst->overall_view = { src->overall_view.x, src->overall_view.y }; + dst->overall_view = TileCoordsXY{ src->overall_view.x, src->overall_view.y }.ToCoordsXY(); } for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++) diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 44bd24d74d..ff93bce14c 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -542,7 +542,8 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src) } else { - dst->overall_view = { static_cast(src->overall_view.x), static_cast(src->overall_view.y) }; + auto tileLoc = TileCoordsXY(src->overall_view); + dst->overall_view = { static_cast(tileLoc.x), static_cast(tileLoc.y) }; } for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++) diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 5d7d1e3750..b32752f8a3 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -529,7 +529,8 @@ public: } else { - dst->overall_view = { src->overall_view.x, src->overall_view.y }; + auto tileLoc = TileCoordsXY(src->overall_view.x, src->overall_view.y); + dst->overall_view = tileLoc.ToCoordsXY(); } for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++) diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 1c635792ea..bf771bcbb8 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -227,7 +227,7 @@ struct Ride uint8_t status; std::string custom_name; uint16_t default_name_number; - TileCoordsXY overall_view; + CoordsXY overall_view; uint16_t vehicles[MAX_VEHICLES_PER_RIDE + 1]; // Points to the first car in the train uint8_t depart_flags; uint8_t num_stations; diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index b7830d04bb..8ef7b1c5c2 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -237,11 +237,10 @@ uint8_t banner_get_closest_ride_index(const CoordsXYZ& mapPos) if (ride_type_has_flag(ride.type, RIDE_TYPE_FLAG_IS_SHOP)) continue; - auto location = ride.overall_view; - if (location.isNull()) + auto rideCoords = ride.overall_view; + if (rideCoords.isNull()) continue; - auto rideCoords = location.ToCoordsXY(); int32_t distance = abs(mapPos.x - rideCoords.x) + abs(mapPos.y - rideCoords.y); if (distance < resultDistance) { diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index dde8c0f1af..a453051c61 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -416,14 +416,14 @@ int16_t tile_element_height(const CoordsXY& loc) { // Off the map if (!map_is_location_valid(loc)) - return 16; + return 2 * COORDS_Z_STEP; // Get the surface element for the tile auto surfaceElement = map_get_surface_element_at(loc); if (surfaceElement == nullptr) { - return 16; + return 2 * COORDS_Z_STEP; } uint16_t height = surfaceElement->GetBaseZ(); @@ -525,7 +525,7 @@ int16_t tile_element_height(const CoordsXY& loc) return height; } // This tile is essentially at the next height level - height += 0x10; + height += LAND_HEIGHT_STEP; // so we move *down* the slope if (quad < 0) {