From d1c42751cd1989b2ba1f650e29e405ff23e04ee5 Mon Sep 17 00:00:00 2001 From: Zor Date: Fri, 29 Dec 2006 19:25:16 +0000 Subject: [PATCH] - Fix in need of testing in regards to the TK / TA bug detected - Created a temp pointer as the first thing to do in the CurWpn function. This way if another message gets thrown while still in the middle of this function the global pointer to messaged player is not affected. --- dlls/dod2/dodx/dodx.h | 6 +- dlls/dod2/dodx/moduleconfig.cpp | 33 +++++---- dlls/dod2/dodx/usermsg.cpp | 122 ++++++++++++++++---------------- 3 files changed, 79 insertions(+), 82 deletions(-) diff --git a/dlls/dod2/dodx/dodx.h b/dlls/dod2/dodx/dodx.h index 40aa98a7..ce1412e0 100755 --- a/dlls/dod2/dodx/dodx.h +++ b/dlls/dod2/dodx/dodx.h @@ -60,13 +60,13 @@ extern int mState; extern int mPlayerIndex; void Client_CurWeapon(void*); -void Client_Health_End(void*); void Client_ResetHUD_End(void*); void Client_ObjScore(void*); void Client_TeamScore(void*); void Client_RoundState(void*); void Client_AmmoX(void*); void Client_AmmoShort(void*); +void Client_Health_End(void*); // Zors //void WeaponList(void*); @@ -78,7 +78,6 @@ extern int AlliesScore; extern int AxisScore; extern int gmsgCurWeapon; -extern int gmsgHealth; extern int gmsgResetHUD; extern int gmsgObjScore; extern int gmsgRoundState; @@ -87,12 +86,11 @@ extern int gmsgScoreShort; extern int gmsgPTeam; extern int gmsgAmmoX; extern int gmsgAmmoShort; +extern int gmsgHealth_End; extern int iFDamage; extern int iFDeath; extern int iFScore; - -// Zors extern int iFSpawnForward; extern int iFTeamForward; extern int iFClassForward; diff --git a/dlls/dod2/dodx/moduleconfig.cpp b/dlls/dod2/dodx/moduleconfig.cpp index f1a66cdf..94c7aeaa 100755 --- a/dlls/dod2/dodx/moduleconfig.cpp +++ b/dlls/dod2/dodx/moduleconfig.cpp @@ -57,7 +57,6 @@ int iFTeamForward = -1; int iFClassForward = -1; int gmsgCurWeapon; -int gmsgHealth; int gmsgResetHUD; int gmsgObjScore; int gmsgRoundState; @@ -66,6 +65,7 @@ int gmsgScoreShort; int gmsgPTeam; int gmsgAmmoX; int gmsgAmmoShort; +int gmsgHealth_End; // Zors //int gmsgWeaponList; @@ -90,22 +90,23 @@ struct sUserMsg { int* id; funEventCall func; bool endmsg; -} g_user_msg[] = { - { "CurWeapon",&gmsgCurWeapon,Client_CurWeapon,false }, - { "ObjScore",&gmsgObjScore,Client_ObjScore,false }, - { "RoundState",&gmsgRoundState,Client_RoundState,false }, - { "Health",&gmsgHealth,Client_Health_End,true }, - { "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true }, - { "TeamScore",&gmsgTeamScore,Client_TeamScore,false }, - { "ScoreShort",&gmsgScoreShort,NULL,false }, - { "PTeam",&gmsgPTeam,NULL,false }, - { "AmmoX",&gmsgAmmoX,Client_AmmoX,false}, - { "AmmoShort",&gmsgAmmoShort,Client_AmmoShort,false}, - { "ScoreShort",&gmsgScoreShort,NULL,false }, +} g_user_msg[] = +{ + { "CurWeapon", &gmsgCurWeapon, Client_CurWeapon, false }, + { "ObjScore", &gmsgObjScore, Client_ObjScore, false }, + { "RoundState", &gmsgRoundState, Client_RoundState, false }, + { "ResetHUD", &gmsgResetHUD, Client_ResetHUD_End, true }, + { "TeamScore", &gmsgTeamScore, Client_TeamScore, false }, + { "AmmoX", &gmsgAmmoX, Client_AmmoX, false }, + { "AmmoShort", &gmsgAmmoShort, Client_AmmoShort, false }, + { "Health", &gmsgHealth_End, Client_Health_End, true }, //Zors - //{ "WeaponList",&gmsgWeaponList,WeaponList,true }, - //{ "WeaponList",&gmsgWeaponList_End,WeaponList_End,true }, + //{ "WeaponList", &gmsgWeaponList, WeaponList, true }, + //{ "WeaponList", &gmsgWeaponList_End, WeaponList_End, true }, + + { "PTeam", &gmsgPTeam, NULL, false }, + { "ScoreShort", &gmsgScoreShort, NULL, false }, { 0,0,0,false } }; @@ -440,8 +441,6 @@ void OnPluginsLoaded() iFDeath = MF_RegisterForward("client_death",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE); iFDamage = MF_RegisterForward("client_damage",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE); iFScore = MF_RegisterForward("client_score",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE); - - // Zors iFTeamForward = MF_RegisterForward("dod_client_changeteam",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*team*/,FP_CELL/*oldteam*/,FP_DONE); iFSpawnForward = MF_RegisterForward("dod_client_spawn",ET_IGNORE,FP_CELL/*id*/,FP_DONE); iFClassForward = MF_RegisterForward("dod_client_changeclass",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*class*/,FP_CELL/*oldclass*/,FP_DONE); diff --git a/dlls/dod2/dodx/usermsg.cpp b/dlls/dod2/dodx/usermsg.cpp index 8b1446b1..22c20bbb 100755 --- a/dlls/dod2/dodx/usermsg.cpp +++ b/dlls/dod2/dodx/usermsg.cpp @@ -141,67 +141,6 @@ void Client_CurWeapon(void* mValue) } } -/* -Nie ma damage event ... -*/ -void Client_Health_End(void* mValue){ - - if ( !isModuleActive() ) - return; - - edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor; - int damage = (int)mPlayer->pEdict->v.dmg_take; - - if ( !mPlayer || !damage || !enemy ) - return; - - int weapon = 0; - int aim = 0; - - mPlayer->pEdict->v.dmg_take = 0.0; - - CPlayer* pAttacker = NULL; - - if ( enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) - { - pAttacker = GET_PLAYER_POINTER(enemy); - weapon = pAttacker->current; - - if ( weaponData[weapon].needcheck ) - weapon = get_weaponid(pAttacker); - - aim = pAttacker->aiming; - - if ( weaponData[weapon].melee ) - pAttacker->saveShot(weapon); - } - else - g_grenades.find( enemy , &pAttacker , weapon ); - - int TA = 0; - - if ( !pAttacker ) - { - pAttacker = mPlayer; - } - - if ( pAttacker->index != mPlayer->index ) - { - pAttacker->saveHit( mPlayer , weapon , damage, aim ); - - if ( mPlayer->pEdict->v.team == pAttacker->pEdict->v.team ) - TA = 1; - } - - MF_ExecuteForward( iFDamage, pAttacker->index, mPlayer->index, damage, weapon, aim, TA ); - - if ( !mPlayer->IsAlive() ) - { - pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA); - MF_ExecuteForward( iFDeath, pAttacker->index, mPlayer->index, weapon, aim, TA ); - } -} - void Client_AmmoX(void* mValue) { static int iAmmo; @@ -241,6 +180,67 @@ void Client_AmmoShort(void* mValue) } } +void Client_Health_End(void* mValue) +{ + if ( !isModuleActive() ) + return; + + CPlayer* pVictim = mPlayer; + + edict_t *enemy = pVictim->pEdict->v.dmg_inflictor; + int damage = (int)pVictim->pEdict->v.dmg_take; + + if(!pVictim || !damage || !enemy) + return; + + int weapon = 0; + int aim = 0; + + pVictim->pEdict->v.dmg_take = 0.0; + + CPlayer* pAttacker = NULL; + + if(enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT)) + { + pAttacker = GET_PLAYER_POINTER(enemy); + weapon = pAttacker->current; + + if(weaponData[weapon].needcheck) + weapon = get_weaponid(pAttacker); + + aim = pAttacker->aiming; + + if(weaponData[weapon].melee) + pAttacker->saveShot(weapon); + } + + else + g_grenades.find(enemy , &pAttacker , weapon); + + int TA = 0; + + if(!pAttacker) + { + pAttacker = pVictim; + } + + if(pAttacker->index != pVictim->index) + { + pAttacker->saveHit(pVictim , weapon , damage, aim); + + if(pVictim->pEdict->v.team == pAttacker->pEdict->v.team) + TA = 1; + } + + MF_ExecuteForward(iFDamage, pAttacker->index, pVictim->index, damage, weapon, aim, TA); + + if(!pVictim->IsAlive()) + { + pAttacker->saveKill(pVictim, weapon, (aim == 1) ? 1:0 , TA); + MF_ExecuteForward(iFDeath, pAttacker->index, pVictim->index, weapon, aim, TA); + } +} + /* Working on being able to modify and switch weapons as they are sent to the client