diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a8e0c8b53..b6edd7f277 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,9 +82,9 @@ set(OPENMSX_VERSION "1.6.1") set(OPENMSX_URL "https://github.com/OpenRCT2/OpenMusic/releases/download/v${OPENMSX_VERSION}/openmusic.zip") set(OPENMSX_SHA256 "994b350d3b180ee1cb9619fe27f7ebae3a1a5232840c4bd47a89f33fa89de1a1") -set(REPLAYS_VERSION "0.0.90") +set(REPLAYS_VERSION "0.0.91") set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v${REPLAYS_VERSION}/replays.zip") -set(REPLAYS_SHA256 "f8474a927e155056e5729b6fa9f05af2a85ae7e1435f5fa89ba496242f9f255e") +set(REPLAYS_SHA256 "5b99edc3d8445fcd2cb22c204708247f575d0bdd3128561322e3abf01e977c79") option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(WITH_TESTS "Build tests") diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 06942cb773..5c66141169 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -27,8 +27,10 @@ - Fix: [#25588] When the master server becomes unreachable the server would not register again until a restart. - Fix: [#25592] Log flume, river rapids, & splash boats can get control failure breakdown instead of brakes failure. - Fix: [#25595] Invisible entrance is added to imported SV4 saves. +- Fix: [#25601] Inspection interval of a ride gets reset when opening the construction window. - Fix: [#25628] Availability of AVX2 and SSE4.1 is not detected correctly. - Fix: [#25639] Scenery window crashes when a no longer present object is still selected. +- Fix: [#25641] Desync because of mismatching inspection intervals. - Fix: [#25642] The selection marker for purchasing land rights is not drawn with the correct colours. - Fix: [#25646] It is possible to remove scenery and paths when setting staff patrol areas and purchasing land. - Fix: [#25660] After saving a track design with scenery, that ride’s entrances and exits are visible in ‘Highlight path issues’ mode. diff --git a/openrct2.deps.targets b/openrct2.deps.targets index 34aea9797e..55f7507cf1 100644 --- a/openrct2.deps.targets +++ b/openrct2.deps.targets @@ -224,8 +224,8 @@ 06b90f3e19c216752df441d551b26a9e3e1ba7755bdd2102504b73bf993608be https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6.1/openmusic.zip 994b350d3b180ee1cb9619fe27f7ebae3a1a5232840c4bd47a89f33fa89de1a1 - https://github.com/OpenRCT2/replays/releases/download/v0.0.90/replays.zip - f8474a927e155056e5729b6fa9f05af2a85ae7e1435f5fa89ba496242f9f255e + https://github.com/OpenRCT2/replays/releases/download/v0.0.91/replays.zip + 5b99edc3d8445fcd2cb22c204708247f575d0bdd3128561322e3abf01e977c79 diff --git a/src/openrct2-ui/ride/Construction.cpp b/src/openrct2-ui/ride/Construction.cpp index 978beeb081..b025036747 100644 --- a/src/openrct2-ui/ride/Construction.cpp +++ b/src/openrct2-ui/ride/Construction.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -231,7 +232,8 @@ namespace OpenRCT2 int32_t colour2 = RideGetUnusedPresetVehicleColour(rideEntryIndex); auto gameAction = GameActions::RideCreateAction( - listItem.Type, listItem.EntryIndex, colour1, colour2, getGameState().lastEntranceStyle); + listItem.Type, listItem.EntryIndex, colour1, colour2, getGameState().lastEntranceStyle, + Config::Get().general.defaultInspectionInterval); gameAction.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->error != GameActions::Status::ok) diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index f2faddf385..e493b2dd17 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -1947,7 +1947,8 @@ namespace OpenRCT2::Ui::Windows } ShowDropdown(widget, 7); - gDropdown.items[Config::Get().general.defaultInspectionInterval].setChecked(true); + auto selectedIndex = EnumValue(Config::Get().general.defaultInspectionInterval); + gDropdown.items[selectedIndex].setChecked(true); break; } } @@ -1975,9 +1976,9 @@ namespace OpenRCT2::Ui::Windows break; } case WIDX_DEFAULT_INSPECTION_INTERVAL_DROPDOWN: - if (dropdownIndex != Config::Get().general.defaultInspectionInterval) + if (dropdownIndex != EnumValue(Config::Get().general.defaultInspectionInterval)) { - Config::Get().general.defaultInspectionInterval = static_cast(dropdownIndex); + Config::Get().general.defaultInspectionInterval = static_cast(dropdownIndex); Config::Save(); invalidate(); } @@ -2040,8 +2041,8 @@ namespace OpenRCT2::Ui::Windows setCheckboxValue(WIDX_SCENARIO_UNLOCKING, Config::Get().general.scenarioUnlockingEnabled); - widgets[WIDX_DEFAULT_INSPECTION_INTERVAL].text = kRideInspectionIntervalNames - [Config::Get().general.defaultInspectionInterval]; + auto selectedIndex = EnumValue(Config::Get().general.defaultInspectionInterval); + widgets[WIDX_DEFAULT_INSPECTION_INTERVAL].text = kRideInspectionIntervalNames[selectedIndex]; } #pragma endregion diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 2dc6f8762d..e4fbfac15b 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -3785,7 +3785,7 @@ namespace OpenRCT2::Ui::Windows { windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height(), colours[1], 0, Dropdown::Flag::StayOpen, 7, widgets[widgetIndex].right - dropdownWidget->left); - gDropdown.items[ride->inspectionInterval].setChecked(true); + gDropdown.items[EnumValue(ride->inspectionInterval)].setChecked(true); break; case WIDX_FORCE_BREAKDOWN: @@ -3984,7 +3984,7 @@ namespace OpenRCT2::Ui::Windows auto ft = Formatter::Common(); ride->formatNameTo(ft); - widgets[WIDX_INSPECTION_INTERVAL].text = kRideInspectionIntervalNames[ride->inspectionInterval]; + widgets[WIDX_INSPECTION_INTERVAL].text = kRideInspectionIntervalNames[EnumValue(ride->inspectionInterval)]; WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 7af1388880..5fcdae1048 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -326,7 +326,6 @@ namespace OpenRCT2::Ui::Windows } } - currentRide->setToDefaultInspectionInterval(); auto intent = Intent(WindowClass::ride); intent.PutExtra(INTENT_EXTRA_RIDE_ID, currentRide->id.ToUnderlying()); ContextOpenIntent(&intent); diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 2e4ff95da8..9a65afe4f8 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -225,7 +226,9 @@ namespace OpenRCT2::Ui::Windows if (res.error == GameActions::Status::ok) { // Valid location found. Place the ghost at the location. - auto tdAction = GameActions::TrackDesignAction(ghostTrackLoc, *_trackDesign, !gTrackDesignSceneryToggle); + auto tdAction = GameActions::TrackDesignAction( + ghostTrackLoc, *_trackDesign, !gTrackDesignSceneryToggle, + Config::Get().general.defaultInspectionInterval); tdAction.SetFlags({ CommandFlag::noSpend, CommandFlag::ghost }); tdAction.SetCallback([&](const GameActions::GameAction*, const GameActions::Result* result) { if (result->error == GameActions::Status::ok) @@ -297,7 +300,8 @@ namespace OpenRCT2::Ui::Windows _placingTrackDesign = true; auto tdAction = GameActions::TrackDesignAction( - { trackLoc, _currentTrackPieceDirection }, *_trackDesign, !gTrackDesignSceneryToggle); + { trackLoc, _currentTrackPieceDirection }, *_trackDesign, !gTrackDesignSceneryToggle, + Config::Get().general.defaultInspectionInterval); tdAction.SetCallback([&, trackLoc](const GameActions::GameAction*, const GameActions::Result* result) { if (result->error != GameActions::Status::ok) { @@ -400,7 +404,8 @@ namespace OpenRCT2::Ui::Windows if (_hasPlacementGhost) { auto tdAction = GameActions::TrackDesignAction( - { _placementGhostLoc }, *_trackDesign, !gTrackDesignSceneryToggle); + { _placementGhostLoc }, *_trackDesign, !gTrackDesignSceneryToggle, + Config::Get().general.defaultInspectionInterval); tdAction.SetFlags({ CommandFlag::noSpend, CommandFlag::ghost }); auto res = GameActions::Execute(&tdAction, getGameState()); if (res.error != GameActions::Status::ok) @@ -747,7 +752,8 @@ namespace OpenRCT2::Ui::Windows for (int32_t i = 0; i < 7; i++, loc.z += kCoordsZStep) { auto tdAction = GameActions::TrackDesignAction( - CoordsXYZD{ loc.x, loc.y, loc.z, _currentTrackPieceDirection }, *_trackDesign, !gTrackDesignSceneryToggle); + CoordsXYZD{ loc.x, loc.y, loc.z, _currentTrackPieceDirection }, *_trackDesign, !gTrackDesignSceneryToggle, + Config::Get().general.defaultInspectionInterval); tdAction.SetFlags(newFlags); res = GameActions::Query(&tdAction, getGameState()); diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/CheatSetAction.cpp index 2ec5f73cba..4fd2bc6681 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/CheatSetAction.cpp @@ -572,7 +572,7 @@ namespace OpenRCT2::GameActions for (auto& ride : RideManager(gameState)) { // Set inspection interval to 10 minutes - ride.inspectionInterval = RIDE_INSPECTION_EVERY_10_MINUTES; + ride.inspectionInterval = RideInspection::every10Minutes; } auto* windowMgr = Ui::GetWindowManager(); windowMgr->InvalidateByClass(WindowClass::ride); diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/RideCreateAction.cpp index e8a5dc3db0..dcf4f21627 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/RideCreateAction.cpp @@ -32,12 +32,13 @@ namespace OpenRCT2::GameActions { RideCreateAction::RideCreateAction( ride_type_t rideType, ObjectEntryIndex subType, uint8_t trackColourPreset, uint8_t vehicleColourPreset, - ObjectEntryIndex entranceObjectIndex) + ObjectEntryIndex entranceObjectIndex, RideInspection inspectionInterval) : _rideType(rideType) , _subType(subType) , _entranceObjectIndex(entranceObjectIndex) , _trackColourPreset(trackColourPreset) , _vehicleColourPreset(vehicleColourPreset) + , _inspectionInterval(inspectionInterval) { } @@ -48,6 +49,7 @@ namespace OpenRCT2::GameActions visitor.Visit("entranceObject", _entranceObjectIndex); visitor.Visit("colour1", _trackColourPreset); visitor.Visit("colour2", _vehicleColourPreset); + visitor.Visit("inspectionInterval", _inspectionInterval); } ride_type_t RideCreateAction::GetRideType() const @@ -70,11 +72,17 @@ namespace OpenRCT2::GameActions GameAction::Serialise(stream); stream << DS_TAG(_rideType) << DS_TAG(_subType) << DS_TAG(_entranceObjectIndex) << DS_TAG(_trackColourPreset) - << DS_TAG(_vehicleColourPreset); + << DS_TAG(_vehicleColourPreset) << DS_TAG(_inspectionInterval); } Result RideCreateAction::Query(GameState_t& gameState) const { + if (_inspectionInterval > RideInspection::never) + { + LOG_ERROR("Invalid inspection interval: %u", EnumValue(_inspectionInterval)); + return Result(Status::invalidParameters, STR_CANT_CHANGE_OPERATING_MODE, STR_ERR_VALUE_OUT_OF_RANGE); + } + auto rideIndex = GetNextFreeRideId(); if (rideIndex.IsNull()) { @@ -274,7 +282,7 @@ namespace OpenRCT2::GameActions ride->upkeepCost = kMoney64Undefined; ride->reliability = kRideInitialReliability; ride->unreliabilityFactor = 1; - ride->inspectionInterval = RIDE_INSPECTION_EVERY_30_MINUTES; + ride->inspectionInterval = _inspectionInterval; ride->lastCrashType = RIDE_CRASH_TYPE_NONE; ride->incomePerHour = kMoney64Undefined; ride->profit = kMoney64Undefined; diff --git a/src/openrct2/actions/RideCreateAction.h b/src/openrct2/actions/RideCreateAction.h index 910bea53d6..b386d45ddb 100644 --- a/src/openrct2/actions/RideCreateAction.h +++ b/src/openrct2/actions/RideCreateAction.h @@ -21,12 +21,13 @@ namespace OpenRCT2::GameActions ObjectEntryIndex _entranceObjectIndex{ kObjectEntryIndexNull }; uint8_t _trackColourPreset{ COLOUR_NULL }; uint8_t _vehicleColourPreset{ COLOUR_NULL }; + RideInspection _inspectionInterval{ RideInspection::every30Minutes }; public: RideCreateAction() = default; RideCreateAction( ride_type_t rideType, ObjectEntryIndex subType, uint8_t trackColourPreset, uint8_t vehicleColourPreset, - ObjectEntryIndex entranceStyleIndex); + ObjectEntryIndex entranceStyleIndex, RideInspection inspectionInterval); void AcceptParameters(GameActionParameterVisitor&) final; diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 50ecc542ad..a32c38ab1c 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -98,7 +98,7 @@ namespace OpenRCT2::GameActions } break; case RideSetSetting::InspectionInterval: - if (_value > RIDE_INSPECTION_NEVER) + if (_value > EnumValue(RideInspection::never)) { LOG_ERROR("Invalid inspection interval: %u", _value); return Result(Status::invalidParameters, STR_CANT_CHANGE_OPERATING_MODE, STR_ERR_VALUE_OUT_OF_RANGE); @@ -190,12 +190,12 @@ namespace OpenRCT2::GameActions break; case RideSetSetting::InspectionInterval: - if (_value == RIDE_INSPECTION_NEVER) + if (_value == EnumValue(RideInspection::never)) { ride->lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; } - ride->inspectionInterval = _value; + ride->inspectionInterval = static_cast(_value); break; case RideSetSetting::Music: ride->lifecycleFlags &= ~RIDE_LIFECYCLE_MUSIC; diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index 0b615143db..5f6311ad56 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -27,10 +27,12 @@ namespace OpenRCT2::GameActions { - TrackDesignAction::TrackDesignAction(const CoordsXYZD& location, const TrackDesign& td, bool placeScenery) + TrackDesignAction::TrackDesignAction( + const CoordsXYZD& location, const TrackDesign& td, bool placeScenery, RideInspection inspectionInterval) : _loc(location) , _td(td) , _placeScenery(placeScenery) + , _inspectionInterval(inspectionInterval) { } @@ -52,6 +54,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc); _td.Serialise(stream); stream << DS_TAG(_placeScenery); + stream << DS_TAG(_inspectionInterval); } Result TrackDesignAction::Query(GameState_t& gameState) const @@ -67,6 +70,12 @@ namespace OpenRCT2::GameActions return Result(Status::invalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP); } + if (_inspectionInterval > RideInspection::never) + { + LOG_ERROR("Invalid inspection interval: %u", EnumValue(_inspectionInterval)); + return Result(Status::invalidParameters, STR_CANT_CHANGE_OPERATING_MODE, STR_ERR_VALUE_OUT_OF_RANGE); + } + auto& objManager = GetContext()->GetObjectManager(); auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.trackAndVehicle.vehicleObject); if (entryIndex == kObjectEntryIndexNull) @@ -80,7 +89,8 @@ namespace OpenRCT2::GameActions } // Colours do not matter as will be overwritten - auto rideCreateAction = RideCreateAction(_td.trackAndVehicle.rtdIndex, entryIndex, 0, 0, gameState.lastEntranceStyle); + auto rideCreateAction = RideCreateAction( + _td.trackAndVehicle.rtdIndex, entryIndex, 0, 0, gameState.lastEntranceStyle, _inspectionInterval); rideCreateAction.SetFlags(GetFlags()); auto r = ExecuteNested(&rideCreateAction, gameState); if (r.error != Status::ok) @@ -150,7 +160,8 @@ namespace OpenRCT2::GameActions } // Colours do not matter as will be overwritten - auto rideCreateAction = RideCreateAction(_td.trackAndVehicle.rtdIndex, entryIndex, 0, 0, gameState.lastEntranceStyle); + auto rideCreateAction = RideCreateAction( + _td.trackAndVehicle.rtdIndex, entryIndex, 0, 0, gameState.lastEntranceStyle, _inspectionInterval); rideCreateAction.SetFlags(GetFlags()); auto r = ExecuteNested(&rideCreateAction, gameState); if (r.error != Status::ok) @@ -236,10 +247,6 @@ namespace OpenRCT2::GameActions auto numCircuits = std::max(1, _td.operation.numCircuits); SetOperatingSettingNested(ride->id, RideSetSetting::NumCircuits, numCircuits, flags); - uint8_t defaultInspectionInterval = Config::Get().general.defaultInspectionInterval; - if (defaultInspectionInterval <= RIDE_INSPECTION_NEVER) - SetOperatingSettingNested(ride->id, RideSetSetting::InspectionInterval, defaultInspectionInterval, flags); - ride->lifecycleFlags |= RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN; ride->vehicleColourSettings = _td.appearance.vehicleColourSettings; diff --git a/src/openrct2/actions/TrackDesignAction.h b/src/openrct2/actions/TrackDesignAction.h index 1b5acfa888..526a9e8f48 100644 --- a/src/openrct2/actions/TrackDesignAction.h +++ b/src/openrct2/actions/TrackDesignAction.h @@ -20,10 +20,12 @@ namespace OpenRCT2::GameActions CoordsXYZD _loc; TrackDesign _td; bool _placeScenery{ false }; + RideInspection _inspectionInterval{ RideInspection::every30Minutes }; public: TrackDesignAction() = default; - TrackDesignAction(const CoordsXYZD& location, const TrackDesign& td, bool placeScenery); + TrackDesignAction( + const CoordsXYZD& location, const TrackDesign& td, bool placeScenery, RideInspection inspectionInterval); void AcceptParameters(GameActionParameterVisitor&) final; diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 60d46e9523..2aef53b51d 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -30,6 +30,7 @@ #include "../paint/VirtualFloor.h" #include "../platform/Platform.h" #include "../rct1/Csg.h" +#include "../ride/Ride.h" #include "../scenario/Scenario.h" #include "../ui/UiContext.h" #include "ConfigEnum.hpp" @@ -131,6 +132,16 @@ namespace OpenRCT2::Config ConfigEnumEntry("GLASSY", VirtualFloorStyles::Glassy), }); + static const auto Enum_RideInspectionInterval = ConfigEnum({ + ConfigEnumEntry("EVERY_10_MINUTES", RideInspection::every10Minutes), + ConfigEnumEntry("EVERY_20_MINUTES", RideInspection::every20Minutes), + ConfigEnumEntry("EVERY_30_MINUTES", RideInspection::every30Minutes), + ConfigEnumEntry("EVERY_45_MINUTES", RideInspection::every45Minutes), + ConfigEnumEntry("EVERY_HOUR", RideInspection::everyHour), + ConfigEnumEntry("EVERY_2_HOURS", RideInspection::every2Hours), + ConfigEnumEntry("NEVER", RideInspection::never), + }); + /** * Config enum wrapping LanguagesDescriptors. */ @@ -204,7 +215,8 @@ namespace OpenRCT2::Config model->dateFormat = reader->GetEnum("date_format", Platform::GetLocaleDateFormat(), Enum_DateFormat); model->autoStaffPlacement = reader->GetBoolean("auto_staff", true); model->handymenMowByDefault = reader->GetBoolean("handymen_mow_default", false); - model->defaultInspectionInterval = reader->GetInt32("default_inspection_interval", 2); + model->defaultInspectionInterval = reader->GetEnum( + "default_inspection_interval", RideInspection::every30Minutes, Enum_RideInspectionInterval); model->lastRunVersion = reader->GetString("last_run_version", ""); model->invertViewportDrag = reader->GetBoolean("invert_viewport_drag", false); model->loadSaveSort = reader->GetEnum( @@ -309,7 +321,8 @@ namespace OpenRCT2::Config writer->WriteEnum("date_format", model->dateFormat, Enum_DateFormat); writer->WriteBoolean("auto_staff", model->autoStaffPlacement); writer->WriteBoolean("handymen_mow_default", model->handymenMowByDefault); - writer->WriteInt32("default_inspection_interval", model->defaultInspectionInterval); + writer->WriteEnum( + "default_inspection_interval", model->defaultInspectionInterval, Enum_RideInspectionInterval); writer->WriteString("last_run_version", model->lastRunVersion); writer->WriteBoolean("invert_viewport_drag", model->invertViewportDrag); writer->WriteEnum("load_save_sort", model->loadSaveSort, Enum_FileBrowserSort); diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index 29cb6727e8..ef531cbe51 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -19,6 +19,8 @@ #undef interface #endif +enum class RideInspection : uint8_t; + namespace OpenRCT2::Config { struct General @@ -98,7 +100,7 @@ namespace OpenRCT2::Config bool autoStaffPlacement; bool handymenMowByDefault; bool autoOpenShops; - int32_t defaultInspectionInterval; + RideInspection defaultInspectionInterval; int32_t windowLimit; bool scenarioUnlockingEnabled; bool scenarioHideMegaPark; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 202af66409..02ccd8a1c1 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1008,7 +1008,8 @@ namespace OpenRCT2::RCT1 // Maintenance dst->buildDate = static_cast(src->buildDate); - dst->inspectionInterval = src->inspectionInterval; + auto clampedInspectionInterval = std::clamp(src->inspectionInterval, 0, EnumValue(RideInspection::never)); + dst->inspectionInterval = static_cast(clampedInspectionInterval); dst->lastInspection = src->lastInspection; dst->reliability = src->reliability; dst->unreliabilityFactor = src->unreliabilityFactor; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index ff4a14c9ca..5bc197e1fe 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -933,7 +933,8 @@ namespace OpenRCT2::RCT2 dst->reliability = src->reliability; dst->unreliabilityFactor = src->unreliabilityFactor; dst->downtime = src->downtime; - dst->inspectionInterval = src->inspectionInterval; + auto clampedInspectionInterval = std::clamp(src->inspectionInterval, 0, EnumValue(RideInspection::never)); + dst->inspectionInterval = static_cast(clampedInspectionInterval); dst->lastInspection = src->lastInspection; for (uint8_t i = 0; i < Limits::kDowntimeHistorySize; i++) diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index a724144d69..70393b3391 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1345,7 +1345,7 @@ static void RideInspectionUpdate(Ride& ride) ride.lastInspection = AddClamp(ride.lastInspection, 1); ride.windowInvalidateFlags |= RIDE_INVALIDATE_RIDE_MAINTENANCE; - int32_t inspectionIntervalMinutes = RideInspectionInterval[ride.inspectionInterval]; + int32_t inspectionIntervalMinutes = RideInspectionInterval[EnumValue(ride.inspectionInterval)]; // An inspection interval of 0 minutes means the ride is set to never be inspected. if (inspectionIntervalMinutes == 0) { @@ -5302,18 +5302,6 @@ void Ride::setReversedTrains(bool reverseTrains) GameActions::Execute(&rideSetVehicleAction, getGameState()); } -void Ride::setToDefaultInspectionInterval() -{ - uint8_t defaultInspectionInterval = Config::Get().general.defaultInspectionInterval; - if (inspectionInterval != defaultInspectionInterval) - { - if (defaultInspectionInterval <= RIDE_INSPECTION_NEVER) - { - SetOperatingSetting(id, GameActions::RideSetSetting::InspectionInterval, defaultInspectionInterval); - } - } -} - /** * * rct2: 0x006B752C diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 4b851a10e5..3570f05b10 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -62,6 +62,17 @@ constexpr money64 kRideMaxPrice = 20.00_GBP; extern const StringId kRideInspectionIntervalNames[]; +enum class RideInspection : uint8_t +{ + every10Minutes, + every20Minutes, + every30Minutes, + every45Minutes, + everyHour, + every2Hours, + never, +}; + enum class RideTestingFlag : uint8_t { sheltered, @@ -282,7 +293,7 @@ struct Ride uint8_t unreliabilityFactor{}; // Range from [0, 100] uint8_t downtime{}; - uint8_t inspectionInterval{}; + RideInspection inspectionInterval{}; uint8_t lastInspection{}; uint8_t downtimeHistory[OpenRCT2::Limits::kDowntimeHistorySize]{}; uint32_t numPrimaryItemsSold{}; @@ -359,7 +370,6 @@ public: void renew(); void remove(); void crash(uint8_t vehicleIndex); - void setToDefaultInspectionInterval(); void setRideEntry(OpenRCT2::ObjectEntryIndex entryIndex); void setNumTrains(int32_t newNumTrains); @@ -780,17 +790,6 @@ enum WAIT_FOR_LOAD_COUNT, }; -enum -{ - RIDE_INSPECTION_EVERY_10_MINUTES, - RIDE_INSPECTION_EVERY_20_MINUTES, - RIDE_INSPECTION_EVERY_30_MINUTES, - RIDE_INSPECTION_EVERY_45_MINUTES, - RIDE_INSPECTION_EVERY_HOUR, - RIDE_INSPECTION_EVERY_2_HOURS, - RIDE_INSPECTION_NEVER -}; - // Flags used by ride->windowInvalidateFlags enum { diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index d39094f2f2..ded63ee05f 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -31,6 +31,7 @@ #include "../actions/WallPlaceAction.h" #include "../actions/WallRemoveAction.h" #include "../audio/Audio.h" +#include "../config/Config.h" #include "../core/DataSerialiser.h" #include "../core/File.h" #include "../core/Numerics.hpp" @@ -1859,7 +1860,8 @@ int32_t TrackDesignGetZPlacement(const TrackDesign& td, Ride& ride, const Coords static money64 TrackDesignCreateRide(int32_t type, int32_t subType, CommandFlags flags, RideId* outRideIndex) { // Don't set colours as will be set correctly later. - auto gameAction = GameActions::RideCreateAction(type, subType, 0, 0, getGameState().lastEntranceStyle); + auto gameAction = GameActions::RideCreateAction( + type, subType, 0, 0, getGameState().lastEntranceStyle, Config::Get().general.defaultInspectionInterval); gameAction.SetFlags(flags); auto& gameState = getGameState(); diff --git a/src/openrct2/scripting/bindings/ride/ScRide.cpp b/src/openrct2/scripting/bindings/ride/ScRide.cpp index aa9194681a..05b157ace3 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.cpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.cpp @@ -454,7 +454,7 @@ namespace OpenRCT2::Scripting uint8_t ScRide::inspectionInterval_get() const { auto ride = GetRide(); - return ride != nullptr ? ride->inspectionInterval : 0; + return ride != nullptr ? EnumValue(ride->inspectionInterval) : 0; } void ScRide::inspectionInterval_set(uint8_t value) { @@ -462,7 +462,9 @@ namespace OpenRCT2::Scripting auto ride = GetRide(); if (ride != nullptr) { - ride->inspectionInterval = std::clamp(value, RIDE_INSPECTION_EVERY_10_MINUTES, RIDE_INSPECTION_NEVER); + auto clamped = std::clamp( + value, EnumValue(RideInspection::every10Minutes), EnumValue(RideInspection::never)); + ride->inspectionInterval = static_cast(clamped); } }