diff --git a/extensions/tf2/criticals.cpp b/extensions/tf2/criticals.cpp index cbd20414..a013c170 100644 --- a/extensions/tf2/criticals.cpp +++ b/extensions/tf2/criticals.cpp @@ -318,9 +318,19 @@ void CriticalHitManager::EnableCriticalDetour() { if (!detoured) { - DoGatePatch((unsigned char *)critical_address, &critical_callback); - DoGatePatch((unsigned char *)melee_address, &melee_callback); - DoGatePatch((unsigned char *)knife_address, &knife_callback); + if (normalcreated) + { + DoGatePatch((unsigned char *)critical_address, &critical_callback); + } + if (meleecreated) + { + DoGatePatch((unsigned char *)melee_address, &melee_callback); + } + if (knifecreated) + { + DoGatePatch((unsigned char *)knife_address, &knife_callback); + } + detoured = true; } } diff --git a/extensions/tf2/criticals.h b/extensions/tf2/criticals.h index 604647fc..135aedb7 100644 --- a/extensions/tf2/criticals.h +++ b/extensions/tf2/criticals.h @@ -51,6 +51,10 @@ public: knife_callback = NULL; forward = NULL; + + normalcreated = false; + meleecreated = false; + knifecreated = false; } ~CriticalHitManager() @@ -61,9 +65,14 @@ public: void Init() { - if (!CreateCriticalDetour() || !CreateCriticalMeleeDetour() || !CreateCriticalKnifeDetour()) + normalcreated = CreateCriticalDetour(); + meleecreated = CreateCriticalMeleeDetour(); + knifecreated = CreateCriticalKnifeDetour(); + + if (!normalcreated && !meleecreated && !knifecreated) { enabled = false; + g_pSM->LogError(myself, "No critical hit forwards could be initialised - Disabled critical hit hooks"); return; } @@ -98,6 +107,10 @@ private: bool CreateCriticalKnifeDetour(); void DeleteCriticalDetour(); + bool normalcreated; + bool meleecreated; + bool knifecreated; + /* These patch/unpatch the server.dll */ void EnableCriticalDetour(); void DisableCriticalDetour(); diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt index 803489fd..5a14704b 100644 --- a/gamedata/sm-tf2.games.txt +++ b/gamedata/sm-tf2.games.txt @@ -44,7 +44,7 @@ { "library" "server" "linux" "@_ZN8CTFKnife26CalcIsAttackCriticalHelperEv" - "windows" "\x33\xC0\x83\xB9\x20\x05\x00" + "windows" "\x33\xC0\x83\xB9\x74\x12\x00\x00\x01\x0F\x94\xC0\xC3" } }