Merge pull request #25641 from Gymnasiast/refactor/inspection

Refactor inspection interval and fix bugs
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2025-12-31 12:54:19 +01:00
commit c8445ebbeb
22 files changed
+103 -67

No files matched your search

+2 -2
View File
@@ -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")
+2
View File
@@ -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.
+2 -2
View File
@@ -224,8 +224,8 @@
<OpenSFXSha256>06b90f3e19c216752df441d551b26a9e3e1ba7755bdd2102504b73bf993608be</OpenSFXSha256>
<OpenMSXUrl>https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6.1/openmusic.zip</OpenMSXUrl>
<OpenMSXSha256>994b350d3b180ee1cb9619fe27f7ebae3a1a5232840c4bd47a89f33fa89de1a1</OpenMSXSha256>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.90/replays.zip</ReplaysUrl>
<ReplaysSha256>f8474a927e155056e5729b6fa9f05af2a85ae7e1435f5fa89ba496242f9f255e</ReplaysSha256>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.91/replays.zip</ReplaysUrl>
<ReplaysSha256>5b99edc3d8445fcd2cb22c204708247f575d0bdd3128561322e3abf01e977c79</ReplaysSha256>
</PropertyGroup>
<!-- Unified Dependency Target -->
+3 -1
View File
@@ -13,6 +13,7 @@
#include <openrct2/GameState.h>
#include <openrct2/actions/RideCreateAction.h>
#include <openrct2/config/Config.h>
#include <openrct2/ride/Ride.h>
#include <openrct2/ride/RideConstruction.h>
#include <openrct2/ride/RideData.h>
@@ -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)
+6 -5
View File
@@ -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<uint8_t>(dropdownIndex);
Config::Get().general.defaultInspectionInterval = static_cast<RideInspection>(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
+2 -2
View File
@@ -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);
@@ -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);
+10 -4
View File
@@ -21,6 +21,7 @@
#include <openrct2/SpriteIds.h>
#include <openrct2/actions/TrackDesignAction.h>
#include <openrct2/audio/Audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/paint/VirtualFloor.h>
#include <openrct2/ride/RideConstruction.h>
@@ -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());
+1 -1
View File
@@ -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);
+11 -3
View File
@@ -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;
+2 -1
View File
@@ -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;
@@ -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<RideInspection>(_value);
break;
case RideSetSetting::Music:
ride->lifecycleFlags &= ~RIDE_LIFECYCLE_MUSIC;
+14 -7
View File
@@ -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<uint8_t>(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;
+3 -1
View File
@@ -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;
+15 -2
View File
@@ -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<VirtualFloorStyles>("GLASSY", VirtualFloorStyles::Glassy),
});
static const auto Enum_RideInspectionInterval = ConfigEnum<RideInspection>({
ConfigEnumEntry<RideInspection>("EVERY_10_MINUTES", RideInspection::every10Minutes),
ConfigEnumEntry<RideInspection>("EVERY_20_MINUTES", RideInspection::every20Minutes),
ConfigEnumEntry<RideInspection>("EVERY_30_MINUTES", RideInspection::every30Minutes),
ConfigEnumEntry<RideInspection>("EVERY_45_MINUTES", RideInspection::every45Minutes),
ConfigEnumEntry<RideInspection>("EVERY_HOUR", RideInspection::everyHour),
ConfigEnumEntry<RideInspection>("EVERY_2_HOURS", RideInspection::every2Hours),
ConfigEnumEntry<RideInspection>("NEVER", RideInspection::never),
});
/**
* Config enum wrapping LanguagesDescriptors.
*/
@@ -204,7 +215,8 @@ namespace OpenRCT2::Config
model->dateFormat = reader->GetEnum<int32_t>("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<RideInspection>(
"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<FileBrowserSort>(
@@ -309,7 +321,8 @@ namespace OpenRCT2::Config
writer->WriteEnum<int32_t>("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<RideInspection>(
"default_inspection_interval", model->defaultInspectionInterval, Enum_RideInspectionInterval);
writer->WriteString("last_run_version", model->lastRunVersion);
writer->WriteBoolean("invert_viewport_drag", model->invertViewportDrag);
writer->WriteEnum<FileBrowserSort>("load_save_sort", model->loadSaveSort, Enum_FileBrowserSort);
+3 -1
View File
@@ -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;
+2 -1
View File
@@ -1008,7 +1008,8 @@ namespace OpenRCT2::RCT1
// Maintenance
dst->buildDate = static_cast<int32_t>(src->buildDate);
dst->inspectionInterval = src->inspectionInterval;
auto clampedInspectionInterval = std::clamp<uint8_t>(src->inspectionInterval, 0, EnumValue(RideInspection::never));
dst->inspectionInterval = static_cast<RideInspection>(clampedInspectionInterval);
dst->lastInspection = src->lastInspection;
dst->reliability = src->reliability;
dst->unreliabilityFactor = src->unreliabilityFactor;
+2 -1
View File
@@ -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<uint8_t>(src->inspectionInterval, 0, EnumValue(RideInspection::never));
dst->inspectionInterval = static_cast<RideInspection>(clampedInspectionInterval);
dst->lastInspection = src->lastInspection;
for (uint8_t i = 0; i < Limits::kDowntimeHistorySize; i++)
+1 -13
View File
@@ -1345,7 +1345,7 @@ static void RideInspectionUpdate(Ride& ride)
ride.lastInspection = AddClamp<decltype(ride.lastInspection)>(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
+12 -13
View File
@@ -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
{
+3 -1
View File
@@ -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();
@@ -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<uint8_t>(value, RIDE_INSPECTION_EVERY_10_MINUTES, RIDE_INSPECTION_NEVER);
auto clamped = std::clamp<uint8_t>(
value, EnumValue(RideInspection::every10Minutes), EnumValue(RideInspection::never));
ride->inspectionInterval = static_cast<RideInspection>(clamped);
}
}