mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Fix plugin game action hook player and result (#11587)
- Player was not being attached to the game action event args. - OpenRCT2 was looking for error on the event args object rather than the result sub object.
This commit is contained in:
parent
32eb7071a1
commit
e3016cdc03
2 changed files with 11 additions and 6 deletions
2
distribution/openrct2.d.ts
vendored
2
distribution/openrct2.d.ts
vendored
|
@ -242,7 +242,7 @@ declare global {
|
|||
}
|
||||
|
||||
interface GameActionResult {
|
||||
error?: string;
|
||||
error?: number;
|
||||
errorTitle?: string;
|
||||
errorMessage?: string;
|
||||
position?: Coord3;
|
||||
|
|
|
@ -942,6 +942,7 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, std::unique_ptr<
|
|||
if (_hookEngine.HasSubscriptions(hookType))
|
||||
{
|
||||
DukObject obj(_context);
|
||||
obj.Set("player", action.GetPlayer());
|
||||
obj.Set("type", action.GetType());
|
||||
|
||||
auto flags = action.GetActionFlags();
|
||||
|
@ -957,12 +958,16 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, std::unique_ptr<
|
|||
|
||||
if (!isExecute)
|
||||
{
|
||||
auto error = AsOrDefault<int32_t>(dukEventArgs["error"]);
|
||||
if (error != 0)
|
||||
auto dukResult = dukEventArgs["result"];
|
||||
if (dukResult.type() == DukValue::Type::OBJECT)
|
||||
{
|
||||
result->Error = static_cast<GA_ERROR>(error);
|
||||
result->ErrorTitle = AsOrDefault<std::string>(dukEventArgs["errorTitle"]);
|
||||
result->ErrorMessage = AsOrDefault<std::string>(dukEventArgs["errorMessage"]);
|
||||
auto error = AsOrDefault<int32_t>(dukResult["error"]);
|
||||
if (error != 0)
|
||||
{
|
||||
result->Error = static_cast<GA_ERROR>(error);
|
||||
result->ErrorTitle = AsOrDefault<std::string>(dukResult["errorTitle"]);
|
||||
result->ErrorMessage = AsOrDefault<std::string>(dukResult["errorMessage"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue