From 329616c029ed3b6a4fd394ac0e1c64926ff0b1f4 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Fri, 21 Dec 2012 01:17:30 -0500 Subject: [PATCH] Fixed hang in TF2 extension when player condition 63 is added. --- extensions/tf2/conditions.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extensions/tf2/conditions.cpp b/extensions/tf2/conditions.cpp index 141975fb..9a2e5543 100644 --- a/extensions/tf2/conditions.cpp +++ b/extensions/tf2/conditions.cpp @@ -48,6 +48,8 @@ int conditionBitsOffset = -1; bool g_bIgnoreRemove; +#define MAX_CONDS (sizeof(uint64_t) * 8) + inline condflags_t GetPlayerConds(CBaseEntity *pPlayer) { uint32_t playerCond = *(uint32_t *)((intptr_t)pPlayer + playerCondOffset); @@ -92,25 +94,25 @@ void Conditions_OnGameFrame(bool simulating) addedconds = newconds &~ oldconds; removedconds = oldconds &~ newconds; - int j; + uint64_t j; condflags_t bit; - for (j = 0; (bit = ((condflags_t)1 << j)) <= addedconds; j++) + for (j = 0; j < MAX_CONDS && (bit = ((condflags_t)1 << j)) <= addedconds; j++) { if ((addedconds & bit) == bit) { g_addCondForward->PushCell(i); - g_addCondForward->PushCell(j); + g_addCondForward->PushCell(j & 0xFFFFFFFF); g_addCondForward->Execute(NULL, NULL); } } - for (j = 0; (bit = ((condflags_t)1 << j)) <= removedconds; j++) + for (j = 0; j < MAX_CONDS && (bit = ((condflags_t)1 << j)) <= removedconds; j++) { if ((removedconds & bit) == bit) { g_removeCondForward->PushCell(i); - g_removeCondForward->PushCell(j); + g_removeCondForward->PushCell(j & 0xFFFFFFFF); g_removeCondForward->Execute(NULL, NULL); } }