From f031b97e91c069ee1b99af07f3181bb7a80ee7f9 Mon Sep 17 00:00:00 2001 From: Harsha Raghu Date: Fri, 17 Sep 2021 16:29:54 +0530 Subject: [PATCH] [TFCX] Fix Medic infection Crash on Linux (#991) * [TFCX] Fix Medic infection Crash on Linux Issue: #988 * [TFCX] Removed redundant code - Added `_DEBUG_TFCX` preprocessor directive - Deleted redundant code (which fetches pdata) --- modules/tfcx/usermsg.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/modules/tfcx/usermsg.cpp b/modules/tfcx/usermsg.cpp index 81d8cde9..4dc1fc40 100644 --- a/modules/tfcx/usermsg.cpp +++ b/modules/tfcx/usermsg.cpp @@ -121,10 +121,23 @@ void Client_Damage(void* mValue){ if ( FNullEnt( enemy ) ) break; +#ifdef _DEBUG_TFCX + ALERT(at_logged, "Clinet_damage Called with state-%d dmg-%d Netname'%s'(Class'%s') slno-'%d'\n", + mState, damage, STRING(mPlayer->pEdict->v.netname), + STRING(mPlayer->pEdict->v.classname), mPlayer->pEdict->serialnumber); + + ALERT(at_logged, " Called with enemy-slno-%d Netname:'%s'(Class'%s')\n", mPlayer->pEdict->serialnumber, + STRING(enemy->v.netname), STRING(enemy->v.classname)); +#endif // _DEBUG_TFCX + if (enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) { // attacker is player and his active weapon pAttacker = GET_PLAYER_POINTER(enemy); - + +#ifdef _DEBUG_TFCX + ALERT(at_logged, " attacker is player and his active weapon id-%d, has flags - (FL_CLIENT | FL_FAKECLIENT)\n\n", pAttacker->current); +#endif // _DEBUG_TFCX + aim = pAttacker->aiming; weapon = pAttacker->current; @@ -150,6 +163,15 @@ void Client_Damage(void* mValue){ pAttacker = GET_PLAYER_POINTER(enemy->v.owner); +#ifdef _DEBUG_TFCX + ALERT(at_logged, " attacker is Class'%s'(with its enmy as Netname'%s'[Class'%s']) and his owner is '%s(%s)' enemy->owner has flags - FL_CLIENT | FL_FAKECLIENT\n\n", + (enemy ? STRING(enemy->v.classname) : "Null"), + (enemy->v.enemy ? STRING(enemy->v.enemy->v.netname) : "Null"), + (enemy->v.enemy ? STRING(enemy->v.enemy->v.classname) : "Null"), + (enemy->v.owner ? STRING(enemy->v.owner->v.netname) : "Null"), + (enemy->v.owner ? STRING(enemy->v.owner->v.classname) : "Null")); +#endif // _DEBUG_TFCX + const char *szClass = STRING(enemy->v.classname); switch(szClass[10]){ @@ -185,16 +207,8 @@ void Client_Damage(void* mValue){ if ( !weapon ) { switch(szClass[3]){ case 'e': - weapon = TFC_WPN_TIMER; // TFC_WPN_MEDKIT ?? - - tempInt = get_pdata_ehandle(mPlayer->pEdict, pdTimerOwner * 4); // function is char-based. - - if (tempInt < 1 || tempInt > gpGlobals->maxClients) - { - break; - } - - pAttacker = GET_PLAYER_POINTER_I(tempInt); + weapon = TFC_WPN_TIMER; // TFC_WPN_MEDKIT ?? //ShootingKing: Class - "timer" + pAttacker = GET_PLAYER_POINTER(enemy->v.enemy); if (pAttacker->teamId == mPlayer->teamId) // ??? {