From 45403ac2d3cd6917dc0a67f5309a1684a8aa86f4 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 21 Dec 2019 11:48:13 +0000 Subject: [PATCH] Move station_starts to TileCoordsXY --- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2/peep/GuestPathfinding.cpp | 2 +- src/openrct2/peep/Staff.cpp | 4 ++-- src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/ride/Ride.cpp | 23 ++++++++++------------- src/openrct2/ride/Ride.h | 2 +- src/openrct2/ride/RideRatings.cpp | 2 +- src/openrct2/ride/Station.cpp | 4 ++-- src/openrct2/ride/Vehicle.cpp | 2 +- src/openrct2/world/Location.hpp | 5 +++++ 10 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index b19428d900..8dc9a7655a 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1911,7 +1911,7 @@ static void window_ride_init_viewport(rct_window* w) } } while (count >= 0); - LocationXY8 location = ride->stations[stationIndex].Start; + auto location = ride->stations[stationIndex].Start; focus.coordinate.x = location.x * 32; focus.coordinate.y = location.y * 32; diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 89c9bf88fe..312f70769e 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -2121,7 +2121,7 @@ int32_t guest_path_finding(Guest* peep) if (numEntranceStations == 0) { // closestStationNum is always 0 here. - LocationXY8 entranceXY = ride->stations[closestStationNum].Start; + auto entranceXY = ride->stations[closestStationNum].Start; loc.x = entranceXY.x; loc.y = entranceXY.y; loc.z = ride->stations[closestStationNum].Height; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 271c58a194..ddf6621c7f 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -2333,7 +2333,7 @@ bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride) return true; } - LocationXY8 stationPosition = ride->stations[current_ride_station].Start; + auto stationPosition = ride->stations[current_ride_station].Start; if (stationPosition.isNull()) { return true; @@ -2425,7 +2425,7 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride) return true; } - LocationXY8 stationPosition = ride->stations[current_ride_station].Start; + auto stationPosition = ride->stations[current_ride_station].Start; if (stationPosition.isNull()) { return true; diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index dfab24edb7..cead99afdb 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -532,7 +532,7 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src) } else { - dst->station_starts[i] = { src->stations[i].Start.x, src->stations[i].Start.y }; + dst->station_starts[i] = { static_cast(src->stations[i].Start.x), static_cast(src->stations[i].Start.y) }; } dst->station_heights[i] = src->stations[i].Height; dst->station_length[i] = src->stations[i].Length; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index c28093b327..116c59b847 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -3289,14 +3289,12 @@ static void ride_entrance_exit_connected(Ride* ride) static void ride_shop_connected(Ride* ride) { - LocationXY8 coordinates = ride->stations[0].Start; - if (coordinates.isNull()) + TileCoordsXY shopLoc = ride->stations[0].Start; + if (shopLoc.isNull()) return; - TileCoordsXY loc = { coordinates.x, coordinates.y }; - TrackElement* trackElement = nullptr; - TileElement* tileElement = map_get_first_element_at(loc.x, loc.y); + TileElement* tileElement = map_get_first_element_at(shopLoc.x, shopLoc.y); do { if (tileElement == nullptr) @@ -3346,8 +3344,8 @@ static void ride_shop_connected(Ride* ride) // Flip direction north<->south, east<->west uint8_t face_direction = direction_reverse(count); - int32_t y2 = loc.y - TileDirectionDelta[face_direction].y; - int32_t x2 = loc.x - TileDirectionDelta[face_direction].x; + int32_t y2 = shopLoc.y - TileDirectionDelta[face_direction].y; + int32_t x2 = shopLoc.x - TileDirectionDelta[face_direction].x; if (map_coord_is_connected({ x2, y2, tileElement->base_height }, face_direction)) return; @@ -4924,7 +4922,7 @@ void loc_6DDF9C(Ride* ride, TileElement* tileElement) */ static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying) { - LocationXY8 location; + TileCoordsXY location; int32_t stationIndex; for (stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) { @@ -6234,7 +6232,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(ScreenCoordsX return entranceExitCoords; } - LocationXY8 stationStart = ride->stations[gRideEntranceExitPlaceStationIndex].Start; + auto stationStart = ride->stations[gRideEntranceExitPlaceStationIndex].Start; if (stationStart.isNull()) { entranceExitCoords.x = LOCATION_NULL; @@ -6657,12 +6655,11 @@ static int32_t ride_get_track_length(Ride* ride) for (int32_t i = 0; i < MAX_STATIONS && !foundTrack; i++) { - LocationXY8 location = ride->stations[i].Start; - if (location.isNull()) + if (ride->stations[i].Start.isNull()) continue; - x = location.x * 32; - y = location.y * 32; + x = ride->stations[i].Start.x * 32; + y = ride->stations[i].Start.y * 32; z = ride->stations[i].Height; tileElement = map_get_first_element_at(x >> 5, y >> 5); diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index c4a788e66f..2cbd13e65d 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -162,7 +162,7 @@ struct rct_ride_entry struct RideStation { - LocationXY8 Start; + TileCoordsXY Start; uint8_t Height; uint8_t Length; uint8_t Depart; diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 930f8683ce..33503079bf 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -1433,7 +1433,7 @@ static int32_t ride_ratings_get_scenery_score(Ride* ride) } else { - LocationXY8 location = ride->stations[i].Start; + auto location = ride->stations[i].Start; x = location.x; y = location.y; } diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index 8acbbbde10..7074be8920 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -417,12 +417,12 @@ TileCoordsXYZD ride_get_exit_location(const Ride* ride, const int32_t stationInd void ride_clear_entrance_location(Ride* ride, const int32_t stationIndex) { - ride->stations[stationIndex].Entrance.x = COORDS_NULL; + ride->stations[stationIndex].Entrance.setNull(); } void ride_clear_exit_location(Ride* ride, const int32_t stationIndex) { - ride->stations[stationIndex].Exit.x = COORDS_NULL; + ride->stations[stationIndex].Exit.setNull(); } void ride_set_entrance_location(Ride* ride, const int32_t stationIndex, const TileCoordsXYZD location) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 4b3279921a..657c8143b9 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -2797,7 +2797,7 @@ static bool vehicle_can_depart_synchronised(rct_vehicle* vehicle) return false; int32_t station = vehicle->current_station; - LocationXY8 location = ride->stations[station].Start; + auto location = ride->stations[station].Start; int32_t x = location.x * 32; int32_t y = location.y * 32; int32_t z = ride->stations[station].Height; diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index d4f369ab2f..1235d11af3 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -234,6 +234,11 @@ struct TileCoordsXY { return x == COORDS_NULL; }; + + void setNull() + { + x = COORDS_NULL; + } }; struct CoordsXYZ : public CoordsXY