diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 5faef14558..e5ed2bbcea 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1609,7 +1609,7 @@ rct_window* window_ride_main_open(Ride* ride) * * rct2: 0x006ACCCE */ -static rct_window* window_ride_open_station(Ride* ride, int32_t stationIndex) +static rct_window* window_ride_open_station(Ride* ride, StationIndex stationIndex) { if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_NO_VEHICLES)) return window_ride_main_open(ride); @@ -1904,7 +1904,7 @@ static void window_ride_init_viewport(rct_window* w) } else if (eax >= ride->num_vehicles && eax < (ride->num_vehicles + ride->num_stations)) { - int32_t stationIndex = -1; + StationIndex stationIndex = STATION_INDEX_NULL; int32_t count = eax - ride->num_vehicles; do { @@ -2820,7 +2820,7 @@ static rct_string_id window_ride_get_status_station(rct_window* w, void* argumen return STR_NONE; int32_t count = w->ride.view - ride->num_vehicles - 1; - int32_t stationIndex = -1; + StationIndex stationIndex = STATION_INDEX_NULL; rct_string_id stringId = 0; do diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 71fbf7738e..89e615f8ca 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3663,8 +3663,6 @@ void ride_construction_toolupdate_construct(const ScreenCoordsXY& screenCoords) */ void ride_construction_toolupdate_entrance_exit(const ScreenCoordsXY& screenCoords) { - uint8_t stationNum; - map_invalidate_selection_rect(); map_invalidate_map_selection_tiles(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; @@ -3686,7 +3684,7 @@ void ride_construction_toolupdate_entrance_exit(const ScreenCoordsXY& screenCoor map_invalidate_selection_rect(); entranceOrExitCoords.direction = direction_reverse(gRideEntranceExitPlaceDirection); - stationNum = gRideEntranceExitPlaceStationIndex; + StationIndex stationNum = gRideEntranceExitPlaceStationIndex; if (!(_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT) || entranceOrExitCoords != gRideEntranceExitGhostPosition || stationNum != gRideEntranceExitGhostStationIndex) { diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp index 417e54599f..37b5e5271a 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp @@ -24,13 +24,14 @@ private: CoordsXY _loc; Direction _direction; NetworkRideId_t _rideIndex; - uint8_t _stationNum; + StationIndex _stationNum; bool _isExit; public: RideEntranceExitPlaceAction() = default; - RideEntranceExitPlaceAction(const CoordsXY& loc, Direction direction, ride_id_t rideIndex, uint8_t stationNum, bool isExit) + RideEntranceExitPlaceAction( + const CoordsXY& loc, Direction direction, ride_id_t rideIndex, StationIndex stationNum, bool isExit) : _loc(loc) , _direction(direction) , _rideIndex(rideIndex) diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.hpp b/src/openrct2/actions/RideEntranceExitRemoveAction.hpp index 7b67003f08..418c802791 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.hpp +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.hpp @@ -19,13 +19,13 @@ DEFINE_GAME_ACTION(RideEntranceExitRemoveAction, GAME_COMMAND_REMOVE_RIDE_ENTRAN private: CoordsXY _loc; NetworkRideId_t _rideIndex; - uint8_t _stationNum; + StationIndex _stationNum; bool _isExit; public: RideEntranceExitRemoveAction() = default; - RideEntranceExitRemoveAction(const CoordsXY& loc, ride_id_t rideIndex, uint8_t stationNum, bool isExit) + RideEntranceExitRemoveAction(const CoordsXY& loc, ride_id_t rideIndex, StationIndex stationNum, bool isExit) : _loc(loc) , _rideIndex(rideIndex) , _stationNum(stationNum) diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index e4ec636326..cd6c586b92 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -4174,7 +4174,7 @@ void Guest::UpdateRideLeaveVehicle() break; } - uint8_t stationIndex = inner_map->AsTrack()->GetStationIndex(); + auto stationIndex = inner_map->AsTrack()->GetStationIndex(); if (stationIndex == current_ride_station) break; } @@ -4260,7 +4260,7 @@ void Guest::UpdateRideLeaveVehicle() TileElement* trackElement = ride_get_station_start_track_element(ride, current_ride_station); - uint8_t station_direction = (trackElement == nullptr ? 0 : trackElement->GetDirection()); + Direction station_direction = (trackElement == nullptr ? 0 : trackElement->GetDirection()); vehicle = GET_VEHICLE(ride->vehicles[current_train]); diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index f6673e3b9b..ff30e5c2f8 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -1839,6 +1839,44 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) loc.z = tileElement->base_height; } +/* + * If a ride has multiple entrance stations and is set to sync with + * adjacent stations, cycle through the entrance stations (based on + * number of rides the peep has been on) so the peep will try the + * different sections of the ride. + * In this case, the ride's various entrance stations will typically, + * though not necessarily, be adjacent to one another and consequently + * not too far for the peep to walk when cycling between them. + * Note: the same choice of station must made while the peep navigates + * to the station. Consequently a truly random station selection here is not + * appropriate. + */ +static StationIndex guest_pathfinding_select_random_station( + const Guest* guest, int32_t numEntranceStations, std::bitset& entranceStations) +{ + int32_t select = guest->no_of_rides % numEntranceStations; + while (select > 0) + { + for (StationIndex i = 0; i < MAX_STATIONS; i++) + { + if (entranceStations[i]) + { + entranceStations[i] = false; + select--; + break; + } + } + } + for (StationIndex i = 0; i < MAX_STATIONS; i++) + { + if (entranceStations[i]) + { + return i; + } + } + + return 0; +} /** * * rct2: 0x00694C35 @@ -2051,19 +2089,19 @@ int32_t guest_path_finding(Guest* peep) * At the same time, count how many entrance stations there are and * which stations are entrance stations. */ auto bestScore = std::numeric_limits::max(); - uint8_t closestStationNum = 0; + StationIndex closestStationNum = 0; int32_t numEntranceStations = 0; - uint8_t entranceStations = 0; + std::bitset entranceStations = {}; - for (uint8_t stationNum = 0; stationNum < MAX_STATIONS; ++stationNum) + for (StationIndex stationNum = 0; stationNum < MAX_STATIONS; ++stationNum) { // Skip if stationNum has no entrance (so presumably an exit only station) if (ride_get_entrance_location(ride, stationNum).isNull()) continue; numEntranceStations++; - entranceStations |= (1 << stationNum); + entranceStations[stationNum] = true; TileCoordsXYZD entranceLocation = ride_get_entrance_location(ride, stationNum); auto score = CalculateHeuristicPathingScore(entranceLocation, TileCoordsXYZ{ peep->NextLoc }); @@ -2079,26 +2117,9 @@ int32_t guest_path_finding(Guest* peep) if (numEntranceStations == 0) closestStationNum = 0; - /* If a ride has multiple entrance stations and is set to sync with - * adjacent stations, cycle through the entrance stations (based on - * number of rides the peep has been on) so the peep will try the - * different sections of the ride. - * In this case, the ride's various entrance stations will typically, - * though not necessarily, be adjacent to one another and consequently - * not too far for the peep to walk when cycling between them. - * Note: the same choice of station must made while the peep navigates - * to the station. Consequently a random station selection here is not - * appropriate. */ if (numEntranceStations > 1 && (ride->depart_flags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS)) { - int32_t select = peep->no_of_rides % numEntranceStations; - while (select > 0) - { - closestStationNum = bitscanforward(entranceStations); - entranceStations &= ~(1 << closestStationNum); - select--; - } - closestStationNum = bitscanforward(entranceStations); + closestStationNum = guest_pathfinding_select_random_station(peep, numEntranceStations, entranceStations); } if (numEntranceStations == 0) diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 1af65055b9..4940b4cd2e 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2404,7 +2404,7 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl } peep->time_lost = 0; - uint8_t stationNum = tile_element->AsEntrance()->GetStationIndex(); + auto stationNum = tile_element->AsEntrance()->GetStationIndex(); // Guest walks up to the ride for the first time since entering // the path tile or since considering another ride attached to // the path tile. @@ -2831,7 +2831,7 @@ static void peep_interact_with_path(Peep* peep, int16_t x, int16_t y, TileElemen { // Peep is not queuing. peep->time_lost = 0; - uint8_t stationNum = tile_element->AsPath()->GetStationIndex(); + auto stationNum = tile_element->AsPath()->GetStationIndex(); if ((tile_element->AsPath()->HasQueueBanner()) && (tile_element->AsPath()->GetQueueBannerDirection() diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index b4d5d051be..fd0f2ca8c9 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -582,7 +582,7 @@ struct Peep : SpriteBase uint8_t photo3_ride_ref; uint8_t photo4_ride_ref; uint8_t current_ride; - uint8_t current_ride_station; + StationIndex current_ride_station; uint8_t current_train; union { diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 18e464654a..aff8d6d7f7 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -2441,7 +2441,7 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride) return true; } - uint8_t stationDirection = 0; + Direction stationDirection = 0; track_begin_end trackBeginEnd; while (track_block_get_previous(input.x, input.y, input.element, &trackBeginEnd)) { diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index fdef426d18..2e0ad9c282 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -116,7 +116,7 @@ CoordsXYZD _unkF440C5; uint8_t gRideEntranceExitPlaceType; ride_id_t gRideEntranceExitPlaceRideIndex; -uint8_t gRideEntranceExitPlaceStationIndex; +StationIndex gRideEntranceExitPlaceStationIndex; uint8_t gRideEntranceExitPlacePreviousRideConstructionState; Direction gRideEntranceExitPlaceDirection; @@ -266,7 +266,7 @@ int32_t Ride::GetMaxQueueTime() const return (int32_t)queueTime; } -Peep* Ride::GetQueueHeadGuest(int32_t stationIndex) const +Peep* Ride::GetQueueHeadGuest(StationIndex stationIndex) const { Peep* peep; Peep* result = nullptr; @@ -279,7 +279,7 @@ Peep* Ride::GetQueueHeadGuest(int32_t stationIndex) const return result; } -void Ride::UpdateQueueLength(int32_t stationIndex) +void Ride::UpdateQueueLength(StationIndex stationIndex) { uint16_t count = 0; Peep* peep; @@ -292,7 +292,7 @@ void Ride::UpdateQueueLength(int32_t stationIndex) stations[stationIndex].QueueLength = count; } -void Ride::QueueInsertGuestAtFront(int32_t stationIndex, Peep* peep) +void Ride::QueueInsertGuestAtFront(StationIndex stationIndex, Peep* peep) { assert(stationIndex < MAX_STATIONS); assert(peep != nullptr); @@ -1680,7 +1680,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement) if (entranceType != ENTRANCE_TYPE_RIDE_ENTRANCE && entranceType != ENTRANCE_TYPE_RIDE_EXIT) return false; - int32_t stationIndex = entranceElement->GetStationIndex(); + auto stationIndex = entranceElement->GetStationIndex(); // Get or create construction window for ride auto constructionWindow = window_find_by_class(WC_RIDE_CONSTRUCTION); @@ -2638,7 +2638,7 @@ static void ride_call_closest_mechanic(Ride* ride) Peep* ride_find_closest_mechanic(Ride* ride, int32_t forInspection) { // Get either exit position or entrance position if there is no exit - int32_t stationIndex = ride->inspection_station; + auto stationIndex = ride->inspection_station; TileCoordsXYZD location = ride_get_exit_location(ride, stationIndex); if (location.isNull()) { @@ -3729,14 +3729,14 @@ money32 set_operating_setting_nested(ride_id_t rideId, RideSetSetting setting, u * * rct2: 0x006B4CC1 */ -static int32_t ride_mode_check_valid_station_numbers(Ride* ride) +static StationIndex ride_mode_check_valid_station_numbers(Ride* ride) { - uint8_t no_stations = 0; - for (uint8_t station_index = 0; station_index < MAX_STATIONS; ++station_index) + uint16_t numStations = 0; + for (StationIndex stationIndex = 0; stationIndex < MAX_STATIONS; ++stationIndex) { - if (!ride->stations[station_index].Start.isNull()) + if (!ride->stations[stationIndex].Start.isNull()) { - no_stations++; + numStations++; } } @@ -3746,12 +3746,12 @@ static int32_t ride_mode_check_valid_station_numbers(Ride* ride) case RIDE_MODE_POWERED_LAUNCH_PASSTROUGH: case RIDE_MODE_POWERED_LAUNCH: case RIDE_MODE_LIM_POWERED_LAUNCH: - if (no_stations <= 1) + if (numStations <= 1) return 1; gGameCommandErrorText = STR_UNABLE_TO_OPERATE_WITH_MORE_THAN_ONE_STATION_IN_THIS_MODE; return 0; case RIDE_MODE_SHUTTLE: - if (no_stations >= 2) + if (numStations >= 2) return 1; gGameCommandErrorText = STR_UNABLE_TO_OPERATE_WITH_LESS_THAN_TWO_STATIONS_IN_THIS_MODE; return 0; @@ -3759,7 +3759,7 @@ static int32_t ride_mode_check_valid_station_numbers(Ride* ride) if (ride->type == RIDE_TYPE_GO_KARTS || ride->type == RIDE_TYPE_MINI_GOLF) { - if (no_stations <= 1) + if (numStations <= 1) return 1; gGameCommandErrorText = STR_UNABLE_TO_OPERATE_WITH_MORE_THAN_ONE_STATION_IN_THIS_MODE; return 0; @@ -4821,8 +4821,7 @@ void loc_6DDF9C(Ride* ride, TileElement* tileElement) static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying) { CoordsXYZ location; - int32_t stationIndex; - for (stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) + for (StationIndex stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) { location = ride->stations[stationIndex].GetStart(); if (!location.isNull()) @@ -5098,7 +5097,6 @@ static TileElement* loc_6B4F6B(ride_id_t rideIndex, int32_t x, int32_t y) int32_t ride_is_valid_for_test(Ride* ride, int32_t status, bool isApplying) { - int32_t stationIndex; CoordsXYE trackElement, problematicTrackElement = {}; if (ride->type == RIDE_TYPE_NULL) @@ -5112,8 +5110,8 @@ int32_t ride_is_valid_for_test(Ride* ride, int32_t status, bool isApplying) window_close_by_number(WC_RIDE_CONSTRUCTION, ride->id); } - stationIndex = ride_mode_check_station_present(ride); - if (stationIndex == -1) + StationIndex stationIndex = ride_mode_check_station_present(ride); + if (stationIndex == STATION_INDEX_NULL) return 0; if (!ride_mode_check_valid_station_numbers(ride)) @@ -5238,7 +5236,6 @@ int32_t ride_is_valid_for_test(Ride* ride, int32_t status, bool isApplying) */ int32_t ride_is_valid_for_open(Ride* ride, int32_t goingToBeOpen, bool isApplying) { - int32_t stationIndex; CoordsXYE trackElement, problematicTrackElement = {}; // Check to see if construction tool is in use. If it is close the construction window @@ -5249,8 +5246,8 @@ int32_t ride_is_valid_for_open(Ride* ride, int32_t goingToBeOpen, bool isApplyin && (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))) window_close_by_number(WC_RIDE_CONSTRUCTION, ride->id); - stationIndex = ride_mode_check_station_present(ride); - if (stationIndex == -1) + StationIndex stationIndex = ride_mode_check_station_present(ride); + if (stationIndex == STATION_INDEX_NULL) return 0; if (!ride_mode_check_valid_station_numbers(ride)) @@ -6794,7 +6791,7 @@ void sub_6CB945(Ride* ride) { if (ride->type != RIDE_TYPE_MAZE) { - for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId) + for (StationIndex stationId = 0; stationId < MAX_STATIONS; ++stationId) { if (ride->stations[stationId].Start.isNull()) continue; @@ -6887,7 +6884,7 @@ void sub_6CB945(Ride* ride) } std::vector locations; - for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId) + for (StationIndex stationId = 0; stationId < MAX_STATIONS; ++stationId) { auto entrance = ride_get_entrance_location(ride, stationId); if (!entrance.isNull()) @@ -6966,7 +6963,7 @@ void sub_6CB945(Ride* ride) continue; } - uint8_t stationId = 0; + StationIndex stationId = 0; if (trackType != TRACK_ELEM_MAZE) { stationId = trackElement->AsTrack()->GetStationIndex(); @@ -7250,13 +7247,13 @@ bool ride_has_adjacent_station(Ride* ride) /* Loop through all of the ride stations, checking for an * adjacent station on either side. */ - for (int32_t stationNum = 0; stationNum < MAX_STATIONS; stationNum++) + for (StationIndex stationNum = 0; stationNum < MAX_STATIONS; stationNum++) { auto stationStart = ride->stations[stationNum].Start; if (!stationStart.isNull()) { /* Get the map element for the station start. */ - uint8_t stationZ = ride->stations[stationNum].Height; + auto stationZ = ride->stations[stationNum].Height; TileElement* stationElement = get_station_platform(stationStart.x, stationStart.y, stationZ, 0); if (stationElement == nullptr) @@ -7542,7 +7539,7 @@ void determine_ride_entrance_and_exit_locations() for (auto& ride : GetRideManager()) { - for (int32_t stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) + for (StationIndex stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) { TileCoordsXYZD entranceLoc = ride.stations[stationIndex].Entrance; TileCoordsXYZD exitLoc = ride.stations[stationIndex].Exit; diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index c18cc9252a..bac8e8f497 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -332,7 +332,7 @@ struct Ride uint8_t breakdown_reason_pending; uint8_t mechanic_status; uint16_t mechanic; - uint8_t inspection_station; + StationIndex inspection_station; uint8_t broken_vehicle; uint8_t broken_car; uint8_t breakdown_reason; @@ -393,7 +393,7 @@ private: void Update(); void UpdateChairlift(); void UpdateSpiralSlide(); - void UpdateQueueLength(int32_t stationIndex); + void UpdateQueueLength(StationIndex stationIndex); money32 CalculateIncomePerHour() const; public: @@ -434,8 +434,8 @@ public: int32_t GetTotalQueueLength() const; int32_t GetMaxQueueTime() const; - void QueueInsertGuestAtFront(int32_t stationIndex, Peep* peep); - Peep* GetQueueHeadGuest(int32_t stationIndex) const; + void QueueInsertGuestAtFront(StationIndex stationIndex, Peep* peep); + Peep* GetQueueHeadGuest(StationIndex stationIndex) const; void SetNameToDefault(); std::string GetName() const; @@ -1118,7 +1118,7 @@ extern CoordsXYZD _unkF440C5; extern uint8_t gRideEntranceExitPlaceType; extern ride_id_t gRideEntranceExitPlaceRideIndex; -extern uint8_t gRideEntranceExitPlaceStationIndex; +extern StationIndex gRideEntranceExitPlaceStationIndex; extern uint8_t gRideEntranceExitPlacePreviousRideConstructionState; extern uint8_t gRideEntranceExitPlaceDirection; @@ -1215,7 +1215,7 @@ void ride_get_start_of_track(CoordsXYE* output); void window_ride_construction_update_active_elements(); void ride_construction_remove_ghosts(); money32 ride_entrance_exit_place_ghost( - Ride* ride, const CoordsXY& entranceExitCoords, int32_t direction, int32_t placeType, int32_t stationNum); + Ride* ride, const CoordsXY& entranceExitCoords, Direction direction, int32_t placeType, StationIndex stationNum); CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(const ScreenCoordsXY& screenCoords); bool ride_select_backwards_from_front(); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 5ee993a06f..f14efe1d70 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -255,7 +255,7 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride) // First entrances, second exits for (int32_t i = 0; i < 2; i++) { - for (int32_t station_index = 0; station_index < RCT12_MAX_STATIONS_PER_RIDE; station_index++) + for (StationIndex station_index = 0; station_index < RCT12_MAX_STATIONS_PER_RIDE; station_index++) { z = ride.stations[station_index].GetBaseZ(); @@ -1685,7 +1685,7 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1 continue; } - int32_t stationIndex = tile_element->AsTrack()->GetStationIndex(); + auto stationIndex = tile_element->AsTrack()->GetStationIndex(); uint8_t flags = GAME_COMMAND_FLAG_APPLY; if (_trackDesignPlaceOperation == PTD_OPERATION_PLACE_TRACK_PREVIEW) { diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 98e11b1006..d9b03c6d9d 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -2693,7 +2693,7 @@ static void vehicle_update_waiting_to_depart(Vehicle* vehicle) struct rct_synchronised_vehicle { ride_id_t ride_id; - uint8_t station_id; + StationIndex stationIndex; uint16_t vehicle_id; }; @@ -2737,11 +2737,11 @@ static bool try_add_synchronised_station(int32_t x, int32_t y, int32_t z) * to sync with adjacent stations, so it will return true. * Still to determine if a vehicle to sync can be identified. */ - int32_t stationIndex = tileElement->AsTrack()->GetStationIndex(); + auto stationIndex = tileElement->AsTrack()->GetStationIndex(); rct_synchronised_vehicle* sv = _lastSynchronisedVehicle; sv->ride_id = rideIndex; - sv->station_id = stationIndex; + sv->stationIndex = stationIndex; sv->vehicle_id = SPRITE_INDEX_NULL; _lastSynchronisedVehicle++; @@ -2814,7 +2814,7 @@ static bool vehicle_can_depart_synchronised(Vehicle* vehicle) if (ride == nullptr) return false; - int32_t station = vehicle->current_station; + StationIndex station = vehicle->current_station; auto location = ride->stations[station].GetStart(); int32_t x = location.x; int32_t y = location.y; @@ -2892,7 +2892,7 @@ static bool vehicle_can_depart_synchronised(Vehicle* vehicle) { if (sv_ride->IsBlockSectioned()) { - if (!(sv_ride->stations[sv->station_id].Depart & STATION_DEPART_FLAG)) + if (!(sv_ride->stations[sv->stationIndex].Depart & STATION_DEPART_FLAG)) { sv = _synchronisedVehicles; uint8_t rideId = RIDE_ID_NULL; @@ -2947,7 +2947,7 @@ static bool vehicle_can_depart_synchronised(Vehicle* vehicle) int32_t numTrainsAtStation = 0; int32_t numTravelingTrains = 0; - int32_t currentStation = sv->station_id; + auto currentStation = sv->stationIndex; for (int32_t i = 0; i < sv_ride->num_vehicles; i++) { uint16_t spriteIndex = sv_ride->vehicles[i]; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index c76efbd2d0..719c134aba 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -15,6 +15,7 @@ #include "../ride/RideTypes.h" #include "../world/Location.hpp" #include "../world/SpriteBase.h" +#include "Station.h" #include #include @@ -212,7 +213,7 @@ struct Vehicle : SpriteBase uint16_t mass; uint16_t update_flags; uint8_t swing_sprite; - uint8_t current_station; + StationIndex current_station; union { int16_t swinging_car_var_0; diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 9c1da3815f..9ee2fad5e3 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -33,10 +33,10 @@ CoordsXYZD gParkEntranceGhostPosition = { 0, 0, 0, 0 }; std::vector gParkEntrances; CoordsXYZD gRideEntranceExitGhostPosition; -uint8_t gRideEntranceExitGhostStationIndex; +StationIndex gRideEntranceExitGhostStationIndex; static money32 RideEntranceExitPlaceGhost( - ride_id_t rideIndex, const CoordsXY& entranceExitCoords, uint8_t direction, uint8_t placeType, uint8_t stationNum) + ride_id_t rideIndex, const CoordsXY& entranceExitCoords, Direction direction, uint8_t placeType, StationIndex stationNum) { auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction( entranceExitCoords, direction, rideIndex, stationNum, placeType == ENTRANCE_TYPE_RIDE_EXIT); @@ -108,7 +108,7 @@ void ride_entrance_exit_remove_ghost() * rct2: 0x006CA28C */ money32 ride_entrance_exit_place_ghost( - Ride* ride, const CoordsXY& entranceExitCoords, int32_t direction, int32_t placeType, int32_t stationNum) + Ride* ride, const CoordsXY& entranceExitCoords, Direction direction, int32_t placeType, StationIndex stationNum) { ride_construction_remove_ghosts(); money32 result = RideEntranceExitPlaceGhost(ride->id, entranceExitCoords, direction, placeType, stationNum); @@ -119,7 +119,7 @@ money32 ride_entrance_exit_place_ghost( gRideEntranceExitGhostPosition.x = entranceExitCoords.x; gRideEntranceExitGhostPosition.y = entranceExitCoords.y; gRideEntranceExitGhostPosition.direction = direction; - gRideEntranceExitGhostStationIndex = stationNum & 0xFF; + gRideEntranceExitGhostStationIndex = stationNum; } return result; } diff --git a/src/openrct2/world/Entrance.h b/src/openrct2/world/Entrance.h index 8eace218b8..9413916a4b 100644 --- a/src/openrct2/world/Entrance.h +++ b/src/openrct2/world/Entrance.h @@ -43,7 +43,7 @@ constexpr int32_t MaxRideEntranceOrExitHeight = 244 * COORDS_Z_STEP; extern std::vector gParkEntrances; extern CoordsXYZD gRideEntranceExitGhostPosition; -extern uint8_t gRideEntranceExitGhostStationIndex; +extern StationIndex gRideEntranceExitGhostStationIndex; void park_entrance_remove_ghost(); money32 park_entrance_place_ghost(const CoordsXYZD& entranceLoc); diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 8b926a1389..9533df8bf0 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1502,7 +1502,7 @@ void PathElement::SetIsBlockedByVehicle(bool isBlocked) } } -uint8_t PathElement::GetStationIndex() const +::StationIndex PathElement::GetStationIndex() const { return StationIndex; } diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 38afeca016..6331118f4e 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -689,7 +689,7 @@ GameActionResult::Ptr tile_inspector_entrance_make_usable(const CoordsXY& loc, i if (isExecuting) { - uint8_t stationIndex = entranceElement->AsEntrance()->GetStationIndex(); + auto stationIndex = entranceElement->AsEntrance()->GetStationIndex(); switch (entranceElement->AsEntrance()->GetEntranceType()) {