Fix stats

This commit is contained in:
Federico Cecchetto 2022-03-18 00:27:13 +01:00
parent f6fd11d662
commit 3471ae9dd8

View File

@ -21,7 +21,7 @@ namespace stats
utils::hook::detour is_item_unlocked_hook2; utils::hook::detour is_item_unlocked_hook2;
utils::hook::detour is_item_unlocked_hook3; 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) if (cg_unlock_all_items->current.enabled)
{ {
@ -31,7 +31,7 @@ namespace stats
return is_item_unlocked_hook.invoke<int>(a1, a2, a3); return is_item_unlocked_hook.invoke<int>(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) if (cg_unlock_all_items->current.enabled)
{ {
@ -41,7 +41,7 @@ namespace stats
return is_item_unlocked_hook2.invoke<int>(a1, a2, a3, a4, a5, a6); return is_item_unlocked_hook2.invoke<int>(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) if (cg_unlock_all_items->current.enabled)
{ {
@ -50,6 +50,11 @@ namespace stats
return is_item_unlocked_hook3.invoke<int>(a1); return is_item_unlocked_hook3.invoke<int>(a1);
} }
int is_item_unlocked()
{
return 0;
}
} }
class component final : public component_interface class component final : public component_interface
@ -57,19 +62,28 @@ namespace stats
public: public:
void post_unpack() override void post_unpack() override
{ {
if (!game::environment::is_mp()) if (game::environment::is_sp())
{ {
return; return;
} }
cg_unlock_all_items = dvars::register_bool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED, if (game::environment::is_dedi())
"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, utils::hook::jump(0x140413E60, is_item_unlocked);
"Whether classes should be locked based on the player's stats or always 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_hook.create(0x140413E60, is_item_unlocked_stub);
is_item_unlocked_hook2.create(0x140413860, is_item_unlocked_stub2); is_item_unlocked_hook2.create(0x140413860, is_item_unlocked_stub2);
is_item_unlocked_hook3.create(0x140412B70, is_item_unlocked_stub3); is_item_unlocked_hook3.create(0x140412B70, is_item_unlocked_stub3);
}
} }
}; };
} }