From c5d7417f8ed9d29ab507b0afb563c147e3149f6b Mon Sep 17 00:00:00 2001 From: Lukasz Wlasinksi Date: Wed, 8 Sep 2004 18:09:01 +0000 Subject: [PATCH] added client_score forward --- dlls/dod2/dodx/CMisc.cpp | 8 ++++++++ dlls/dod2/dodx/CMisc.h | 6 +++++- dlls/dod2/dodx/NBase.cpp | 8 ++++++++ dlls/dod2/dodx/dodx.h | 2 ++ dlls/dod2/dodx/moduleconfig.cpp | 33 ++++++++++++++++++++++++++------- dlls/dod2/dodx/usermsg.cpp | 15 +++++++-------- 6 files changed, 56 insertions(+), 16 deletions(-) diff --git a/dlls/dod2/dodx/CMisc.cpp b/dlls/dod2/dodx/CMisc.cpp index 8704f588..b8cae595 100755 --- a/dlls/dod2/dodx/CMisc.cpp +++ b/dlls/dod2/dodx/CMisc.cpp @@ -367,6 +367,14 @@ void Forward::exec(int p1,int p2,int p3,int p4,int p5){ } } +void Forward::exec(int p1,int p2,int p3){ + AmxCall* a = head; + while ( a ){ + MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 3,p1, p2, p3); + a = a->next; + } +} + void Forward::exec(int p1,int p2){ AmxCall* a = head; while ( a ){ diff --git a/dlls/dod2/dodx/CMisc.h b/dlls/dod2/dodx/CMisc.h index f0467e66..627c1db0 100755 --- a/dlls/dod2/dodx/CMisc.h +++ b/dlls/dod2/dodx/CMisc.h @@ -74,11 +74,14 @@ public: int current; int wpnModel; - int savedScore; + float savedScore; + int lastScore; + int sendScore; bool ingame; bool bot; float clearStats; + float clearRound; struct PlayerWeapon : public Stats { char* name; @@ -178,6 +181,7 @@ public: void put( AMX *a , int i ); void exec(int p1,int p2,int p3,int p4,int p5,int p6); void exec(int p1,int p2,int p3,int p4,int p5); + void exec(int p1,int p2,int p3); void exec(int p1,int p2); }; #endif diff --git a/dlls/dod2/dodx/NBase.cpp b/dlls/dod2/dodx/NBase.cpp index bdb546aa..17b9e308 100755 --- a/dlls/dod2/dodx/NBase.cpp +++ b/dlls/dod2/dodx/NBase.cpp @@ -205,11 +205,19 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; break; + case 2: + if( MF_AmxFindPublic(amx, "client_score", &iFunctionIndex) == AMX_ERR_NONE ) + g_score_info.put( amx , iFunctionIndex ); + else + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + break; default: MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; } #endif + return 1; } diff --git a/dlls/dod2/dodx/dodx.h b/dlls/dod2/dodx/dodx.h index eaa6f17e..1ad04ded 100755 --- a/dlls/dod2/dodx/dodx.h +++ b/dlls/dod2/dodx/dodx.h @@ -81,11 +81,13 @@ extern int gmsgPTeam; extern Forward g_death_info; extern Forward g_damage_info; +extern Forward g_score_info; #else extern int iFDamage; extern int iFDeath; +extern int iFScore; #endif diff --git a/dlls/dod2/dodx/moduleconfig.cpp b/dlls/dod2/dodx/moduleconfig.cpp index c592efdc..d1cad399 100755 --- a/dlls/dod2/dodx/moduleconfig.cpp +++ b/dlls/dod2/dodx/moduleconfig.cpp @@ -51,11 +51,13 @@ int AxisScore; Forward g_death_info; Forward g_damage_info; +Forward g_score_info; #else int iFDamage; int iFDeath; +int iFScore; #endif @@ -152,16 +154,32 @@ void PlayerPreThink_Post( edict_t *pEntity ) { return; CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); + if ( !pPlayer->ingame ) + return; - if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame){ - - if ( !ignoreBots(pEntity) ){ - pPlayer->clearStats = 0.0f; - pPlayer->rank->updatePosition( &pPlayer->life ); - pPlayer->restartStats(false); + if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time){ + if ( !ignoreBots(pEntity) ){ + pPlayer->clearStats = 0.0f; + pPlayer->rank->updatePosition( &pPlayer->life ); + pPlayer->restartStats(false); + } } + if (pPlayer->clearRound && pPlayer->clearRound < gpGlobals->time){ + pPlayer->clearRound = 0.0f; + memset(&pPlayer->round,0,sizeof(pPlayer->round)); + memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd)); } + + if (pPlayer->sendScore && pPlayer->sendScore < gpGlobals->time){ + pPlayer->sendScore = 0.0f; +#ifdef FORWARD_OLD_SYSTEM + g_score_info.exec( pPlayer->index, pPlayer->lastScore, pPlayer->savedScore ); +#else + MF_ExecuteForward( iFScore,pPlayer->index, pPlayer->lastScore, pPlayer->savedScore ); +#endif + } + RETURN_META(MRES_IGNORED); } @@ -183,6 +201,7 @@ void ServerDeactivate() { g_damage_info.clear(); g_death_info.clear(); + g_score_info.clear(); #endif @@ -398,7 +417,7 @@ void OnAmxxDetach() { 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); } #endif diff --git a/dlls/dod2/dodx/usermsg.cpp b/dlls/dod2/dodx/usermsg.cpp index 5da8818c..9b6a0e1c 100755 --- a/dlls/dod2/dodx/usermsg.cpp +++ b/dlls/dod2/dodx/usermsg.cpp @@ -42,8 +42,7 @@ void Client_RoundState(void* mValue){ for (int i=1;i<=gpGlobals->maxClients;i++){ CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); if (pPlayer->ingame) { - memset(&pPlayer->round,0,sizeof(pPlayer->round)); - memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd)); + pPlayer->clearRound = gpGlobals->time + 0.25f; } } } @@ -70,18 +69,18 @@ void Client_TeamScore(void* mValue){ void Client_ObjScore(void* mValue){ static CPlayer *pPlayer; - static int TMScore; //total map score :-) + static int score; switch(mState++){ case 0: pPlayer = GET_PLAYER_POINTER_I(*(int*)mValue); break; case 1: - TMScore = *(int*)mValue; - int score = TMScore - pPlayer->savedScore; - if ( score && isModuleActive() ){ - pPlayer->updateScore(pPlayer->current,score); + score = *(int*)mValue; + if ( (pPlayer->lastScore = score - pPlayer->savedScore) && isModuleActive() ){ + pPlayer->updateScore(pPlayer->current,pPlayer->lastScore); + pPlayer->sendScore = gpGlobals->time + 0.25f; } - pPlayer->savedScore = TMScore; + pPlayer->savedScore = score; break; } }