From 5a175c50054ffbe1021203c37da99920b3a3ef9a Mon Sep 17 00:00:00 2001 From: SmileyAG <58108407+SmileyAG@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:37:04 +0400 Subject: [PATCH] Pattern-less implementation of bxt_render_far_entities --- BunnymodXT/modules/ServerDLL.cpp | 66 ++------------------------------ BunnymodXT/modules/ServerDLL.hpp | 2 - BunnymodXT/patterns.hpp | 11 ------ 3 files changed, 3 insertions(+), 76 deletions(-) diff --git a/BunnymodXT/modules/ServerDLL.cpp b/BunnymodXT/modules/ServerDLL.cpp index add0ce9a..b283981b 100644 --- a/BunnymodXT/modules/ServerDLL.cpp +++ b/BunnymodXT/modules/ServerDLL.cpp @@ -304,7 +304,6 @@ void ServerDLL::Clear() offBhopcap = 0; pBhopcapWindows = 0; pCZDS_Velocity_Byte = 0; - pAddToFullPack_PVS_Byte = 0; pCoF_Noclip_Preventing_Check_Byte = 0; pCBasePlayer__Jump_OldButtons_Check_Byte = 0; offm_iClientFOV = 0; @@ -570,7 +569,6 @@ void ServerDLL::FindStuff() offFuncIsPlayer = 0xD4; offFuncCenter = 0x100; offFuncObjectCaps = 0x44; - spirit_sdk = true; break; case 15: // Echoes offm_rgAmmoLast = 0x5F4; @@ -578,7 +576,6 @@ void ServerDLL::FindStuff() offFuncIsPlayer = 0xCC; offFuncCenter = 0xF8; offFuncObjectCaps = 0x3C; - spirit_sdk = true; break; case 16: // Decay offm_rgAmmoLast = 0x544; @@ -762,26 +759,6 @@ void ServerDLL::FindStuff() } }); - auto fAddToFullPack_PVS_Byte = FindAsync( - pAddToFullPack_PVS_Byte, - patterns::server::AddToFullPack_PVS_Byte, - [&](auto pattern) { - switch (pattern - patterns::server::AddToFullPack_PVS_Byte.cbegin()) { - case 0: // HL-SteamPipe - case 1: // Parasomnia - pAddToFullPack_PVS_Byte += 2; - break; - case 2: // AoMDC - pAddToFullPack_PVS_Byte += 6; - break; - case 3: // Counter-Strike 1.6 - pAddToFullPack_PVS_Byte += 17; - break; - default: - assert(false); - } - }); - auto fCoF_Noclip_Preventing_Check_Byte = FindAsync( pCoF_Noclip_Preventing_Check_Byte, patterns::server::CoF_Noclip_Preventing_Check_Byte, @@ -914,15 +891,6 @@ void ServerDLL::FindStuff() } } - { - auto pattern = fAddToFullPack_PVS_Byte.get(); - if (pAddToFullPack_PVS_Byte) { - EngineDevMsg("[server dll] Found AddToFullPack PVS Byte at %p (using the %s pattern).\n", pAddToFullPack_PVS_Byte, pattern->name()); - } else { - EngineDevWarning("[server dll] Could not find AddToFullPack PVS Byte.\n"); - } - } - { auto pattern = fCoF_Noclip_Preventing_Check_Byte.get(); if (pCoF_Noclip_Preventing_Check_Byte) @@ -2508,6 +2476,9 @@ HOOK_DEF_7(ServerDLL, int, __cdecl, AddToFullPack, struct entity_state_s*, state return ORIG_AddToFullPack(state, e, ent, host, hostflags, player, pSet); } + if (CVars::bxt_render_far_entities.GetBool()) // https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/client.cpp#L1114-L1122 + pSet = NULL; + auto oldEffects = ent->v.effects; auto oldRendermode = ent->v.rendermode; auto oldRenderColor = ent->v.rendercolor; @@ -2517,37 +2488,6 @@ HOOK_DEF_7(ServerDLL, int, __cdecl, AddToFullPack, struct entity_state_s*, state auto oldIUser1 = ent->v.iuser1; auto oldIUser2 = ent->v.iuser2; - static bool is_0x75 = false; - - if (pAddToFullPack_PVS_Byte) - { - if (CVars::bxt_render_far_entities.GetBool()) - { - if (*reinterpret_cast(pAddToFullPack_PVS_Byte) == 0x75) - is_0x75 = true; - - if ((*reinterpret_cast(pAddToFullPack_PVS_Byte) == 0x74) || (*reinterpret_cast(pAddToFullPack_PVS_Byte) == 0x75)) - MemUtils::ReplaceBytes(reinterpret_cast(pAddToFullPack_PVS_Byte), 1, reinterpret_cast("\xEB")); - } - else if (*reinterpret_cast(pAddToFullPack_PVS_Byte) == 0xEB) - { - if (is_0x75) - MemUtils::ReplaceBytes(reinterpret_cast(pAddToFullPack_PVS_Byte), 1, reinterpret_cast("\x75")); - else - MemUtils::ReplaceBytes(reinterpret_cast(pAddToFullPack_PVS_Byte), 1, reinterpret_cast("\x74")); - } - } - - if (ClientDLL::GetInstance().DoesGameDirContain("czeror") && CVars::bxt_render_far_entities.GetBool()) - { - ent->v.flags |= FL_IMMUNE_LAVA; // Because the PVS check in AddToFullPack points to '524288' flags bit - ent->v.iuser1 = 1; // Similar to above explanation - ent->v.iuser2 = 1; // Mappers used on some entities 'nopvs = 1' keyvalue, which is 'iuser2 = 1` in game code - } - - if (CVars::bxt_render_far_entities.GetInt() == 2 || (CVars::bxt_render_far_entities.GetBool() && spirit_sdk)) - ent->v.renderfx = 22; // kRenderFxEntInPVS from Spirit SDK - const char *classname = HwDLL::GetInstance().ppGlobals->pStringBase + ent->v.classname; bool is_trigger = std::strncmp(classname, "trigger_", 8) == 0; bool is_ladder = std::strncmp(classname, "func_ladder", 11) == 0; diff --git a/BunnymodXT/modules/ServerDLL.hpp b/BunnymodXT/modules/ServerDLL.hpp index c5a86add..dd4a47d3 100644 --- a/BunnymodXT/modules/ServerDLL.hpp +++ b/BunnymodXT/modules/ServerDLL.hpp @@ -197,7 +197,6 @@ class ServerDLL : public IHookableDirFilter ptrdiff_t offBhopcap; ptrdiff_t pCZDS_Velocity_Byte; - ptrdiff_t pAddToFullPack_PVS_Byte; ptrdiff_t pBhopcapWindows; byte originalBhopcapInsn[6]; @@ -215,7 +214,6 @@ class ServerDLL : public IHookableDirFilter ptrdiff_t offm_pClientActiveItem; ptrdiff_t offm_CMultiManager_index; - bool spirit_sdk = false; bool is_czeror = false; bool callerIsWalkMove; diff --git a/BunnymodXT/patterns.hpp b/BunnymodXT/patterns.hpp index 723be09d..0955db24 100644 --- a/BunnymodXT/patterns.hpp +++ b/BunnymodXT/patterns.hpp @@ -1048,17 +1048,6 @@ namespace patterns "53 55 56 8B 74 24 ?? 57 8B CE 8B 06 FF 50" ); - PATTERNS(AddToFullPack_PVS_Byte, - "HL-SteamPipe", - "3B EE 74 ?? 8B 54 24", - "Parasomnia", - "3B FE 74 ?? 8B 55", - "AoMDC", - "8B 45 ?? 3B 45 ?? 74 ?? 8B 4D ?? 51 8B 55 ?? 52 FF 15", - "CStrike-Latest", - "8B 44 24 ?? 50 55 FF 15 ?? ?? ?? ?? 83 C4 08 85 C0 ??" - ); - PATTERNS(CBaseEntity__FireBullets, "HL-SteamPipe-6153", "81 EC FC 00 00 00 A1 ?? ?? ?? ?? 53 55",