Skip to content

Commit

Permalink
TF2Tools: Prevent CalcIsAttackCriticalHelper* from being called twice (
Browse files Browse the repository at this point in the history
…#1573)

* Ensure CalcIsAttackCriticalHelper only gets called once

* fixup: move origReturnValue up
  • Loading branch information
nosoop authored Sep 23, 2021
1 parent a5f99c5 commit 57a3863
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion extensions/tf2/criticals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ bool CritManager::Hook_CalcIsAttackCriticalHelpers(bool noCrits)
returnValue = SH_MCALL(pWeapon, CalcIsAttackCriticalHelper)() ? 1 : 0;
}

int origReturnValue = returnValue;
int ownerIndex = -1;
CBaseHandle &hndl = *(CBaseHandle *) ((intptr_t)pWeapon + info.actual_offset);
CBaseEntity *pHandleEntity = gamehelpers->ReferenceToEntity(hndl.GetEntryIndex());
Expand All @@ -214,5 +215,5 @@ bool CritManager::Hook_CalcIsAttackCriticalHelpers(bool noCrits)
RETURN_META_VALUE(MRES_SUPERCEDE, returnValue);
}

RETURN_META_VALUE(MRES_IGNORED, false);
RETURN_META_VALUE(MRES_SUPERCEDE, origReturnValue);
}

0 comments on commit 57a3863

Please sign in to comment.