TF2Tools: Prevent CalcIsAttackCriticalHelper* from being called twice (#1573)

* Ensure CalcIsAttackCriticalHelper only gets called once

* fixup: move origReturnValue up
This commit is contained in:
nosoop 2021-09-23 03:00:52 -07:00 committed by GitHub
parent a5f99c57e1
commit 57a38636fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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());
@ -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);
}