diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 010d69d513..73410ab600 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1406,7 +1406,7 @@ rct_window* WindowRideOpenVehicle(Vehicle* vehicle) // Get view index int32_t view = 1; - for (int32_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++) + for (int32_t i = 0; i <= OpenRCT2::Limits::MaxTrainsPerRide; i++) { if (ride->vehicles[i] == headVehicleSpriteIndex) break; @@ -2747,7 +2747,7 @@ static void WindowRideVehicleMousedown(rct_window* w, rct_widgetindex widgetInde WindowRideShowVehicleTypeDropdown(w, &w->widgets[widgetIndex]); break; case WIDX_VEHICLE_TRAINS_INCREASE: - if (ride->num_vehicles < MAX_VEHICLES_PER_RIDE) + if (ride->num_vehicles < OpenRCT2::Limits::MaxTrainsPerRide) ride->SetNumVehicles(ride->num_vehicles + 1); break; case WIDX_VEHICLE_TRAINS_DECREASE: @@ -2755,7 +2755,7 @@ static void WindowRideVehicleMousedown(rct_window* w, rct_widgetindex widgetInde ride->SetNumVehicles(ride->num_vehicles - 1); break; case WIDX_VEHICLE_CARS_PER_TRAIN_INCREASE: - if (ride->num_cars_per_train < MAX_CARS_PER_TRAIN) + if (ride->num_cars_per_train < OpenRCT2::Limits::MaxCarsPerTrain) ride->SetNumCarsPerVehicle(ride->num_cars_per_train + 1); break; case WIDX_VEHICLE_CARS_PER_TRAIN_DECREASE: @@ -3350,13 +3350,13 @@ static void WindowRideOperatingMousedown(rct_window* w, rct_widgetindex widgetIn WindowRideLoadDropdown(w, widget); break; case WIDX_OPERATE_NUMBER_OF_CIRCUITS_INCREASE: - upper_bound = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE; + upper_bound = gCheatsUnlockOperatingLimits ? 255 : OpenRCT2::Limits::MaxCircuitsPerRide; lower_bound = 1; set_operating_setting( rideId, RideSetSetting::NumCircuits, std::clamp(ride->num_circuits + 1, lower_bound, upper_bound)); break; case WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE: - upper_bound = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE; + upper_bound = gCheatsUnlockOperatingLimits ? 255 : OpenRCT2::Limits::MaxCircuitsPerRide; lower_bound = 1; set_operating_setting( rideId, RideSetSetting::NumCircuits, std::clamp(ride->num_circuits - 1, lower_bound, upper_bound)); @@ -4329,7 +4329,7 @@ static void WindowRideColourMousedown(rct_window* w, rct_widgetindex widgetIndex switch (widgetIndex) { case WIDX_TRACK_COLOUR_SCHEME_DROPDOWN: - for (i = 0; i < NUM_COLOUR_SCHEMES; i++) + for (i = 0; i < OpenRCT2::Limits::NumColourSchemes; i++) { gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL; gDropdownItemsArgs[i] = ColourSchemeNames[i]; diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index bb37608844..ac1dc210b9 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -359,7 +359,7 @@ void game_fix_save_vars() // Fix possibly invalid field values for (auto peep : EntityList()) { - if (peep->CurrentRideStation >= MAX_STATIONS) + if (peep->CurrentRideStation >= OpenRCT2::Limits::MaxStationsPerRide) { const auto srcStation = peep->CurrentRideStation; const auto rideIdx = peep->CurrentRide; diff --git a/src/openrct2/Limits.h b/src/openrct2/Limits.h new file mode 100644 index 0000000000..9b2feb2dd0 --- /dev/null +++ b/src/openrct2/Limits.h @@ -0,0 +1,30 @@ +/***************************************************************************** + * Copyright (c) 2014-2022 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once +#include "rct2/Limits.h" + +namespace OpenRCT2::Limits +{ + constexpr const uint16_t MaxRidesInPark = 1000; + constexpr const uint16_t MaxStationsPerRide = 255; + constexpr const uint8_t CustomerHistorySize = RCT12::Limits::CustomerHistorySize; + constexpr const uint16_t MaxGolfHoles = RCT12::Limits::MaxGolfHoles; + constexpr const uint16_t MaxHelices = RCT12::Limits::MaxHelices; + constexpr const uint16_t MaxInversions = RCT12::Limits::MaxInversions; + constexpr const uint16_t MaxTrainsPerRide = 255; + constexpr const uint16_t MaxCarsPerTrain = 255; + constexpr const uint16_t MaxVehicleColours = MaxTrainsPerRide; // this should really be MaxTrainsPerRide * MaxCarsPerTrain + constexpr const uint8_t MaxCircuitsPerRide = 20; + constexpr const uint8_t MaxAwards = RCT12::Limits::MaxAwards; + constexpr const uint8_t NumColourSchemes = RCT12::Limits::NumColourSchemes; + constexpr const uint8_t DowntimeHistorySize = RCT2::Limits::DowntimeHistorySize; + constexpr const uint16_t MaxPeepSpawns = 256; + constexpr const uint16_t MaxParkEntrances = 256; +} // namespace OpenRCT2::Limits diff --git a/src/openrct2/actions/PlaceParkEntranceAction.cpp b/src/openrct2/actions/PlaceParkEntranceAction.cpp index 9b1498355a..8f7823772d 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.cpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.cpp @@ -64,7 +64,7 @@ GameActions::Result PlaceParkEntranceAction::Query() const GameActions::Status::NoFreeElements, STR_CANT_BUILD_THIS_HERE, STR_ERR_LANDSCAPE_DATA_AREA_FULL); } - if (gParkEntrances.size() >= MAX_PARK_ENTRANCES) + if (gParkEntrances.size() >= OpenRCT2::Limits::MaxParkEntrances) { return GameActions::Result( GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES); diff --git a/src/openrct2/actions/PlacePeepSpawnAction.cpp b/src/openrct2/actions/PlacePeepSpawnAction.cpp index 4d4eb85701..140967d7b7 100644 --- a/src/openrct2/actions/PlacePeepSpawnAction.cpp +++ b/src/openrct2/actions/PlacePeepSpawnAction.cpp @@ -113,7 +113,7 @@ GameActions::Result PlacePeepSpawnAction::Execute() const } // If we have reached our max peep spawns, remove the oldest spawns - while (gPeepSpawns.size() >= MAX_PEEP_SPAWNS) + while (gPeepSpawns.size() >= OpenRCT2::Limits::MaxPeepSpawns) { PeepSpawn oldestSpawn = *gPeepSpawns.begin(); gPeepSpawns.erase(gPeepSpawns.begin()); diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/RideCreateAction.cpp index 64ed37fcd8..5c27e7502f 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/RideCreateAction.cpp @@ -138,7 +138,7 @@ GameActions::Result RideCreateAction::Execute() const ride->overall_view.SetNull(); ride->SetNameToDefault(); - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { ride->stations[i].Start.SetNull(); ride_clear_entrance_location(ride, i); @@ -158,7 +158,7 @@ GameActions::Result RideCreateAction::Execute() const ride->num_stations = 0; ride->num_vehicles = 1; ride->proposed_num_vehicles = 32; - ride->max_trains = MAX_VEHICLES_PER_RIDE; + ride->max_trains = OpenRCT2::Limits::MaxTrainsPerRide; ride->num_cars_per_train = 1; ride->proposed_num_cars_per_train = 12; ride->min_waiting_time = 10; diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp index 35ed817207..ecb6390f8e 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp @@ -59,7 +59,7 @@ GameActions::Result RideEntranceExitPlaceAction::Query() const return GameActions::Result(GameActions::Status::InvalidParameters, errorTitle, STR_NONE); } - if (_stationNum >= MAX_STATIONS) + if (_stationNum >= OpenRCT2::Limits::MaxStationsPerRide) { log_warning("Invalid station number for ride. stationNum: %u", _stationNum); return GameActions::Result(GameActions::Status::InvalidParameters, errorTitle, STR_NONE); diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 367f19e606..07561aad5d 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -255,7 +255,7 @@ bool RideSetSettingAction::ride_is_valid_lift_hill_speed(Ride* ride) const bool RideSetSettingAction::ride_is_valid_num_circuits() const { int32_t minNumCircuits = 1; - int32_t maxNumCircuits = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE; + int32_t maxNumCircuits = gCheatsUnlockOperatingLimits ? 255 : OpenRCT2::Limits::MaxCircuitsPerRide; return _value >= minNumCircuits && _value <= maxNumCircuits; } diff --git a/src/openrct2/actions/SetCheatAction.cpp b/src/openrct2/actions/SetCheatAction.cpp index 0e3941cb9c..d61d2ad1c8 100644 --- a/src/openrct2/actions/SetCheatAction.cpp +++ b/src/openrct2/actions/SetCheatAction.cpp @@ -630,7 +630,7 @@ void SetCheatAction::RemoveAllGuests() const { ride.num_riders = 0; - for (size_t stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) + for (size_t stationIndex = 0; stationIndex < OpenRCT2::Limits::MaxStationsPerRide; stationIndex++) { ride.stations[stationIndex].QueueLength = 0; ride.stations[stationIndex].LastPeepInQueue = SPRITE_INDEX_NULL; diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index 4218e57255..a6cd6017eb 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -257,7 +257,7 @@ GameActions::Result TrackDesignAction::Execute() const ride->track_colour[i].supports = _td.track_support_colour[i]; } - for (size_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++) + for (size_t i = 0; i <= OpenRCT2::Limits::MaxTrainsPerRide; i++) { auto tdIndex = i % std::size(_td.vehicle_colours); ride->vehicle_colours[i].Body = _td.vehicle_colours[tdIndex].body_colour; diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 3db0c7af3f..6c265a488d 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -1856,9 +1856,9 @@ Ride* Guest::FindBestRideToGoOn() return mostExcitingRide; } -BitSet Guest::FindRidesToGoOn() +BitSet Guest::FindRidesToGoOn() { - BitSet rideConsideration; + BitSet rideConsideration; // FIX Originally checked for a toy, likely a mistake and should be a map, // but then again this seems to only allow the peep to go on @@ -2540,7 +2540,7 @@ bool Guest::FindVehicleToEnter(Ride* ride, std::vector& car_array) { chosen_train = ride->stations[CurrentRideStation].TrainAtStation; } - if (chosen_train >= MAX_VEHICLES_PER_RIDE) + if (chosen_train >= OpenRCT2::Limits::MaxTrainsPerRide) { return false; } @@ -3112,7 +3112,7 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co } } - BitSet rideConsideration; + BitSet rideConsideration; if (!considerOnlyCloseRides && (peep->HasItem(ShopItem::Map))) { // Consider all rides in the park @@ -3155,7 +3155,7 @@ template static void peep_head_for_nearest_ride(Guest* peep, bool co } // Filter the considered rides - ride_id_t potentialRides[MAX_RIDES]; + ride_id_t potentialRides[OpenRCT2::Limits::MaxRidesInPark]; size_t numPotentialRides = 0; for (auto& ride : GetRideManager()) { @@ -3755,7 +3755,7 @@ static void peep_go_to_ride_exit(Peep* peep, Ride* ride, int16_t x, int16_t y, i peep->MoveTo({ x, y, z }); - Guard::Assert(peep->CurrentRideStation < MAX_STATIONS); + Guard::Assert(peep->CurrentRideStation < OpenRCT2::Limits::MaxStationsPerRide); auto exit = ride_get_exit_location(ride, peep->CurrentRideStation); Guard::Assert(!exit.IsNull()); x = exit.x; @@ -4092,7 +4092,7 @@ void Guest::UpdateRideLeaveVehicle() vehicle->ApplyMass(-Mass); vehicle->Invalidate(); - if (ride_station >= MAX_STATIONS) + if (ride_station >= OpenRCT2::Limits::MaxStationsPerRide) { // HACK #5658: Some parks have hacked rides which end up in this state auto bestStationIndex = ride_get_first_valid_station_exit(ride); @@ -4113,7 +4113,7 @@ void Guest::UpdateRideLeaveVehicle() if (!(vehicle_entry->flags & VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS)) { - assert(CurrentRideStation < MAX_STATIONS); + assert(CurrentRideStation < OpenRCT2::Limits::MaxStationsPerRide); TileCoordsXYZD exitLocation = ride_get_exit_location(ride, CurrentRideStation); CoordsXYZD platformLocation; platformLocation.z = ride->stations[CurrentRideStation].GetBaseZ(); diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index c4e3e531df..c5cba093fd 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -418,7 +418,7 @@ private: void MakePassingPeepsSick(Guest* passingPeep); void GivePassingPeepsIceCream(Guest* passingPeep); Ride* FindBestRideToGoOn(); - OpenRCT2::BitSet FindRidesToGoOn(); + OpenRCT2::BitSet FindRidesToGoOn(); bool FindVehicleToEnter(Ride* ride, std::vector& car_array); void GoToRideEntrance(Ride* ride); }; diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 8ea4dd576e..bb18e60915 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1285,7 +1285,7 @@ static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] cons console.WriteFormatLine("Sprites: %d/%d", spriteCount, MAX_ENTITIES); console.WriteFormatLine("Map Elements: %zu/%d", tileElementCount, MAX_TILE_ELEMENTS); console.WriteFormatLine("Banners: %d/%zu", bannerCount, MAX_BANNERS); - console.WriteFormatLine("Rides: %d/%d", rideCount, MAX_RIDES); + console.WriteFormatLine("Rides: %d/%d", rideCount, OpenRCT2::Limits::MaxRidesInPark); console.WriteFormatLine("Images: %zu/%zu", ImageListGetUsedCount(), ImageListGetMaximum()); return 0; } diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 2edd07fd24..ec9bcc3eb0 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -239,6 +239,7 @@ + diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index b8d19438f5..6ab9198163 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -616,7 +616,7 @@ void award_update_all() } // Check if there was a free award entry - if (_currentAwards.size() < MAX_AWARDS) + if (_currentAwards.size() < OpenRCT2::Limits::MaxAwards) { // Get a random award type not already active AwardType awardType; diff --git a/src/openrct2/management/Award.h b/src/openrct2/management/Award.h index 98e93d0920..3e45d13ae4 100644 --- a/src/openrct2/management/Award.h +++ b/src/openrct2/management/Award.h @@ -42,8 +42,6 @@ struct Award AwardType Type; }; -#define MAX_AWARDS 4 - std::vector& GetAwards(); bool award_is_positive(AwardType type); diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 0d083551f4..ca1840f6d3 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -707,7 +707,7 @@ namespace OpenRCT2 // Awards if (version <= 6) { - Award awards[MAX_AWARDS]; + Award awards[RCT2::Limits::MaxAwards]; cs.ReadWriteArray(awards, [&cs](Award& award) { if (award.Time != 0) { diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 97b59a1d4c..782988c029 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -1943,12 +1943,12 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) * appropriate. */ static StationIndex guest_pathfinding_select_random_station( - const Guest* guest, int32_t numEntranceStations, BitSet& entranceStations) + const Guest* guest, int32_t numEntranceStations, BitSet& entranceStations) { int32_t select = guest->GuestNumRides % numEntranceStations; while (select > 0) { - for (StationIndex i = 0; i < MAX_STATIONS; i++) + for (StationIndex i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (entranceStations[i]) { @@ -1958,7 +1958,7 @@ static StationIndex guest_pathfinding_select_random_station( } } } - for (StationIndex i = 0; i < MAX_STATIONS; i++) + for (StationIndex i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (entranceStations[i]) { @@ -2181,9 +2181,9 @@ int32_t guest_path_finding(Guest* peep) StationIndex closestStationNum = 0; int32_t numEntranceStations = 0; - BitSet entranceStations = {}; + BitSet entranceStations = {}; - for (StationIndex stationNum = 0; stationNum < MAX_STATIONS; ++stationNum) + for (StationIndex stationNum = 0; stationNum < OpenRCT2::Limits::MaxStationsPerRide; ++stationNum) { // Skip if stationNum has no entrance (so presumably an exit only station) if (ride_get_entrance_location(ride, stationNum).IsNull()) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index e8118c1325..77eee6211f 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -879,7 +879,7 @@ namespace RCT1 dst->stations[i].SegmentLength = src->length[i]; } // All other values take 0 as their default. Since they're already memset to that, no need to do it again. - for (int32_t i = Limits::MaxStationsPerRide; i < MAX_STATIONS; i++) + for (int32_t i = Limits::MaxStationsPerRide; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { dst->stations[i].Start.SetNull(); dst->stations[i].TrainAtStation = RideStation::NO_TRAIN; @@ -895,7 +895,7 @@ namespace RCT1 { dst->vehicles[i] = src->vehicles[i]; } - for (int32_t i = Limits::MaxTrainsPerRide; i <= MAX_VEHICLES_PER_RIDE; i++) + for (int32_t i = Limits::MaxTrainsPerRide; i <= OpenRCT2::Limits::MaxTrainsPerRide; i++) { dst->vehicles[i] = SPRITE_INDEX_NULL; } diff --git a/src/openrct2/rct1/T4Importer.cpp b/src/openrct2/rct1/T4Importer.cpp index 50bf703be4..055f7be426 100644 --- a/src/openrct2/rct1/T4Importer.cpp +++ b/src/openrct2/rct1/T4Importer.cpp @@ -111,7 +111,7 @@ namespace RCT1 std::unique_ptr td = std::make_unique(); TD4 td4{}; _stream.Read(&td4, sizeof(TD4)); - for (int32_t i = 0; i < NUM_COLOUR_SCHEMES; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::NumColourSchemes; i++) { td->track_spine_colour[i] = RCT1::GetColour(td4.track_spine_colour_v0); td->track_rail_colour[i] = RCT1::GetColour(td4.track_rail_colour_v0); diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 978161ce48..5e8d597f58 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -715,7 +715,7 @@ namespace RCT2 dst->stations[i].QueueLength = src->queue_length[i]; } // All other values take 0 as their default. Since they're already memset to that, no need to do it again. - for (int32_t i = Limits::MaxStationsPerRide; i < MAX_STATIONS; i++) + for (int32_t i = Limits::MaxStationsPerRide; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { dst->stations[i].Start.SetNull(); dst->stations[i].TrainAtStation = RideStation::NO_TRAIN; @@ -728,7 +728,7 @@ namespace RCT2 { dst->vehicles[i] = src->vehicles[i]; } - for (int32_t i = Limits::MaxTrainsPerRide - 1; i <= MAX_VEHICLES_PER_RIDE; i++) + for (int32_t i = Limits::MaxTrainsPerRide - 1; i <= OpenRCT2::Limits::MaxTrainsPerRide; i++) { dst->vehicles[i] = SPRITE_INDEX_NULL; } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index ef9751da2a..f4c5333374 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -146,7 +146,7 @@ ride_id_t GetNextFreeRideId() break; } } - if (result >= MAX_RIDES) + if (result >= OpenRCT2::Limits::MaxRidesInPark) { return RIDE_ID_NULL; } @@ -260,7 +260,7 @@ int32_t Ride::GetAge() const int32_t Ride::GetTotalQueueLength() const { int32_t i, queueLength = 0; - for (i = 0; i < MAX_STATIONS; i++) + for (i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) if (!ride_get_entrance_location(this, i).IsNull()) queueLength += stations[i].QueueLength; return queueLength; @@ -269,7 +269,7 @@ int32_t Ride::GetTotalQueueLength() const int32_t Ride::GetMaxQueueTime() const { uint8_t i, queueTime = 0; - for (i = 0; i < MAX_STATIONS; i++) + for (i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) if (!ride_get_entrance_location(this, i).IsNull()) queueTime = std::max(queueTime, stations[i].QueueTime); return static_cast(queueTime); @@ -303,7 +303,7 @@ void Ride::UpdateQueueLength(StationIndex stationIndex) void Ride::QueueInsertGuestAtFront(StationIndex stationIndex, Guest* peep) { - assert(stationIndex < MAX_STATIONS); + assert(stationIndex < OpenRCT2::Limits::MaxStationsPerRide); assert(peep != nullptr); peep->GuestNextInQueue = SPRITE_INDEX_NULL; @@ -995,7 +995,7 @@ void Ride::Update() // Update stations if (type != RIDE_TYPE_MAZE) - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) ride_update_station(this, i); // Update financial statistics @@ -1007,7 +1007,7 @@ void Ride::Update() num_customers_timeout = 0; // Shift number of customers history, start of the array is the most recent one - for (int32_t i = CUSTOMER_HISTORY_SIZE - 1; i > 0; i--) + for (int32_t i = OpenRCT2::Limits::CustomerHistorySize - 1; i > 0; i--) { num_customers[i] = num_customers[i - 1]; } @@ -1181,7 +1181,7 @@ void Ride::UpdateSpiralSlide() const uint8_t current_rotation = get_current_rotation(); // Invalidate something related to station start - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (stations[i].Start.IsNull()) continue; @@ -1298,14 +1298,14 @@ static void ride_breakdown_update(Ride* ride) { int32_t totalDowntime = 0; - for (int32_t i = 0; i < DOWNTIME_HISTORY_SIZE; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::DowntimeHistorySize; i++) { totalDowntime += ride->downtime_history[i]; } ride->downtime = std::min(totalDowntime / 2, 100); - for (int32_t i = DOWNTIME_HISTORY_SIZE - 1; i > 0; i--) + for (int32_t i = OpenRCT2::Limits::DowntimeHistorySize - 1; i > 0; i--) { ride->downtime_history[i] = ride->downtime_history[i - 1]; } @@ -2101,7 +2101,7 @@ TrackColour ride_get_track_colour(Ride* ride, int32_t colourScheme) VehicleColour ride_get_vehicle_colour(Ride* ride, int32_t vehicleIndex) { // Prevent indexing array out of bounds - vehicleIndex = std::min(vehicleIndex, MAX_CARS_PER_TRAIN); + vehicleIndex = std::min(vehicleIndex, OpenRCT2::Limits::MaxCarsPerTrain); return ride->vehicle_colours[vehicleIndex]; } @@ -2221,7 +2221,7 @@ static bool ride_entrance_exit_is_reachable(const TileCoordsXYZD& coordinates) static void ride_entrance_exit_connected(Ride* ride) { - for (int32_t i = 0; i < MAX_STATIONS; ++i) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; ++i) { auto station_start = ride->stations[i].Start; auto entrance = ride_get_entrance_location(ride, i); @@ -2483,7 +2483,7 @@ void ride_set_map_tooltip(TileElement* tileElement) static StationIndex ride_mode_check_valid_station_numbers(Ride* ride) { uint16_t numStations = 0; - for (StationIndex stationIndex = 0; stationIndex < MAX_STATIONS; ++stationIndex) + for (StationIndex stationIndex = 0; stationIndex < OpenRCT2::Limits::MaxStationsPerRide; ++stationIndex) { if (!ride->stations[stationIndex].Start.IsNull()) { @@ -2563,7 +2563,7 @@ static int32_t ride_check_for_entrance_exit(ride_id_t rideIndex) uint8_t entrance = 0; uint8_t exit = 0; - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (ride->stations[i].Start.IsNull()) continue; @@ -2608,7 +2608,7 @@ static int32_t ride_check_for_entrance_exit(ride_id_t rideIndex) */ void Ride::ChainQueues() const { - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { auto location = ride_get_entrance_location(this, i); if (location.IsNull()) @@ -2938,11 +2938,11 @@ static void ride_set_boat_hire_return_point(Ride* ride, CoordsXYE* startElement) static void ride_set_maze_entrance_exit_points(Ride* ride) { // Needs room for an entrance and an exit per station, plus one position for the list terminator. - TileCoordsXYZD positions[(MAX_STATIONS * 2) + 1]; + TileCoordsXYZD positions[(OpenRCT2::Limits::MaxStationsPerRide * 2) + 1]; // Create a list of all the entrance and exit positions TileCoordsXYZD* position = positions; - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { const auto entrance = ride_get_entrance_location(ride, i); const auto exit = ride_get_exit_location(ride, i); @@ -3344,7 +3344,7 @@ static bool vehicle_create_trains(ride_id_t rideIndex, const CoordsXYZ& trainsPo } lastTrain = train; - for (int32_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++) + for (int32_t i = 0; i <= OpenRCT2::Limits::MaxTrainsPerRide; i++) { if (ride->vehicles[i] == SPRITE_INDEX_NULL) { @@ -3482,7 +3482,7 @@ bool Ride::CreateVehicles(const CoordsXYE& element, bool isApplying) // Initialise station departs // 006DDDD0: lifecycle_flags |= RIDE_LIFECYCLE_ON_TRACK; - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { stations[i].Depart = (stations[i].Depart & STATION_DEPART_FLAG) | 1; } @@ -3584,12 +3584,12 @@ void Ride::MoveTrainsToBlockBrakes(TrackElement* firstBlock) static bool ride_initialise_cable_lift_track(Ride* ride, bool isApplying) { CoordsXYZ location; - for (StationIndex stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) + for (StationIndex stationIndex = 0; stationIndex < OpenRCT2::Limits::MaxStationsPerRide; stationIndex++) { location = ride->stations[stationIndex].GetStart(); if (!location.IsNull()) break; - if (stationIndex == (MAX_STATIONS - 1)) + if (stationIndex == (OpenRCT2::Limits::MaxStationsPerRide - 1)) { gGameCommandErrorText = STR_CABLE_LIFT_HILL_MUST_START_IMMEDIATELY_AFTER_STATION; return false; @@ -3769,7 +3769,7 @@ void Ride::ConstructMissingEntranceOrExit() const int8_t entranceOrExit = -1; int32_t i; - for (i = 0; i < MAX_STATIONS; i++) + for (i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (stations[i].Start.IsNull()) continue; @@ -4267,7 +4267,7 @@ void Ride::SetColourPreset(uint8_t index) { colours = colourPresets->list[index]; } - for (int32_t i = 0; i < NUM_COLOUR_SCHEMES; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::NumColourSchemes; i++) { track_colour[i].main = colours.main; track_colour[i].additional = colours.additional; @@ -4745,7 +4745,7 @@ void ride_update_vehicle_colours(Ride* ride) gfx_invalidate_screen(); } - for (int32_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++) + for (int32_t i = 0; i <= OpenRCT2::Limits::MaxTrainsPerRide; i++) { int32_t carIndex = 0; VehicleColour colours = {}; @@ -4764,8 +4764,8 @@ void ride_update_vehicle_colours(Ride* ride) colours.Ternary = ride->vehicle_colours[i].Ternary; break; case RIDE_COLOUR_SCHEME_DIFFERENT_PER_CAR: - colours = ride->vehicle_colours[std::min(carIndex, MAX_CARS_PER_TRAIN - 1)]; - colours.Ternary = ride->vehicle_colours[std::min(carIndex, MAX_CARS_PER_TRAIN - 1)].Ternary; + colours = ride->vehicle_colours[std::min(carIndex, OpenRCT2::Limits::MaxCarsPerTrain - 1)]; + colours.Ternary = ride->vehicle_colours[std::min(carIndex, OpenRCT2::Limits::MaxCarsPerTrain - 1)].Ternary; break; } @@ -4917,7 +4917,7 @@ static int32_t ride_get_track_length(Ride* ride) CoordsXYZ trackStart; bool foundTrack = false; - for (int32_t i = 0; i < MAX_STATIONS && !foundTrack; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide && !foundTrack; i++) { trackStart = ride->stations[i].GetStart(); if (trackStart.IsNull()) @@ -5043,7 +5043,7 @@ void Ride::UpdateMaxVehicles() { case RideMode::ContinuousCircuitBlockSectioned: case RideMode::PoweredLaunchBlockSectioned: - maxNumTrains = std::clamp(num_stations + num_block_brakes - 1, 1, MAX_VEHICLES_PER_RIDE); + maxNumTrains = std::clamp(num_stations + num_block_brakes - 1, 1, OpenRCT2::Limits::MaxTrainsPerRide); break; case RideMode::ReverseInclineLaunchedShuttle: case RideMode::PoweredLaunchPasstrough: @@ -5075,7 +5075,7 @@ void Ride::UpdateMaxVehicles() if ((mode != RideMode::StationToStation && mode != RideMode::ContinuousCircuit) || !(GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_ALLOW_MORE_VEHICLES_THAN_STATION_FITS))) { - maxNumTrains = std::min(maxNumTrains, int32_t(MAX_VEHICLES_PER_RIDE)); + maxNumTrains = std::min(maxNumTrains, int32_t(OpenRCT2::Limits::MaxTrainsPerRide)); } else { @@ -5104,7 +5104,7 @@ void Ride::UpdateMaxVehicles() { maxNumTrains++; length += totalSpacing; - } while (maxNumTrains < MAX_VEHICLES_PER_RIDE && length < trackLength); + } while (maxNumTrains < OpenRCT2::Limits::MaxTrainsPerRide && length < trackLength); } break; } @@ -5123,7 +5123,7 @@ void Ride::UpdateMaxVehicles() if (gCheatsDisableTrainLengthLimit) { - maxNumTrains = MAX_VEHICLES_PER_RIDE; + maxNumTrains = OpenRCT2::Limits::MaxTrainsPerRide; } numVehicles = std::min(proposed_num_vehicles, static_cast(maxNumTrains)); @@ -5224,7 +5224,7 @@ uint32_t ride_customers_in_last_5_minutes(const Ride* ride) { uint32_t sum = 0; - for (int32_t i = 0; i < CUSTOMER_HISTORY_SIZE; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::CustomerHistorySize; i++) { sum += ride->num_customers[i]; } @@ -5378,7 +5378,7 @@ bool ride_has_adjacent_station(Ride* ride) /* Loop through all of the ride stations, checking for an * adjacent station on either side. */ - for (StationIndex stationNum = 0; stationNum < MAX_STATIONS; stationNum++) + for (StationIndex stationNum = 0; stationNum < OpenRCT2::Limits::MaxStationsPerRide; stationNum++) { auto stationStart = ride->stations[stationNum].GetStart(); if (!stationStart.IsNull()) @@ -5547,7 +5547,7 @@ void determine_ride_entrance_and_exit_locations() for (auto& ride : GetRideManager()) { - for (StationIndex stationIndex = 0; stationIndex < MAX_STATIONS; stationIndex++) + for (StationIndex stationIndex = 0; stationIndex < OpenRCT2::Limits::MaxStationsPerRide; 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 63533ffa16..9a82bdcbac 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -9,6 +9,7 @@ #pragma once +#include "../Limits.h" #include "../common.h" #include "../object/MusicObject.h" #include "../rct2/DATLimits.h" @@ -32,23 +33,10 @@ struct Staff; struct Vehicle; struct rct_ride_entry; -constexpr const uint8_t MAX_VEHICLES_PER_RIDE = 255; // Note: that 255 represents No Train (null) hence why this is not 256 -constexpr const uint8_t MAX_CIRCUITS_PER_RIDE = 20; -constexpr const uint8_t MAX_CARS_PER_TRAIN = 255; -constexpr const uint8_t MAX_VEHICLE_COLOURS = std::max(MAX_CARS_PER_TRAIN, MAX_VEHICLES_PER_RIDE); -#define NUM_COLOUR_SCHEMES 4 -#define DOWNTIME_HISTORY_SIZE 8 -#define CUSTOMER_HISTORY_SIZE 10 -#define MAX_CARS_PER_TRAIN 255 -#define MAX_STATIONS 255 -constexpr const uint16_t MAX_RIDES = 1000; #define RIDE_TYPE_NULL 255 #define RIDE_ADJACENCY_CHECK_DISTANCE 5 -constexpr uint16_t const MAX_STATION_LOCATIONS = MAX_STATIONS * 2; // Entrance and exit per station -constexpr uint16_t const MAX_INVERSIONS = RCT12::Limits::MaxInversions; -constexpr uint16_t const MAX_GOLF_HOLES = RCT12::Limits::MaxGolfHoles; -constexpr uint16_t const MAX_HELICES = RCT12::Limits::MaxHelices; +constexpr uint16_t const MAX_STATION_LOCATIONS = OpenRCT2::Limits::MaxStationsPerRide * 2; // Entrance and exit per station constexpr uint16_t const MAZE_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP; @@ -124,13 +112,13 @@ struct Ride ObjectEntryIndex subtype; RideMode mode; uint8_t colour_scheme_type; - VehicleColour vehicle_colours[MAX_VEHICLES_PER_RIDE + 1]; + VehicleColour vehicle_colours[OpenRCT2::Limits::MaxTrainsPerRide + 1]; // 0 = closed, 1 = open, 2 = test RideStatus status; std::string custom_name; uint16_t default_name_number; CoordsXY overall_view; - uint16_t vehicles[MAX_VEHICLES_PER_RIDE + 1]; // Points to the first car in the train + uint16_t vehicles[OpenRCT2::Limits::MaxTrainsPerRide + 1]; // Points to the first car in the train uint8_t depart_flags; uint8_t num_stations; uint8_t num_vehicles; @@ -191,7 +179,7 @@ struct Ride // Counts ticks to update customer intervals, resets each 960 game ticks. uint16_t num_customers_timeout; // Customer count in the last 10 * 960 game ticks (sliding window) - uint16_t num_customers[CUSTOMER_HISTORY_SIZE]; + uint16_t num_customers[OpenRCT2::Limits::CustomerHistorySize]; money16 price[RCT2::ObjectLimits::MaxShopItemsPerRideEntry]; TileCoordsXYZ ChairliftBullwheelLocation[2]; union @@ -253,7 +241,7 @@ struct Ride uint8_t downtime; uint8_t inspection_interval; uint8_t last_inspection; - uint8_t downtime_history[DOWNTIME_HISTORY_SIZE]; + uint8_t downtime_history[OpenRCT2::Limits::DowntimeHistorySize]; uint32_t no_primary_items_sold; uint32_t no_secondary_items_sold; uint8_t breakdown_sound_modifier; @@ -264,7 +252,7 @@ struct Ride uint8_t connected_message_throttle; money64 income_per_hour; money64 profit; - TrackColour track_colour[NUM_COLOUR_SCHEMES]; + TrackColour track_colour[OpenRCT2::Limits::NumColourSchemes]; ObjectEntryIndex music; ObjectEntryIndex entrance_style; uint16_t vehicle_change_timeout; @@ -284,7 +272,7 @@ struct Ride uint8_t current_issues; uint32_t last_issue_time; - RideStation stations[MAX_STATIONS]; + RideStation stations[OpenRCT2::Limits::MaxStationsPerRide]; uint16_t inversions; uint16_t holes; uint8_t sheltered_eighths; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 560fd1dfd2..bd7534ca90 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -187,7 +187,7 @@ void Ride::RemoveVehicles() lifecycle_flags &= ~RIDE_LIFECYCLE_ON_TRACK; lifecycle_flags &= ~(RIDE_LIFECYCLE_TEST_IN_PROGRESS | RIDE_LIFECYCLE_HAS_STALLED_VEHICLE); - for (size_t i = 0; i <= MAX_VEHICLES_PER_RIDE; i++) + for (size_t i = 0; i <= OpenRCT2::Limits::MaxTrainsPerRide; i++) { uint16_t spriteIndex = vehicles[i]; while (spriteIndex != SPRITE_INDEX_NULL) @@ -205,7 +205,7 @@ void Ride::RemoveVehicles() vehicles[i] = SPRITE_INDEX_NULL; } - for (size_t i = 0; i < MAX_STATIONS; i++) + for (size_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) stations[i].TrainAtStation = RideStation::NO_TRAIN; // Also clean up orphaned vehicles for good measure. @@ -1341,7 +1341,7 @@ void Ride::ValidateStations() if (type != RIDE_TYPE_MAZE) { // find the stations of the ride to begin stepping over track elements from - for (StationIndex stationId = 0; stationId < MAX_STATIONS; ++stationId) + for (StationIndex stationId = 0; stationId < OpenRCT2::Limits::MaxStationsPerRide; ++stationId) { if (stations[stationId].Start.IsNull()) continue; @@ -1447,7 +1447,7 @@ void Ride::ValidateStations() } // determine what entrances and exits exist FixedVector locations; - for (StationIndex stationId = 0; stationId < MAX_STATIONS; ++stationId) + for (StationIndex stationId = 0; stationId < OpenRCT2::Limits::MaxStationsPerRide; ++stationId) { auto entrance = ride_get_entrance_location(this, stationId); if (!entrance.IsNull()) @@ -1638,7 +1638,7 @@ bool ride_are_all_possible_entrances_and_exits_built(Ride* ride) if (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_IS_SHOP)) return true; - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (ride->stations[i].Start.IsNull()) { diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 5056492591..4d0925064c 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -163,7 +163,7 @@ static void ride_ratings_update_state_0(RideRatingUpdateState& state) ride_id_t currentRide = state.CurrentRide; currentRide = static_cast(EnumValue(currentRide) + 1); - if (currentRide >= static_cast(MAX_RIDES)) + if (currentRide >= static_cast(OpenRCT2::Limits::MaxRidesInPark)) { currentRide = {}; } @@ -387,7 +387,7 @@ static void ride_ratings_begin_proximity_loop(RideRatingUpdateState& state) return; } - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (!ride->stations[i].Start.IsNull()) { diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index 69cc1c4b88..dfe2679350 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -366,7 +366,7 @@ TileElement* ride_get_station_exit_element(const CoordsXYZ& elementPos) StationIndex ride_get_first_valid_station_exit(Ride* ride) { - for (StationIndex i = 0; i < MAX_STATIONS; i++) + for (StationIndex i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (!ride->stations[i].Exit.IsNull()) { @@ -378,7 +378,7 @@ StationIndex ride_get_first_valid_station_exit(Ride* ride) StationIndex ride_get_first_valid_station_start(const Ride* ride) { - for (StationIndex i = 0; i < MAX_STATIONS; i++) + for (StationIndex i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (!ride->stations[i].Start.IsNull()) { @@ -390,7 +390,7 @@ StationIndex ride_get_first_valid_station_start(const Ride* ride) StationIndex ride_get_first_empty_station_start(const Ride* ride) { - for (StationIndex i = 0; i < MAX_STATIONS; i++) + for (StationIndex i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (ride->stations[i].Start.IsNull()) { diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 136b056df8..6f97faa432 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -95,7 +95,7 @@ static TileElement* find_station_element(const CoordsXYZD& loc, ride_id_t rideIn static void ride_remove_station(Ride* ride, const CoordsXYZ& location) { - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { auto stationStart = ride->stations[i].GetStart(); if (stationStart == location) @@ -123,7 +123,7 @@ bool track_add_station_element(CoordsXYZD loc, ride_id_t rideIndex, int32_t flag if (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_SINGLE_PIECE_STATION)) { - if (ride->num_stations >= MAX_STATIONS) + if (ride->num_stations >= OpenRCT2::Limits::MaxStationsPerRide) { gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE; return false; @@ -192,7 +192,7 @@ bool track_add_station_element(CoordsXYZD loc, ride_id_t rideIndex, int32_t flag // When attempting to place a track design, it sometimes happens that the front and back of station 0 are built, // but the middle is not. Allow this, so the track place function can actually finish building all 4 stations. // This _might_ cause issues if the track designs is bugged and actually has 5. - if (stationBackLoc == stationFrontLoc && ride->num_stations >= MAX_STATIONS && !fromTrackDesign) + if (stationBackLoc == stationFrontLoc && ride->num_stations >= OpenRCT2::Limits::MaxStationsPerRide && !fromTrackDesign) { gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE; return false; @@ -330,7 +330,8 @@ bool track_remove_station_element(const CoordsXYZD& loc, ride_id_t rideIndex, in if (!(flags & GAME_COMMAND_FLAG_APPLY)) { - if ((removeLoc != stationBackLoc) && (removeLoc != stationFrontLoc) && ride->num_stations >= MAX_STATIONS) + if ((removeLoc != stationBackLoc) && (removeLoc != stationFrontLoc) + && ride->num_stations >= OpenRCT2::Limits::MaxStationsPerRide) { gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE; return false; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 0f82376568..292329e67f 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1685,7 +1685,7 @@ void Vehicle::UpdateMeasurements() { if (trackFlags & TRACK_ELEM_FLAG_IS_GOLF_HOLE) { - if (curRide->holes < MAX_GOLF_HOLES) + if (curRide->holes < OpenRCT2::Limits::MaxGolfHoles) curRide->holes++; } } @@ -1693,7 +1693,7 @@ void Vehicle::UpdateMeasurements() { if (trackFlags & TRACK_ELEM_FLAG_NORMAL_TO_INVERSION) { - if (curRide->inversions < MAX_INVERSIONS) + if (curRide->inversions < OpenRCT2::Limits::MaxInversions) curRide->inversions++; } } @@ -1701,7 +1701,7 @@ void Vehicle::UpdateMeasurements() if (trackFlags & TRACK_ELEM_FLAG_HELIX) { uint8_t helixes = ride_get_helix_sections(curRide); - if (helixes != MAX_HELICES) + if (helixes != OpenRCT2::Limits::MaxHelices) helixes++; curRide->special_track_elements &= ~0x1F; @@ -9067,7 +9067,7 @@ loc_6DCE02: _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { if (TrackLocation != curRide->stations[i].Start) { diff --git a/src/openrct2/world/Entrance.h b/src/openrct2/world/Entrance.h index 6ce821d83c..9dbbd55c57 100644 --- a/src/openrct2/world/Entrance.h +++ b/src/openrct2/world/Entrance.h @@ -48,8 +48,6 @@ constexpr const uint8_t RideExitHeight = 5 * COORDS_Z_STEP; extern bool gParkEntranceGhostExists; extern CoordsXYZD gParkEntranceGhostPosition; -#define MAX_PARK_ENTRANCES 256 - constexpr int32_t MaxRideEntranceOrExitHeight = 244 * COORDS_Z_STEP; extern std::vector gParkEntrances; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index e166f23f47..1eed7fddbd 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1235,7 +1235,7 @@ void footpath_update_queue_chains() if (ride == nullptr) continue; - for (int32_t i = 0; i < MAX_STATIONS; i++) + for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++) { TileCoordsXYZD location = ride_get_entrance_location(ride, i); if (location.IsNull()) diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index e142044f15..50ebadefb7 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -35,7 +35,6 @@ constexpr const int32_t MINIMUM_LAND_HEIGHT_BIG = MINIMUM_LAND_HEIGHT * COORDS_Z constexpr const uint32_t MAX_TILE_ELEMENTS_WITH_SPARE_ROOM = 0x1000000; constexpr const uint32_t MAX_TILE_ELEMENTS = MAX_TILE_ELEMENTS_WITH_SPARE_ROOM - 512; #define MAX_TILE_TILE_ELEMENT_POINTERS (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) -#define MAX_PEEP_SPAWNS 256 #define TILE_UNDEFINED_TILE_ELEMENT NULL