From afce6de8010d77e0b0d1aefddd299c65c1feba02 Mon Sep 17 00:00:00 2001 From: Lukasz Wlasinksi Date: Fri, 23 Jul 2004 23:18:50 +0000 Subject: [PATCH] register_statsfwd --- dlls/csstats2/amxx_package/csstats.inc | 13 +++++-- dlls/csstats2/amxx_package/stats_test.sma | 3 ++ dlls/csstats2/csstats/CMisc.cpp | 43 +++++++++++++++++++++++ dlls/csstats2/csstats/CMisc.h | 22 ++++++++++++ dlls/csstats2/csstats/meta_api.cpp | 12 ++++--- dlls/csstats2/csstats/moduleconfig.h | 6 ++-- dlls/csstats2/csstats/rank.cpp | 30 ++++++++++++++-- dlls/csstats2/csstats/rank.h | 5 +-- dlls/csstats2/csstats/usermsg.cpp | 6 ++-- dlls/dod2/dodx/NBase.cpp | 2 +- dlls/dod2/dodx/moduleconfig.h | 4 +-- dlls/tfc/tfcx/NBase.cpp | 2 +- dlls/tfc/tfcx/moduleconfig.h | 6 ++-- dlls/ts/tsx/NBase.cpp | 2 +- dlls/ts/tsx/moduleconfig.h | 6 ++-- 15 files changed, 135 insertions(+), 27 deletions(-) diff --git a/dlls/csstats2/amxx_package/csstats.inc b/dlls/csstats2/amxx_package/csstats.inc index fde49906..f7d49e87 100755 --- a/dlls/csstats2/amxx_package/csstats.inc +++ b/dlls/csstats2/amxx_package/csstats.inc @@ -70,8 +70,17 @@ native custom_wpn_shot( index,wid ); native get_custom_wpnname( wId,name[],len ); /* -* Usefull forwards +* Forwards */ + +forward grenade_throw( index,greindex,wId ); + +enum { + CSF_DAMAGE = 0, + CSF_DEATH, +} + +/* You must register client_* forwards using register_statsfwd native */ +native register_statsfwd( ftype ) forward client_damage( attacker,victim,damage,wpnindex,hitplace,TA ); forward client_death( killer,victim,wpnindex,hitplace,TK ); -forward grenade_throw( index,greindex,wId ); diff --git a/dlls/csstats2/amxx_package/stats_test.sma b/dlls/csstats2/amxx_package/stats_test.sma index aa9d4108..32e6f3e2 100755 --- a/dlls/csstats2/amxx_package/stats_test.sma +++ b/dlls/csstats2/amxx_package/stats_test.sma @@ -1,7 +1,10 @@ #include +#include public plugin_init() { register_plugin("Stats Test","0.1","SidLuke") + register_statsfwd( CSF_DAMAGE ) + register_statsfwd( CSF_DEATH ) } public client_damage( attacker,victim,damage,wpnindex,hitplace,TA ){ diff --git a/dlls/csstats2/csstats/CMisc.cpp b/dlls/csstats2/csstats/CMisc.cpp index 72883af4..a9569a77 100755 --- a/dlls/csstats2/csstats/CMisc.cpp +++ b/dlls/csstats2/csstats/CMisc.cpp @@ -243,6 +243,49 @@ void CPlayer::saveBDefused(){ } +// ***************************************************** +// class Forward +// ***************************************************** + +void Forward::put( AMX *a , int i ){ + head = new AmxCall( a, i , head ); +} + + +void Forward::clear(){ + while ( head ) { + AmxCall* a = head->next; + delete head; + head = a; + } +} + +void Forward::exec(int p1,int p2,int p3,int p4,int p5,int p6){ + AmxCall* a = head; + while ( a ){ + MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 6,p1, p2, p3, p4, p5, p6); + a = a->next; + } +} + +void Forward::exec(int p1,int p2,int p3,int p4,int p5){ + AmxCall* a = head; + while ( a ){ + MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 5,p1, p2, p3, p4, p5); + a = a->next; + } +} + +void Forward::exec(int p1,int p2){ + AmxCall* a = head; + while ( a ){ + MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 2,p1, p2); + a = a->next; + } +} + +// ***************************************************** + bool ignoreBots (edict_t *pEnt, edict_t *pOther){ if ( !rankBots && ( pEnt->v.flags & FL_FAKECLIENT || ( pOther && pOther->v.flags & FL_FAKECLIENT ) ) ) return true; diff --git a/dlls/csstats2/csstats/CMisc.h b/dlls/csstats2/csstats/CMisc.h index 83239113..d13122f5 100755 --- a/dlls/csstats2/csstats/CMisc.h +++ b/dlls/csstats2/csstats/CMisc.h @@ -87,6 +87,28 @@ public: void clear(); }; +// ***************************************************** +// class Forward +// ***************************************************** + +class Forward +{ + struct AmxCall { + AMX *amx; + int iFunctionIdx; + AmxCall* next; + AmxCall( AMX *a , int i, AmxCall* n ): amx(a), iFunctionIdx(i), next(n) {} + } *head; +public: + Forward() { head = 0; } + ~Forward() { clear(); } + void clear(); + 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); +}; + #endif // CMISC_H diff --git a/dlls/csstats2/csstats/meta_api.cpp b/dlls/csstats2/csstats/meta_api.cpp index d4d7672b..db7386e1 100755 --- a/dlls/csstats2/csstats/meta_api.cpp +++ b/dlls/csstats2/csstats/meta_api.cpp @@ -21,8 +21,9 @@ RankSystem g_rank; Grenades g_grenades; -int iFDeath; -int iFDamage; +Forward g_death_info; +Forward g_damage_info; + int iFGrenade; bool rankBots; @@ -141,9 +142,14 @@ void ServerDeactivate() { g_rank.clear(); // clear before save to file } g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("csstats")) ); + + g_damage_info.clear(); + g_death_info.clear(); + // clear custom weapons info for ( i=MAX_WEAPONS;iteamId == pAtt->teamId) && ( pVic != pAtt) ) TA = 1; - MF_ExecuteForward( iFDamage, pAtt->index, pVic->index, dmg, weapon, aim, TA ); + g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA ); if ( pVic->IsAlive() ) return 1; pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA); - MF_ExecuteForward( iFDeath, pAtt->index, pVic->index, weapon, aim, TA ); + g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA ); return 1; } @@ -380,6 +380,30 @@ static cell AMX_NATIVE_CALL get_custom_wpnname(AMX *amx, cell *params){ return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]); } +static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward + int iFunctionIndex; + switch( params[1] ){ + case 0: + if( MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex) == AMX_ERR_NONE ) + g_damage_info.put( amx , iFunctionIndex ); + else + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + break; + case 1: + if( MF_AmxFindPublic(amx, "client_death", &iFunctionIndex) == AMX_ERR_NONE ) + g_death_info.put( amx , iFunctionIndex ); + else + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + break; + default: + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + } + return 1; +} + AMX_NATIVE_INFO stats_Natives[] = { { "get_stats", get_stats}, { "get_stats2", get_stats2}, @@ -400,6 +424,8 @@ AMX_NATIVE_INFO stats_Natives[] = { { "custom_wpn_shot", custom_wpn_shot }, { "get_custom_wpnname", get_custom_wpnname }, + {"register_statsfwd",register_forward }, + ///******************* { NULL, NULL } }; diff --git a/dlls/csstats2/csstats/rank.h b/dlls/csstats2/csstats/rank.h index 5503ddfb..6b490df5 100755 --- a/dlls/csstats2/csstats/rank.h +++ b/dlls/csstats2/csstats/rank.h @@ -26,8 +26,9 @@ extern bool rankBots; extern cvar_t* csstats_rankbots; extern cvar_t* csstats_pause; -extern int iFDeath; -extern int iFDamage; +extern Forward g_death_info; +extern Forward g_damage_info; + extern int iFGrenade; extern weaponsVault weaponData[MAX_WEAPONS+MAX_CWEAPONS]; diff --git a/dlls/csstats2/csstats/usermsg.cpp b/dlls/csstats2/csstats/usermsg.cpp index e7d2c470..6a4d26a2 100755 --- a/dlls/csstats2/csstats/usermsg.cpp +++ b/dlls/csstats2/csstats/usermsg.cpp @@ -90,11 +90,12 @@ void Client_Damage_End(void* mValue){ TA = 0; if ( (mPlayer->teamId == pAttacker->teamId) && (mPlayer != pAttacker) ) TA = 1; - MF_ExecuteForward( iFDamage, pAttacker->index, mPlayer->index, damage, weapon, aim, TA ); + + g_damage_info.exec( 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 ); + g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA ); } } @@ -148,7 +149,6 @@ void Client_AmmoPickup(void* mValue){ } } - void Client_ScoreInfo(void* mValue){ static int index; switch (mState++){ diff --git a/dlls/dod2/dodx/NBase.cpp b/dlls/dod2/dodx/NBase.cpp index 976532ae..a14580bc 100755 --- a/dlls/dod2/dodx/NBase.cpp +++ b/dlls/dod2/dodx/NBase.cpp @@ -219,7 +219,7 @@ AMX_NATIVE_INFO base_Natives[] = { { "dod_user_kill", user_kill }, { "dod_get_pronestate", get_user_pronestate }, - {"register_forward",register_forward }, + {"register_statsfwd",register_forward }, ///******************* { NULL, NULL } diff --git a/dlls/dod2/dodx/moduleconfig.h b/dlls/dod2/dodx/moduleconfig.h index c0a12d13..ccdd4690 100755 --- a/dlls/dod2/dodx/moduleconfig.h +++ b/dlls/dod2/dodx/moduleconfig.h @@ -5,9 +5,9 @@ // Module info #define MODULE_NAME "DoDX" -#define MODULE_VERSION "0.1" +#define MODULE_VERSION "0.20" #define MODULE_AUTHOR "SidLuke" -#define MODULE_URL "www.amxmodx.org" +#define MODULE_URL "http://www.amxmodx.org/" #define MODULE_LOGTAG "DODX" // If you want the module not to be reloaded on mapchange, remove / comment out the next line #define MODULE_RELOAD_ON_MAPCHANGE diff --git a/dlls/tfc/tfcx/NBase.cpp b/dlls/tfc/tfcx/NBase.cpp index 3c0bc737..6ce158b1 100755 --- a/dlls/tfc/tfcx/NBase.cpp +++ b/dlls/tfc/tfcx/NBase.cpp @@ -431,7 +431,7 @@ AMX_NATIVE_INFO base_Natives[] = { {"tfc_setpddata", TFC_SetPDdata }, - {"register_forward",register_forward }, + {"register_statsfwd",register_forward }, //******************* 19 :) {NULL, NULL} }; diff --git a/dlls/tfc/tfcx/moduleconfig.h b/dlls/tfc/tfcx/moduleconfig.h index ce14afb3..81fb6897 100755 --- a/dlls/tfc/tfcx/moduleconfig.h +++ b/dlls/tfc/tfcx/moduleconfig.h @@ -5,9 +5,9 @@ // Module info #define MODULE_NAME "TFCX" -#define MODULE_VERSION "0.1" -#define MODULE_AUTHOR "SidLuke" -#define MODULE_URL "www.amxmodx.org" +#define MODULE_VERSION "0.20" +#define MODULE_AUTHOR "AMXx Dev Team" +#define MODULE_URL "http://www.amxmodx.org/" #define MODULE_LOGTAG "TFCX" // If you want the module not to be reloaded on mapchange, remove / comment out the next line #define MODULE_RELOAD_ON_MAPCHANGE diff --git a/dlls/ts/tsx/NBase.cpp b/dlls/ts/tsx/NBase.cpp index bd526631..dbdfb5b8 100755 --- a/dlls/ts/tsx/NBase.cpp +++ b/dlls/ts/tsx/NBase.cpp @@ -381,7 +381,7 @@ AMX_NATIVE_INFO base_Natives[] = { { "ts_setpddata",ts_setup }, - { "register_forward",register_forward }, + { "register_statsfwd",register_forward }, //"*******************" { NULL, NULL } diff --git a/dlls/ts/tsx/moduleconfig.h b/dlls/ts/tsx/moduleconfig.h index b9e3eb38..9a0c99e9 100755 --- a/dlls/ts/tsx/moduleconfig.h +++ b/dlls/ts/tsx/moduleconfig.h @@ -5,9 +5,9 @@ // Module info #define MODULE_NAME "TSX" -#define MODULE_VERSION "0.1" -#define MODULE_AUTHOR "SidLuke" -#define MODULE_URL "www.amxmodx.org" +#define MODULE_VERSION "0.2" +#define MODULE_AUTHOR "AMXx Dev Team" +#define MODULE_URL "http://www.amxmodx.org/" #define MODULE_LOGTAG "TSX" // If you want the module not to be reloaded on mapchange, remove / comment out the next line #define MODULE_RELOAD_ON_MAPCHANGE