diff --git a/src/component/gsc.cpp b/src/component/gsc.cpp index 38074fd..92d2173 100644 --- a/src/component/gsc.cpp +++ b/src/component/gsc.cpp @@ -248,16 +248,21 @@ namespace gsc { void add(const std::string& name, const script_function& func) { - try + auto index = 0u; + auto& ctx = (*game::plutonium::gsc_ctx); + + if (ctx->func_exists(name)) { - const auto index = function_map_start++; - functions[index] = func; - (*game::plutonium::gsc_ctx)->func_add(name, index); + printf("[iw5-gsc-utils] Warning: function '%s' already defined\n", name.data()); + index = ctx->func_id(name); } - catch (const std::exception& e) + else { - printf("[iw5-gsc-utils] failed to add function \"%s\": %s\n", name.data(), e.what()); + index = function_map_start++; + ctx->func_add(name, index); } + + functions.insert(std::make_pair(index, func)); } } @@ -265,16 +270,21 @@ namespace gsc { void add(const std::string& name, const script_method& func) { - try + auto index = 0u; + auto& ctx = (*game::plutonium::gsc_ctx); + + if (ctx->meth_exists(name)) { - const auto index = method_map_start++; - methods[index] = func; - (*game::plutonium::gsc_ctx)->meth_add(name, index); + printf("[iw5-gsc-utils] Warning: method '%s' already defined\n", name.data()); + index = ctx->meth_id(name); } - catch (const std::exception& e) + else { - printf("[iw5-gsc-utils] failed to add method \"%s\": %s\n", name.data(), e.what()); + index = method_map_start++; + ctx->meth_add(name, index); } + + methods.insert(std::make_pair(index, func)); } } diff --git a/src/component/io.cpp b/src/component/io.cpp index de02ceb..35ba2e2 100644 --- a/src/component/io.cpp +++ b/src/component/io.cpp @@ -179,4 +179,4 @@ namespace io }; } -REGISTER_COMPONENT(io::component) \ No newline at end of file +REGISTER_COMPONENT(io::component) diff --git a/src/component/json.cpp b/src/component/json.cpp index d7e85ba..b3c632c 100644 --- a/src/component/json.cpp +++ b/src/component/json.cpp @@ -194,4 +194,4 @@ namespace json }; } -REGISTER_COMPONENT(json::component) \ No newline at end of file +REGISTER_COMPONENT(json::component) diff --git a/src/component/notifies.cpp b/src/component/notifies.cpp index 825c2c9..a5a5d22 100644 --- a/src/component/notifies.cpp +++ b/src/component/notifies.cpp @@ -71,4 +71,4 @@ namespace notifies }; } -REGISTER_COMPONENT(notifies::component) \ No newline at end of file +REGISTER_COMPONENT(notifies::component) diff --git a/src/component/scripting.cpp b/src/component/scripting.cpp index b108300..322bc8e 100644 --- a/src/component/scripting.cpp +++ b/src/component/scripting.cpp @@ -136,4 +136,4 @@ namespace scripting }; } -REGISTER_COMPONENT(scripting::component) \ No newline at end of file +REGISTER_COMPONENT(scripting::component) diff --git a/src/component/signatures.cpp b/src/component/signatures.cpp index 416e3e7..0e962fa 100644 --- a/src/component/signatures.cpp +++ b/src/component/signatures.cpp @@ -35,11 +35,18 @@ namespace signatures const auto base = reinterpret_cast(GetModuleHandle("plutonium-bootstrapper-win32.exe")); utils::hook::signature signature(base, get_image_size() - base); + auto found = false; signature.add({ string, mask, [&](char* address) { + if (found) + { + return; + } + + found = true; string_ptr = address; } }); @@ -70,7 +77,6 @@ namespace signatures } const auto gsc_ctx_ptr = *reinterpret_cast(string_ref - 0xAD); - OutputDebugString(utils::string::va("string_ref: %p\n", string_ref)); OutputDebugString(utils::string::va("gsc_ctx_ptr: %p\n", gsc_ctx_ptr)); game::plutonium::gsc_ctx.set(gsc_ctx_ptr); return true; diff --git a/src/component/userinfo.cpp b/src/component/userinfo.cpp index 9f4c742..ca69326 100644 --- a/src/component/userinfo.cpp +++ b/src/component/userinfo.cpp @@ -193,4 +193,4 @@ namespace userinfo }; } -REGISTER_COMPONENT(userinfo::component) \ No newline at end of file +REGISTER_COMPONENT(userinfo::component)