From a0f76ddc1b1806c3bd2479401e45ee50458df558 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 12 May 2020 20:54:12 +0100 Subject: [PATCH] Add running cost and inspection --- distribution/openrct2.d.ts | 10 ++++++++++ src/openrct2/scripting/ScRide.hpp | 33 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index d06d2cb67e..f0996f6cc4 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -773,6 +773,16 @@ declare global { * The date in months when the ride was built. */ buildDate: number; + + /** + * The running cost of the ride billed every fortnight. Multiply this by 16 to get the cost per hour (~ 1 year). + */ + runningCost: number; + + /** + * How often the ride should be inspected by a mechanic. + */ + inspectionInterval: number; } type RideClassification = "ride" | "stall" | "facility"; diff --git a/src/openrct2/scripting/ScRide.hpp b/src/openrct2/scripting/ScRide.hpp index 3eaa960798..c1290dfac2 100644 --- a/src/openrct2/scripting/ScRide.hpp +++ b/src/openrct2/scripting/ScRide.hpp @@ -561,6 +561,36 @@ namespace OpenRCT2::Scripting } } + int16_t runningCost_get() const + { + auto ride = GetRide(); + return ride != nullptr ? ride->upkeep_cost : 0; + } + void runningCost_set(int16_t value) + { + ThrowIfGameStateNotMutable(); + auto ride = GetRide(); + if (ride != nullptr) + { + ride->upkeep_cost = value; + } + } + + uint8_t inspectionInterval_get() const + { + auto ride = GetRide(); + return ride != nullptr ? ride->inspection_interval : 0; + } + void inspectionInterval_set(uint8_t value) + { + ThrowIfGameStateNotMutable(); + auto ride = GetRide(); + if (ride != nullptr) + { + ride->inspection_interval = std::clamp(value, RIDE_INSPECTION_EVERY_10_MINUTES, RIDE_INSPECTION_NEVER); + } + } + Ride* GetRide() const { return get_ride(_rideId); @@ -593,6 +623,9 @@ namespace OpenRCT2::Scripting dukglue_register_property(ctx, &ScRide::nausea_get, &ScRide::nausea_set, "nausea"); dukglue_register_property(ctx, &ScRide::totalCustomers_get, &ScRide::totalCustomers_set, "totalCustomers"); dukglue_register_property(ctx, &ScRide::buildDate_get, &ScRide::buildDate_set, "buildDate"); + dukglue_register_property(ctx, &ScRide::runningCost_get, &ScRide::runningCost_set, "runningCost"); + dukglue_register_property( + ctx, &ScRide::inspectionInterval_get, &ScRide::inspectionInterval_set, "inspectionInterval"); } }; } // namespace OpenRCT2::Scripting