From 1441efaa061686efaffc2df304f2ebb858dba246 Mon Sep 17 00:00:00 2001 From: quaK <38787176+Joelrau@users.noreply.github.com> Date: Wed, 26 Apr 2023 22:02:05 +0300 Subject: [PATCH] Small gsc fixes --- src/client/component/gsc/script_extension.cpp | 2 -- src/client/component/gsc/script_loading.cpp | 6 +++++ src/client/component/scripting.cpp | 23 +++++-------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/client/component/gsc/script_extension.cpp b/src/client/component/gsc/script_extension.cpp index afe0e679..e5230cb6 100644 --- a/src/client/component/gsc/script_extension.cpp +++ b/src/client/component/gsc/script_extension.cpp @@ -344,8 +344,6 @@ namespace gsc utils::hook::inject(SELECT_VALUE(0x3BDC36_b, 0x504C66_b) + 3, &meth_table); utils::hook::set(SELECT_VALUE(0x3BDC3F_b, 0x504C6F_b), sizeof(meth_table)); - developer_script = dvars::register_bool("developer_script", false, 0, "Enable developer script comments"); - utils::hook::nop(SELECT_VALUE(0x3CB723_b, 0x512783_b), 8); utils::hook::call(SELECT_VALUE(0x3CB723_b, 0x512783_b), vm_call_builtin_function_stub); diff --git a/src/client/component/gsc/script_loading.cpp b/src/client/component/gsc/script_loading.cpp index 7cd16ea1..4a2d5a9f 100644 --- a/src/client/component/gsc/script_loading.cpp +++ b/src/client/component/gsc/script_loading.cpp @@ -430,6 +430,12 @@ namespace gsc } }); } + + void pre_destroy() override + { + scr_begin_load_scripts_hook.clear(); + scr_end_load_scripts_hook.clear(); + } }; } diff --git a/src/client/component/scripting.cpp b/src/client/component/scripting.cpp index 4efc6df4..79cd5701 100644 --- a/src/client/component/scripting.cpp +++ b/src/client/component/scripting.cpp @@ -63,7 +63,7 @@ namespace scripting const auto* string = game::SL_ConvertToString(string_value); if (string) { - event e; + event e{}; e.name = string; e.entity = notify_list_owner_id; @@ -159,6 +159,7 @@ namespace scripting if (file_id) { current_file_id = static_cast(file_id); + current_file = scripting::get_token(current_file_id); } else { @@ -172,10 +173,6 @@ namespace scripting void add_function_sort(unsigned int id, const char* pos) { std::string filename = current_file; - if (current_file_id) - { - filename = scripting::get_token(current_file_id); - } if (!script_function_table_sort.contains(filename)) { @@ -203,15 +200,7 @@ namespace scripting { add_function_sort(thread_name, code_pos); - if (current_file_id) - { - const auto name = get_token(current_file_id); - add_function(name, thread_name, code_pos); - } - else - { - add_function(current_file, thread_name, code_pos); - } + add_function(current_file, thread_name, code_pos); scr_set_thread_position_hook.invoke(thread_name, code_pos); } @@ -252,12 +241,12 @@ namespace scripting std::optional get_canonical_string(const unsigned int id) { - if (const auto itr = canonical_string_table.find(id); itr != canonical_string_table.end()) + if (canonical_string_table.find(id) == canonical_string_table.end()) { - return itr->second; + return {}; } - return {}; + return {canonical_string_table[id]}; } class component final : public component_interface