From 8071edfc55611647d16b73e1e4661dffca25838c Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Fri, 18 Mar 2022 00:27:13 +0100 Subject: [PATCH] Fix stats --- src/client/component/stats.cpp | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/client/component/stats.cpp b/src/client/component/stats.cpp index 81e7c3da..99ffdd5f 100644 --- a/src/client/component/stats.cpp +++ b/src/client/component/stats.cpp @@ -21,7 +21,7 @@ namespace stats utils::hook::detour is_item_unlocked_hook2; utils::hook::detour is_item_unlocked_hook3; - int is_item_unlocked_stub(void* a1, void* a2, void* a3) + int is_item_unlocked_stub(int a1, void* a2, int a3) { if (cg_unlock_all_items->current.enabled) { @@ -31,7 +31,7 @@ namespace stats return is_item_unlocked_hook.invoke(a1, a2, a3); } - int is_item_unlocked_stub2(void* a1, void* a2, void* a3, void* a4, void* a5, void* a6) + int is_item_unlocked_stub2(int a1, void* a2, void* a3, void* a4, int a5, void* a6) { if (cg_unlock_all_items->current.enabled) { @@ -41,7 +41,7 @@ namespace stats return is_item_unlocked_hook2.invoke(a1, a2, a3, a4, a5, a6); } - int is_item_unlocked_stub3(void* a1) + int is_item_unlocked_stub3(int a1) { if (cg_unlock_all_items->current.enabled) { @@ -50,6 +50,11 @@ namespace stats return is_item_unlocked_hook3.invoke(a1); } + + int is_item_unlocked() + { + return 0; + } } class component final : public component_interface @@ -57,19 +62,28 @@ namespace stats public: void post_unpack() override { - if (!game::environment::is_mp()) + if (game::environment::is_sp()) { return; } - cg_unlock_all_items = dvars::register_bool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED, - "Whether items should be locked based on the player's stats or always unlocked."); - dvars::register_bool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED, - "Whether classes should be locked based on the player's stats or always unlocked."); + if (game::environment::is_dedi()) + { + utils::hook::jump(0x140413E60, is_item_unlocked); + utils::hook::jump(0x140413860, is_item_unlocked); + utils::hook::jump(0x140412B70, is_item_unlocked); + } + else + { + cg_unlock_all_items = dvars::register_bool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED, + "Whether items should be locked based on the player's stats or always unlocked."); + dvars::register_bool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED, + "Whether classes should be locked based on the player's stats or always unlocked."); - is_item_unlocked_hook.create(0x140413E60, is_item_unlocked_stub); - is_item_unlocked_hook2.create(0x140413860, is_item_unlocked_stub2); - is_item_unlocked_hook3.create(0x140412B70, is_item_unlocked_stub3); + is_item_unlocked_hook.create(0x140413E60, is_item_unlocked_stub); + is_item_unlocked_hook2.create(0x140413860, is_item_unlocked_stub2); + is_item_unlocked_hook3.create(0x140412B70, is_item_unlocked_stub3); + } } }; }