From 95d30ba4ec71f04dcd2ccd9a26195842b832110a Mon Sep 17 00:00:00 2001 From: Matt Schubert Date: Thu, 17 Sep 2009 12:42:58 -0400 Subject: [PATCH] Fixed the Huntsman not firing CalcIsAttackCritical (bug 3927, r=dvander) --- extensions/tf2/criticals.cpp | 27 +++++++++++++++++++++++++++ gamedata/sm-tf2.games.txt | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/extensions/tf2/criticals.cpp b/extensions/tf2/criticals.cpp index 1c5ecb57..447b8257 100644 --- a/extensions/tf2/criticals.cpp +++ b/extensions/tf2/criticals.cpp @@ -35,6 +35,7 @@ IServerGameEnts *gameents = NULL; CDetour *calcIsAttackCriticalDetour = NULL; CDetour *calcIsAttackCriticalMeleeDetour = NULL; +CDetour *calcIsAttackCriticalBowDetour = NULL; IForward *g_critForward = NULL; @@ -169,10 +170,29 @@ DETOUR_DECL_MEMBER0(CalcIsAttackCriticalHelper, bool) } } +DETOUR_DECL_MEMBER0(CalcIsAttackCriticalHelperBow, bool) +{ + DetourResult result = DetourCallback((CBaseEntity *)this); + + if (result == Result_Ignore) + { + return DETOUR_MEMBER_CALL(CalcIsAttackCriticalHelperBow)(); + } + else if (result == Result_NoCrit) + { + return 0; + } + else + { + return 1; + } +} + void InitialiseDetours() { calcIsAttackCriticalDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCritical"); calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperMelee, "CalcCriticalMelee"); + calcIsAttackCriticalBowDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperBow, "CalcCriticalBow"); bool HookCreated = false; @@ -188,6 +208,12 @@ void InitialiseDetours() HookCreated = true; } + if (calcIsAttackCriticalBowDetour != NULL) + { + calcIsAttackCriticalBowDetour->EnableDetour(); + HookCreated = true; + } + if (!HookCreated) { g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks"); @@ -200,4 +226,5 @@ void RemoveDetours() { calcIsAttackCriticalDetour->Destroy(); calcIsAttackCriticalMeleeDetour->Destroy(); + calcIsAttackCriticalBowDetour->Destroy(); } diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt index 72bd3f9d..c41a77d7 100644 --- a/gamedata/sm-tf2.games.txt +++ b/gamedata/sm-tf2.games.txt @@ -45,6 +45,12 @@ "linux" "@_ZN18CTFWeaponBaseMelee26CalcIsAttackCriticalHelperEv" "windows" "\x83\xEC\x08\x53\x57\x8B\xF9\xE8\x2A\x2A\x2A\x2A\x8B\xD8" } + "CalcCriticalBow" + { + "library" "server + "linux" "@_ZN14CTFCompoundBow26CalcIsAttackCriticalHelperEv" + "windows" "\xE8\x2A\x2A\x2A\x2A\x85\xC0\x74\x14\x6A\x0B" + } } "Offsets" {