Skip to content

Commit

Permalink
[TFCX] Fix Medic infection Crash on Linux (#991)
Browse files Browse the repository at this point in the history
* [TFCX] Fix Medic infection Crash on Linux

Issue: #988

* [TFCX] Removed redundant code

- Added `_DEBUG_TFCX` preprocessor directive
- Deleted redundant code (which fetches pdata)
  • Loading branch information
ShootingKing-AM authored and Arkshine committed Sep 17, 2021
1 parent beaa8c4 commit f031b97
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions modules/tfcx/usermsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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]){
Expand Down Expand Up @@ -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) // ???
{
Expand Down

0 comments on commit f031b97

Please sign in to comment.