From 78eadd4eb1b70fb7be47a412da3ce582d211a089 Mon Sep 17 00:00:00 2001 From: rackover Date: Fri, 2 Jul 2021 11:43:04 +0200 Subject: [PATCH 1/7] WIP entity skipping --- src/Components/Modules/QuickPatch.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 4b0e78b3..69bc0e66 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -396,6 +396,28 @@ namespace Components return std::function < T >(reinterpret_cast(procAddr)); } + int __cdecl G_ParseSpawnVars(Game::SpawnVar* spawnVar){ + if (Zones::Version() >= VERSION_ALPHA2) { + for (auto i = 0; i < spawnVar->numSpawnVars; i++) + { + char** kvPair = spawnVar->spawnVars[i]; + auto key = kvPair[0]; + auto val = kvPair[1]; + + bool isSpecOps = strncmp(key, "script_specialops", 16) == 0; + bool isSpecOpsOnly = *val == 49; // 49 => Ascii "1" + + if (isSpecOps && isSpecOpsOnly) { + spawnVar->spawnVars[i] = nullptr; + } + } + } + + Components::Logger::Print("G_SpawnString: %s %d\n", spawnVar->spawnVarChars, spawnVar->numSpawnVarChars); + + return Utils::Hook::Call(0x4B3410)(spawnVar); + } + QuickPatch::QuickPatch() { QuickPatch::FrameTime = 0; @@ -439,6 +461,10 @@ namespace Components (0xC000007B /*0x0000000A*/, 0, nullptr, nullptr, OptionShutdownSystem, &response); }); + Utils::Hook(0x4D8845, G_ParseSpawnVars, HOOK_CALL).install()->quick(); + Utils::Hook(0x4D8880, G_ParseSpawnVars, HOOK_CALL).install()->quick(); + Utils::Hook(0x4D886A, G_ParseSpawnVars, HOOK_CALL).install()->quick(); + // bounce dvar sv_enableBounces = Game::Dvar_RegisterBool("sv_enableBounces", false, Game::DVAR_FLAG_REPLICATED, "Enables bouncing on the server"); Utils::Hook(0x4B1B2D, QuickPatch::BounceStub, HOOK_JUMP).install()->quick(); From 993fe28a37daf3b8c40a1f867ccaa9f8c21a428f Mon Sep 17 00:00:00 2001 From: rackover Date: Sun, 4 Jul 2021 18:44:25 +0200 Subject: [PATCH 2/7] Wip skip specops entities part 2 --- src/Components/Modules/QuickPatch.cpp | 81 ++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 13 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 69bc0e66..7e4d5bcd 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -396,28 +396,81 @@ namespace Components return std::function < T >(reinterpret_cast(procAddr)); } - int __cdecl G_ParseSpawnVars(Game::SpawnVar* spawnVar){ - if (Zones::Version() >= VERSION_ALPHA2) { - for (auto i = 0; i < spawnVar->numSpawnVars; i++) + //int __cdecl G_ParseSpawnVars(Game::SpawnVar* spawnVar){ + // if (Zones::Version() >= VERSION_ALPHA2) { + // bool shouldBeRemoved = false; + + + // for (auto i = 0; i < spawnVar->numSpawnVars; i++) + // { + // char** kvPair = spawnVar->spawnVars[i]; + // auto key = kvPair[0]; + // auto val = kvPair[1]; + // + // bool isSpecOps = strncmp(key, "script_specialops", 16) == 0; + // bool isSpecOpsOnly = *val == 49; // 49 => Ascii "1" + + // if (isSpecOps && isSpecOpsOnly) { + // shouldBeRemoved = true; + // break; + // } + // } + + // if (shouldBeRemoved) { + // for (auto i = 0; i < spawnVar->numSpawnVars; i++) + // { + // char** kvPair = spawnVar->spawnVars[i]; + // auto key = kvPair[0]; + // auto val = kvPair[1]; + + // bool isClassName = strncmp(key, "classname", 9) == 0; + + // if (isClassName) { + // val = "dyn_lmao"; + // } + // } + // } + + // if (shouldBeRemoved) { + // spawnVar->numSpawnVars = 0; + // spawnVar->numSpawnVarChars = 0; + // spawnVar->spawnVarsValid = false; + + // //Components::Logger::Print("G_SpawnString: Removed %s\n", spawnVar->spawnVarChars); + // } + // } + // + // return Utils::Hook::Call(0x4B3410)(spawnVar); + //} + + BOOL __cdecl IsDynClassname(char* a1) { + //if (Zones::Version() >= VERSION_ALPHA2) { + bool shouldBeRemoved = false; + + + for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++) { - char** kvPair = spawnVar->spawnVars[i]; + char** kvPair = Game::spawnVars->spawnVars[i]; auto key = kvPair[0]; auto val = kvPair[1]; - + bool isSpecOps = strncmp(key, "script_specialops", 16) == 0; bool isSpecOpsOnly = *val == 49; // 49 => Ascii "1" if (isSpecOps && isSpecOpsOnly) { - spawnVar->spawnVars[i] = nullptr; + Components::Logger::Print("Prevented spawning of entity: %s\n", Game::spawnVars->spawnVarChars); + return true; // This will prevent spawning hopefully; } } - } + //} - Components::Logger::Print("G_SpawnString: %s %d\n", spawnVar->spawnVarChars, spawnVar->numSpawnVarChars); - - return Utils::Hook::Call(0x4B3410)(spawnVar); + return Utils::Hook::Call(0x444810)(a1); } + //void __cdecl G_SpawnItem(Game::gentity_s* a1, signed int a2) { + + //} + QuickPatch::QuickPatch() { QuickPatch::FrameTime = 0; @@ -461,9 +514,11 @@ namespace Components (0xC000007B /*0x0000000A*/, 0, nullptr, nullptr, OptionShutdownSystem, &response); }); - Utils::Hook(0x4D8845, G_ParseSpawnVars, HOOK_CALL).install()->quick(); - Utils::Hook(0x4D8880, G_ParseSpawnVars, HOOK_CALL).install()->quick(); - Utils::Hook(0x4D886A, G_ParseSpawnVars, HOOK_CALL).install()->quick(); + Utils::Hook(0x5FBD6E, IsDynClassname, HOOK_CALL).install()->quick(); + + //Utils::Hook(0x4D8845, G_ParseSpawnVars, HOOK_CALL).install()->quick(); + //Utils::Hook(0x4D8880, G_ParseSpawnVars, HOOK_CALL).install()->quick(); + //Utils::Hook(0x4D886A, G_ParseSpawnVars, HOOK_CALL).install()->quick(); // bounce dvar sv_enableBounces = Game::Dvar_RegisterBool("sv_enableBounces", false, Game::DVAR_FLAG_REPLICATED, "Enables bouncing on the server"); From 6ab6f2cd625eb689f258fce04b51b8be688e4ac8 Mon Sep 17 00:00:00 2001 From: rackover Date: Mon, 5 Jul 2021 00:28:50 +0200 Subject: [PATCH 3/7] Remove extra fluff & useless comments --- src/Components/Modules/QuickPatch.cpp | 66 ++------------------------- src/Components/Modules/QuickPatch.hpp | 1 + 2 files changed, 4 insertions(+), 63 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 7e4d5bcd..b1320f9f 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -396,58 +396,7 @@ namespace Components return std::function < T >(reinterpret_cast(procAddr)); } - //int __cdecl G_ParseSpawnVars(Game::SpawnVar* spawnVar){ - // if (Zones::Version() >= VERSION_ALPHA2) { - // bool shouldBeRemoved = false; - - - // for (auto i = 0; i < spawnVar->numSpawnVars; i++) - // { - // char** kvPair = spawnVar->spawnVars[i]; - // auto key = kvPair[0]; - // auto val = kvPair[1]; - // - // bool isSpecOps = strncmp(key, "script_specialops", 16) == 0; - // bool isSpecOpsOnly = *val == 49; // 49 => Ascii "1" - - // if (isSpecOps && isSpecOpsOnly) { - // shouldBeRemoved = true; - // break; - // } - // } - - // if (shouldBeRemoved) { - // for (auto i = 0; i < spawnVar->numSpawnVars; i++) - // { - // char** kvPair = spawnVar->spawnVars[i]; - // auto key = kvPair[0]; - // auto val = kvPair[1]; - - // bool isClassName = strncmp(key, "classname", 9) == 0; - - // if (isClassName) { - // val = "dyn_lmao"; - // } - // } - // } - - // if (shouldBeRemoved) { - // spawnVar->numSpawnVars = 0; - // spawnVar->numSpawnVarChars = 0; - // spawnVar->spawnVarsValid = false; - - // //Components::Logger::Print("G_SpawnString: Removed %s\n", spawnVar->spawnVarChars); - // } - // } - // - // return Utils::Hook::Call(0x4B3410)(spawnVar); - //} - - BOOL __cdecl IsDynClassname(char* a1) { - //if (Zones::Version() >= VERSION_ALPHA2) { - bool shouldBeRemoved = false; - - + bool QuickPatch::IsDynClassnameStub(char* a1) { for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++) { char** kvPair = Game::spawnVars->spawnVars[i]; @@ -462,15 +411,10 @@ namespace Components return true; // This will prevent spawning hopefully; } } - //} - return Utils::Hook::Call(0x444810)(a1); + return Utils::Hook::Call(0x444810)(a1); } - //void __cdecl G_SpawnItem(Game::gentity_s* a1, signed int a2) { - - //} - QuickPatch::QuickPatch() { QuickPatch::FrameTime = 0; @@ -514,11 +458,7 @@ namespace Components (0xC000007B /*0x0000000A*/, 0, nullptr, nullptr, OptionShutdownSystem, &response); }); - Utils::Hook(0x5FBD6E, IsDynClassname, HOOK_CALL).install()->quick(); - - //Utils::Hook(0x4D8845, G_ParseSpawnVars, HOOK_CALL).install()->quick(); - //Utils::Hook(0x4D8880, G_ParseSpawnVars, HOOK_CALL).install()->quick(); - //Utils::Hook(0x4D886A, G_ParseSpawnVars, HOOK_CALL).install()->quick(); + Utils::Hook(0x5FBD6E, QuickPatch::IsDynClassnameStub, HOOK_CALL).install()->quick(); // bounce dvar sv_enableBounces = Game::Dvar_RegisterBool("sv_enableBounces", false, Game::DVAR_FLAG_REPLICATED, "Enables bouncing on the server"); diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index 37402355..1b0c979b 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -47,5 +47,6 @@ namespace Components static void PlayerCollisionStub(); static Game::dvar_t* g_playerEjection; static void PlayerEjectionStub(); + static bool IsDynClassnameStub(char* a1); }; } From e99b642cec58f2e8e20f2498e8a509460674ddb7 Mon Sep 17 00:00:00 2001 From: rackover Date: Mon, 5 Jul 2021 00:29:53 +0200 Subject: [PATCH 4/7] Whoops, forgot that print --- src/Components/Modules/QuickPatch.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index b1320f9f..d8ce4e2f 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -407,7 +407,6 @@ namespace Components bool isSpecOpsOnly = *val == 49; // 49 => Ascii "1" if (isSpecOps && isSpecOpsOnly) { - Components::Logger::Print("Prevented spawning of entity: %s\n", Game::spawnVars->spawnVarChars); return true; // This will prevent spawning hopefully; } } From 54df979c2b6324d72e9e3de6b777b44f228c8339 Mon Sep 17 00:00:00 2001 From: rackover Date: Mon, 5 Jul 2021 21:23:57 +0200 Subject: [PATCH 5/7] Add comments, improve clarity --- src/Components/Modules/QuickPatch.cpp | 30 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index d8ce4e2f..87bb93f3 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -396,21 +396,26 @@ namespace Components return std::function < T >(reinterpret_cast(procAddr)); } - bool QuickPatch::IsDynClassnameStub(char* a1) { - for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++) + bool QuickPatch::IsDynClassnameStub(char* a1) + { + for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++) + { + char** kvPair = Game::spawnVars->spawnVars[i]; + auto key = kvPair[0]; + auto val = kvPair[1]; + + bool isSpecOps = strncmp(key, "script_specialops", 17) == 0; + bool isSpecOpsOnly = val[0] == '1' && val[1] == '\0'; + + if (isSpecOps && isSpecOpsOnly) { - char** kvPair = Game::spawnVars->spawnVars[i]; - auto key = kvPair[0]; - auto val = kvPair[1]; - - bool isSpecOps = strncmp(key, "script_specialops", 16) == 0; - bool isSpecOpsOnly = *val == 49; // 49 => Ascii "1" - - if (isSpecOps && isSpecOpsOnly) { - return true; // This will prevent spawning hopefully; - } + // This will prevent spawning of any entity that contains "script_specialops: '1'" + // It removes extra hitboxes / meshes on 461+ CODO multiplayer maps + return true; } + } + // Passthrough to the game's own IsDynClassname return Utils::Hook::Call(0x444810)(a1); } @@ -457,6 +462,7 @@ namespace Components (0xC000007B /*0x0000000A*/, 0, nullptr, nullptr, OptionShutdownSystem, &response); }); + // Filtering any mapents that is intended for Spec:Ops gamemode (CODO) and prevent them from spawning Utils::Hook(0x5FBD6E, QuickPatch::IsDynClassnameStub, HOOK_CALL).install()->quick(); // bounce dvar From 2dd703c0379542806c3e9de4775bcc3c4dcdee9f Mon Sep 17 00:00:00 2001 From: Louvenarde Date: Wed, 28 Jul 2021 18:49:39 +0200 Subject: [PATCH 6/7] Another zones::version specific to the map --- src/Components/Modules/QuickPatch.cpp | 28 +++++++++++++++------------ src/Components/Modules/Zones.cpp | 3 +++ src/Components/Modules/Zones.hpp | 5 ++++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 73af2b27..be4b5a37 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -390,20 +390,24 @@ namespace Components bool QuickPatch::IsDynClassnameStub(char* a1) { - for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++) - { - char** kvPair = Game::spawnVars->spawnVars[i]; - auto key = kvPair[0]; - auto val = kvPair[1]; + auto version = Zones::GetEntitiesZoneVersion(); - bool isSpecOps = strncmp(key, "script_specialops", 17) == 0; - bool isSpecOpsOnly = val[0] == '1' && val[1] == '\0'; - - if (isSpecOps && isSpecOpsOnly) + if (version >= VERSION_LATEST_CODO) { + for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++) { - // This will prevent spawning of any entity that contains "script_specialops: '1'" - // It removes extra hitboxes / meshes on 461+ CODO multiplayer maps - return true; + char** kvPair = Game::spawnVars->spawnVars[i]; + auto key = kvPair[0]; + auto val = kvPair[1]; + + bool isSpecOps = strncmp(key, "script_specialops", 17) == 0; + bool isSpecOpsOnly = val[0] == '1' && val[1] == '\0'; + + if (isSpecOps && isSpecOpsOnly) + { + // This will prevent spawning of any entity that contains "script_specialops: '1'" + // It removes extra hitboxes / meshes on 461+ CODO multiplayer maps + return true; + } } } diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index d72d4b45..30572989 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -4,6 +4,7 @@ namespace Components { int Zones::ZoneVersion; + int Zones::EntitiesVersion; int Zones::FxEffectIndex; char* Zones::FxEffectStrings[64]; @@ -2561,6 +2562,8 @@ namespace Components int Zones::LoadMapEnts(bool atStreamStart, Game::MapEnts* buffer, int size) { + EntitiesVersion = Zones::Version(); + if (Zones::Version() >= 446) { size /= 44; diff --git a/src/Components/Modules/Zones.hpp b/src/Components/Modules/Zones.hpp index a869b1c0..dd1b5df6 100644 --- a/src/Components/Modules/Zones.hpp +++ b/src/Components/Modules/Zones.hpp @@ -24,10 +24,13 @@ namespace Components static int Version() { return Zones::ZoneVersion; }; + static int GetEntitiesZoneVersion() { return Zones::EntitiesVersion; }; + private: static int ZoneVersion; - + static int EntitiesVersion; + static int FxEffectIndex; static char* FxEffectStrings[64]; From 4db1c1b0a9062f02c70696edd61ef7c255b4b184 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 28 Jul 2021 19:15:47 +0200 Subject: [PATCH 7/7] Remove function again --- src/Components/Modules/QuickPatch.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index be4b5a37..1e0be026 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -380,19 +380,12 @@ namespace Components } } - template std::function ImportFunction(const std::string& dll, const std::string& function) - { - auto dllHandle = GetModuleHandleA(&dll[0]); - auto procAddr = GetProcAddress(dllHandle, &function[0]); - - return std::function (reinterpret_cast(procAddr)); - } - bool QuickPatch::IsDynClassnameStub(char* a1) { auto version = Zones::GetEntitiesZoneVersion(); - if (version >= VERSION_LATEST_CODO) { + if (version >= VERSION_LATEST_CODO) + { for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++) { char** kvPair = Game::spawnVars->spawnVars[i];