From 8f6a9277924c5733167a3a8b287917de6854deae Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 30 Apr 2022 00:17:21 +0200 Subject: [PATCH] Small fix --- src/client/component/ui_scripting.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index fb4681d7..6b6056c8 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -351,24 +351,37 @@ namespace ui_scripting } } - void* hks_start_stub(char a1) + void try_start() { - const auto _ = gsl::finally(&start); - return hks_start_hook.invoke(a1); + try + { + start(); + } + catch (const std::exception& e) + { + game_console::print(game_console::con_type_error, "Failed to load LUI scripts: %s\n", e.what()); + } + } + + void hks_start_stub(char a1) + { + const auto _0 = gsl::finally(&try_start); + return hks_start_hook.invoke(a1); } void hks_shutdown_stub() { converted_functions.clear(); - hks_shutdown_hook.invoke(); + globals = {}; + hks_shutdown_hook.invoke(); } - void hks_package_require_stub(game::hks::lua_State* state) + void* hks_package_require_stub(game::hks::lua_State* state) { const auto script = get_current_script(); const auto root = get_root_script(script); globals.in_require_script = root; - hks_package_require_hook.invoke(state); + return hks_package_require_hook.invoke(state); } game::XAssetHeader db_find_xasset_header_stub(game::XAssetType type, const char* name, int allow_create_default)