From ac80ca7b4677f47849c65270c5a14fe13aa114f2 Mon Sep 17 00:00:00 2001 From: Emre Aydin Date: Wed, 2 Jun 2021 17:48:09 +0300 Subject: [PATCH] Refactored code to use a constant for max circuits --- contributors.md | 1 + src/openrct2-ui/windows/Ride.cpp | 4 ++-- src/openrct2/actions/RideSetSettingAction.cpp | 2 +- src/openrct2/ride/Ride.h | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contributors.md b/contributors.md index 0a8a3039d1..d853b68902 100644 --- a/contributors.md +++ b/contributors.md @@ -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 diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 2e6dc5d22f..b31a78bca1 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -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(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(ride->num_circuits - 1, lower_bound, upper_bound)); diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 24cbf5f9bb..8c19249b86 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -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; } diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index af5956ad43..8d19dc04f9 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -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