Skip to content

Commit

Permalink
Try block in notify
Browse files Browse the repository at this point in the history
  • Loading branch information
alicealys committed Apr 29, 2022
1 parent 8f6a927 commit 31e1b9b
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/client/game/ui_scripting/execution.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <std_include.hpp>
#include "execution.hpp"
#include "component/ui_scripting.hpp"
#include "component/game_console.hpp"

#include <utils/string.hpp>

Expand Down Expand Up @@ -88,22 +89,31 @@ namespace ui_scripting
const auto _1 = gsl::finally(game::LUI_LeaveCriticalSection);
game::LUI_EnterCriticalSection();

const auto globals = table((*::game::hks::lua_state)->globals.v.table);
const auto engine = globals.get("Engine").as<table>();
const auto root = engine.get("GetLuiRoot")()[0].as<userdata>();
const auto process_event = root.get("processEvent");

table event{};
event.set("name", name);
event.set("dispatchChildren", true);

for (const auto& arg : arguments)
try
{
const auto globals = table((*::game::hks::lua_state)->globals.v.table);
const auto engine = globals.get("Engine").as<table>();
const auto root = engine.get("GetLuiRoot")()[0].as<userdata>();
const auto process_event = root.get("processEvent");

table event{};
event.set("name", name);
event.set("dispatchChildren", true);

for (const auto& arg : arguments)
{
event.set(arg.first, arg.second);
}

process_event(root, event);
return true;
}
catch (const std::exception& e)
{
event.set(arg.first, arg.second);
game_console::print(game_console::con_type_error, "Error processing event '%s' %s\n", name.data(), e.what());
}

process_event(root, event);
return true;
return false;
}

arguments call_script_function(const function& function, const arguments& arguments)
Expand Down

0 comments on commit 31e1b9b

Please sign in to comment.