diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 7cd12a43e9..5c296f5854 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -5,6 +5,7 @@ - Change: [#26689] A clear scenario editor can now be opened directly from the command line. - Fix: [#26494] The limits for where walls on the path side of the first tile block the view of rides/scenery are wrong (original bug). - Fix: [#26504] The boosts/penalties to excitement and nausea that air time provides are calculated wrong. +- Fix: [#26545] Game crashes when plugin API function generateGuest fails to generate a guest. 0.5.2 (2026-06-07) ------------------------------------------------------------------------ diff --git a/distribution/scripting/openrct2.d.ts b/distribution/scripting/openrct2.d.ts index 8770aff4d4..aadd336961 100644 --- a/distribution/scripting/openrct2.d.ts +++ b/distribution/scripting/openrct2.d.ts @@ -4282,10 +4282,11 @@ declare global { readonly guestGenerationProbability: number; /** - * Spawns a new guest at a random peep spawn point. + * Spawns a new guest at a random peep spawn point, or null if a guest could not + * spawn due to entity limits or no spawn points. * Note: The "guest.generation" hook will be called before this function returns. */ - generateGuest(): Guest; + generateGuest(): Guest | null; /** * The average amount of cash guests will spawn with. diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index 0042ccf60d..0992f669f0 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -43,7 +43,7 @@ namespace OpenRCT2 namespace OpenRCT2::Scripting { // Grepped from CI (.github/workflows/publish-plugin-types.yml); keep the format `kPluginApiVersion = N`. - static constexpr int32_t kPluginApiVersion = 114; + static constexpr int32_t kPluginApiVersion = 115; // Versions marking breaking changes. static constexpr int32_t kApiVersionPeepDeprecation = 33; diff --git a/src/openrct2/scripting/bindings/world/ScPark.cpp b/src/openrct2/scripting/bindings/world/ScPark.cpp index 66e786c175..4153c3a29b 100644 --- a/src/openrct2/scripting/bindings/world/ScPark.cpp +++ b/src/openrct2/scripting/bindings/world/ScPark.cpp @@ -161,6 +161,8 @@ namespace OpenRCT2::Scripting { JS_THROW_IF_GAME_STATE_NOT_MUTABLE(); auto guest = Park::GenerateGuest(); + if (guest == nullptr) + return JS_NULL; return ScGuest::New(ctx, guest->id); }