Refactored code to use a constant for max circuits

This commit is contained in:
Emre Aydin 2021-06-02 17:48:09 +03:00
parent b7e7915efa
commit ac80ca7b46
4 changed files with 5 additions and 3 deletions

View File

@ -168,6 +168,7 @@ The following people are not part of the development team, but have been contrib
* Geoff B. (geoff-B)
* Ryan D. (rctdude2)
* (zrowny)
* Emre Aydin (aemreaydin)
## Toolchain
* (Balletie) - macOS

View File

@ -3301,13 +3301,13 @@ static void window_ride_operating_mousedown(rct_window* w, rct_widgetindex widge
window_ride_load_dropdown(w, widget);
break;
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_INCREASE:
upper_bound = gCheatsUnlockOperatingLimits ? 255 : 20;
upper_bound = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE;
lower_bound = 1;
set_operating_setting(
w->number, RideSetSetting::NumCircuits, std::clamp<int16_t>(ride->num_circuits + 1, lower_bound, upper_bound));
break;
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE:
upper_bound = gCheatsUnlockOperatingLimits ? 255 : 20;
upper_bound = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE;
lower_bound = 1;
set_operating_setting(
w->number, RideSetSetting::NumCircuits, std::clamp<int16_t>(ride->num_circuits - 1, lower_bound, upper_bound));

View File

@ -252,7 +252,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 : 20;
int32_t maxNumCircuits = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE;
return _value >= minNumCircuits && _value <= maxNumCircuits;
}

View File

@ -37,6 +37,7 @@ struct Vehicle;
// Examples of vehicles here are the locomotive, tender and carriage of the Miniature Railway.
#define MAX_VEHICLES_PER_RIDE_ENTRY 4
constexpr const uint8_t MAX_VEHICLES_PER_RIDE = 31;
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