From 705ad50d65e415131995ae6b639fa070cb6cc8a6 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sun, 7 Nov 2021 02:33:16 +0100 Subject: [PATCH] Fixes for pluto update --- src/component/gsc.cpp | 75 ++------------------------------ src/component/gsc.hpp | 2 - src/component/scripting.cpp | 1 - src/game/scripting/functions.cpp | 6 +-- 4 files changed, 7 insertions(+), 77 deletions(-) diff --git a/src/component/gsc.cpp b/src/component/gsc.cpp index 30cf674..203f056 100644 --- a/src/component/gsc.cpp +++ b/src/component/gsc.cpp @@ -14,8 +14,6 @@ namespace gsc { - std::unordered_map replaced_functions; - function_args::function_args(std::vector values) : values_(values) { @@ -109,7 +107,7 @@ namespace gsc { if (id < 0x200) { - return reinterpret_cast(0x1D6EB34)[id](); + return reinterpret_cast(0x20689DD8)[id](); } try @@ -135,7 +133,7 @@ namespace gsc { if (id < 0x8400) { - return reinterpret_cast(0x1D4F258)[id](ent); + return reinterpret_cast(0x2068A5A8)[id - 0x8000](ent); } try @@ -201,62 +199,6 @@ namespace gsc retn } } - - const char* replaced_pos = 0; - - void get_replaced_pos(const char* pos) - { - if (replaced_functions.find(pos) != replaced_functions.end()) - { - replaced_pos = replaced_functions[pos]; - } - } - - __declspec(naked) void vm_execute_stub() - { - __asm - { - pushad - push esi - call get_replaced_pos - pop esi - popad - - cmp replaced_pos, 0 - jne set_pos - - movzx eax, byte ptr[esi] - inc esi - - jmp loc_1 - loc_1: - mov [ebp - 0x18], eax - mov [ebp - 0x8], esi - - push ecx - - mov ecx, 0x20B8E28 - mov [ecx], eax - - mov ecx, 0x20B4A5C - mov[ecx], esi - - pop ecx - - cmp eax, 0x98 - - push 0x56B740 - retn - set_pos: - mov esi, replaced_pos - mov replaced_pos, 0 - - movzx eax, byte ptr[esi] - inc esi - - jmp loc_1 - } - } } namespace function @@ -292,16 +234,6 @@ namespace gsc return {}; }); - function::add("replacefunc", [](const function_args& args) -> scripting::script_value - { - const auto what = args[0].as(); - const auto with = args[1].as(); - - replaced_functions[what.get_pos()] = with.get_pos(); - - return {}; - }); - function::add("addcommand", [](const function_args& args) -> scripting::script_value { const auto name = args[0].as(); @@ -360,11 +292,12 @@ namespace gsc playerState->perks[0] = toggle ? flags | 0x4000u : flags & ~0x4000u; + + return {}; }); utils::hook::jump(0x56C8EB, call_builtin_stub); utils::hook::jump(0x56CBDC, call_builtin_method_stub); - utils::hook::jump(0x56B726, vm_execute_stub); } }; } diff --git a/src/component/gsc.hpp b/src/component/gsc.hpp index 4447b9f..8b9c687 100644 --- a/src/component/gsc.hpp +++ b/src/component/gsc.hpp @@ -2,8 +2,6 @@ namespace gsc { - extern std::unordered_map replaced_functions; - class function_args { public: diff --git a/src/component/scripting.cpp b/src/component/scripting.cpp index 8255cf5..a9e0ecf 100644 --- a/src/component/scripting.cpp +++ b/src/component/scripting.cpp @@ -77,7 +77,6 @@ namespace scripting { userinfo::clear_overrides(); command::clear_script_commands(); - gsc::replaced_functions.clear(); g_shutdown_game_hook.invoke(free_scripts); } diff --git a/src/game/scripting/functions.cpp b/src/game/scripting/functions.cpp index b827de4..cfb2665 100644 --- a/src/game/scripting/functions.cpp +++ b/src/game/scripting/functions.cpp @@ -59,15 +59,15 @@ namespace scripting script_function get_function_by_index(const unsigned index) { - static const auto function_table = 0x1D6EB34; - static const auto method_table = 0x1D4F258; + static const auto function_table = 0x20689DD8; + static const auto method_table = 0x2068A5A8; if (index < 0x1C7) { return reinterpret_cast(function_table)[index]; } - return reinterpret_cast(method_table)[index]; + return reinterpret_cast(method_table)[index - 0x8000]; } }