From 0a5f145ae5e51afddb76fa6905d7d82656c4f604 Mon Sep 17 00:00:00 2001 From: MarkAlliban <115544029+MarkAlliban@users.noreply.github.com> Date: Wed, 21 Oct 2026 10:06:21 +0100 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=98popularity=E2=80=99=20to=20plugi?= =?UTF-8?q?n,=20fix=20values=20for=20=E2=80=98satisfaction=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contributors.md | 1 + distribution/scripting/openrct2.d.ts | 9 +++++++-- src/openrct2/scripting/bindings/ride/ScRide.cpp | 13 ++++++++++++- src/openrct2/scripting/bindings/ride/ScRide.hpp | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/contributors.md b/contributors.md index f05c48b141..12f6d6343a 100644 --- a/contributors.md +++ b/contributors.md @@ -132,6 +132,7 @@ Appreciation for contributors who have provided substantial work, but are no lon * Ben Spurlock (BenDaSpur) - Plugin API automation helpers * (frozensnowy) - Draggable path slopes, self-intersecting track designs, refactors, bug fixes, misc. * Arjan van Dijk (Manticore-007) - Added guests entertained to API. +* Mark Alliban (MarkAlliban) - Added plugin API fields. ## Bug fixes & Refactors * Claudio Tiecher (janclod) diff --git a/distribution/scripting/openrct2.d.ts b/distribution/scripting/openrct2.d.ts index 39830f227a..d4c8e32aab 100644 --- a/distribution/scripting/openrct2.d.ts +++ b/distribution/scripting/openrct2.d.ts @@ -2530,9 +2530,14 @@ declare global { readonly minLiftHillSpeed: number; /** - * The satisfaction rating of the ride from 0 to 100. + * The satisfaction rating of the ride from 0 to 100, or NULL if not yet calculated. */ - readonly satisfaction: number; + readonly satisfaction: number | null; + + /** + * The popularity rating of the ride from 0 to 100, or NULL if not calculated. + */ + readonly popularity: number | null; /** * The max speed in miles per hour. diff --git a/src/openrct2/scripting/bindings/ride/ScRide.cpp b/src/openrct2/scripting/bindings/ride/ScRide.cpp index 0669b77c55..ccf31aa7dc 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.cpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.cpp @@ -63,6 +63,7 @@ namespace OpenRCT2::Scripting JS_CGETSET_DEF("maxLiftHillSpeed", ScRide::maxLiftHillSpeed_get, nullptr), JS_CGETSET_DEF("minLiftHillSpeed", ScRide::minLiftHillSpeed_get, nullptr), JS_CGETSET_DEF("satisfaction", ScRide::satisfaction_get, nullptr), + JS_CGETSET_DEF("popularity", ScRide::popularity_get, nullptr), JS_CGETSET_DEF("maxSpeed", ScRide::maxSpeed_get, nullptr), JS_CGETSET_DEF("averageSpeed", ScRide::averageSpeed_get, nullptr), JS_CGETSET_DEF("rideTime", ScRide::rideTime_get, nullptr), @@ -732,7 +733,17 @@ namespace OpenRCT2::Scripting JSValue ScRide::satisfaction_get(JSContext* ctx, JSValue thisVal) { auto ride = GetRide(thisVal); - return JS_NewUint32(ctx, ride != nullptr ? ride->satisfaction * 5 : 0); + if (ride == nullptr || ride->satisfaction == 255) + return JS_NULL; + return JS_NewUint32(ctx, ride->satisfaction * 5); + } + + JSValue ScRide::popularity_get(JSContext* ctx, JSValue thisVal) + { + auto ride = GetRide(thisVal); + if (ride == nullptr || ride->popularity == 255) + return JS_NULL; + return JS_NewUint32(ctx, ride->popularity * 4); } JSValue ScRide::maxSpeed_get(JSContext* ctx, JSValue thisVal) diff --git a/src/openrct2/scripting/bindings/ride/ScRide.hpp b/src/openrct2/scripting/bindings/ride/ScRide.hpp index 276487155c..69e42e5d79 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.hpp @@ -133,6 +133,7 @@ namespace OpenRCT2::Scripting static JSValue maxLiftHillSpeed_get(JSContext* ctx, JSValue thisVal); static JSValue minLiftHillSpeed_get(JSContext* ctx, JSValue thisVal); static JSValue satisfaction_get(JSContext* ctx, JSValue thisVal); + static JSValue popularity_get(JSContext* ctx, JSValue thisVal); static JSValue maxSpeed_get(JSContext* ctx, JSValue thisVal); static JSValue averageSpeed_get(JSContext* ctx, JSValue thisVal); static JSValue rideTime_get(JSContext* ctx, JSValue thisVal);