mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #20462 from ZehMatt/script-crash
Fix crashes when custom plugin actions fail due to immutable state
This commit is contained in:
commit
49c5ceda66
|
@ -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.
|
||||
|
|
|
@ -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<GameActions::Status>(AsOrDefault<int32_t>(d["error"]));
|
||||
result.ErrorTitle = AsOrDefault<std::string>(d["errorTitle"]);
|
||||
result.ErrorMessage = AsOrDefault<std::string>(d["errorMessage"]);
|
||||
result.Cost = AsOrDefault<int32_t>(d["cost"]);
|
||||
|
||||
auto expenditureType = AsOrDefault<std::string>(d["expenditureType"]);
|
||||
if (!expenditureType.empty())
|
||||
if (d.type() == DUK_TYPE_OBJECT)
|
||||
{
|
||||
auto expenditure = StringToExpenditureType(expenditureType);
|
||||
if (expenditure != ExpenditureType::Count)
|
||||
result.Error = static_cast<GameActions::Status>(AsOrDefault<int32_t>(d["error"]));
|
||||
result.ErrorTitle = AsOrDefault<std::string>(d["errorTitle"]);
|
||||
result.ErrorMessage = AsOrDefault<std::string>(d["errorMessage"]);
|
||||
result.Cost = AsOrDefault<int32_t>(d["cost"]);
|
||||
auto expenditureType = AsOrDefault<std::string>(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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue