From 943b902e2341f20a8abdebd092f1e0815901deb6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 4 Mar 2006 08:16:00 +0000 Subject: [PATCH] fixed the cursed bug of throwing knives --- dlls/ts/tsx/CMisc.h | 2 +- dlls/ts/tsx/usermsg.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dlls/ts/tsx/CMisc.h b/dlls/ts/tsx/CMisc.h index 1a107319..b1b2d5de 100755 --- a/dlls/ts/tsx/CMisc.h +++ b/dlls/ts/tsx/CMisc.h @@ -42,7 +42,7 @@ #ifndef __linux__ #define TSKNIFE_OFFSET 31 // owner offset in knife entity #else -#define TSKNIFE_OFFSET 36 +#define TSKNIFE_OFFSET 35 #endif #define TSPWUP_SLOWMO 1 diff --git a/dlls/ts/tsx/usermsg.cpp b/dlls/ts/tsx/usermsg.cpp index b553cb45..a3632b61 100755 --- a/dlls/ts/tsx/usermsg.cpp +++ b/dlls/ts/tsx/usermsg.cpp @@ -102,6 +102,7 @@ void Client_ClipInfo(void* mValue) void Client_TSHealth_End(void* mValue){ edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor; int damage = (int)mPlayer->pEdict->v.dmg_take; + if ( !damage || !enemy ) return; @@ -129,14 +130,15 @@ void Client_TSHealth_End(void* mValue){ } } else if ( szCName[0] == 'k' ) { - int pOwner = *( (int*)enemy->pvPrivateData + gKnifeOffset ); + edict_t *pOwner = (edict_t *)*( (int*)enemy->pvPrivateData + gKnifeOffset ); if ( FNullEnt( (edict_t*)pOwner) ) return; - pAttacker = GET_PLAYER_POINTER( (edict_t*)pOwner ); + + pAttacker = GET_PLAYER_POINTER( pOwner ); weapon = 37; // throwing knife - aim = pAttacker->aiming; + aim = pAttacker ? pAttacker->aiming : 0; pAttacker->saveHit( mPlayer , weapon , damage, aim ); } } @@ -171,7 +173,6 @@ void Client_TSHealth_End(void* mValue){ int killFlags = 0; if ( !TA && mPlayer!=pAttacker ) { - int sflags = pAttacker->pEdict->v.iuser4; int stuntKill = 0; @@ -287,4 +288,4 @@ void Client_PwUp(void* mValue) mPlayer->PwUpValue = *(int*)mValue; break; } -} \ No newline at end of file +}