From cdb16bf8bba9bb6bd35ff2555080dad827c75dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sat, 24 Jun 2023 16:20:21 +0300 Subject: [PATCH 1/2] Fix crashes when custom plugin actions fail due to immutable state --- src/openrct2/scripting/ScriptEngine.cpp | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index f9f7ea3449..c064ca486d 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -1109,20 +1109,28 @@ GameActions::Result ScriptEngine::QueryOrExecuteCustomGameAction(const CustomAct GameActions::Result ScriptEngine::DukToGameActionResult(const DukValue& d) { auto result = GameActions::Result(); - result.Error = static_cast(AsOrDefault(d["error"])); - result.ErrorTitle = AsOrDefault(d["errorTitle"]); - result.ErrorMessage = AsOrDefault(d["errorMessage"]); - result.Cost = AsOrDefault(d["cost"]); - - auto expenditureType = AsOrDefault(d["expenditureType"]); - if (!expenditureType.empty()) + if (d.type() == DUK_TYPE_OBJECT) { - auto expenditure = StringToExpenditureType(expenditureType); - if (expenditure != ExpenditureType::Count) + result.Error = static_cast(AsOrDefault(d["error"])); + result.ErrorTitle = AsOrDefault(d["errorTitle"]); + result.ErrorMessage = AsOrDefault(d["errorMessage"]); + result.Cost = AsOrDefault(d["cost"]); + auto expenditureType = AsOrDefault(d["expenditureType"]); + if (!expenditureType.empty()) { - result.Expenditure = expenditure; + auto expenditure = StringToExpenditureType(expenditureType); + if (expenditure != ExpenditureType::Count) + { + result.Expenditure = expenditure; + } } } + else + { + result.Error = GameActions::Status::Unknown; + result.ErrorTitle = "Unknown"; + result.ErrorMessage = "Unknown"; + } return result; } From faded9936be2e84dcfa1baf9ac959e660dc03b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sat, 24 Jun 2023 20:42:51 +0300 Subject: [PATCH 2/2] Update changelog.txt --- distribution/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 21088f56ed..b2f0126ac2 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -9,6 +9,7 @@ - Fix: [#9534] Screams no longer cut-off on steep diagonal drops - Fix: [#19823] Parkobj: disallow overriding objects of different object types. - Fix: [#20083] Cannot use terrain surfaces with ID > 32 and terrain edges with ID > 16. +- Fix: [#20103] [Plugin] Crash when custom plugin actions fail due to immutable state. - Fix: [#20111] All coaster types can access the new diagonal slope pieces. - Fix: [#20155] Fairground organ style 2 shows up as regular music, rather than for the merry-go-round. - Fix: [#20260] Ride locks up when inspecting/fixing staff member is fired.