diff --git a/dlls/tfc/tfcx/CMisc.cpp b/dlls/tfc/tfcx/CMisc.cpp index 1f1f6d36..c938a295 100755 --- a/dlls/tfc/tfcx/CMisc.cpp +++ b/dlls/tfc/tfcx/CMisc.cpp @@ -276,3 +276,43 @@ void CPlayer::killPlayer(){ pEdict->v.weapons = 0; } +// ***************************************************** +// 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; + } +} diff --git a/dlls/tfc/tfcx/CMisc.h b/dlls/tfc/tfcx/CMisc.h index 7921562b..3db7c3e7 100755 --- a/dlls/tfc/tfcx/CMisc.h +++ b/dlls/tfc/tfcx/CMisc.h @@ -184,5 +184,27 @@ 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/tfc/tfcx/NBase.cpp b/dlls/tfc/tfcx/NBase.cpp index decd2fc1..3c0bc737 100755 --- a/dlls/tfc/tfcx/NBase.cpp +++ b/dlls/tfc/tfcx/NBase.cpp @@ -391,6 +391,30 @@ static cell AMX_NATIVE_CALL TFC_UserKill(AMX *amx, cell *params){ // player,wid return 1; } +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; +} + // Native list. AMX_NATIVE_INFO base_Natives[] = { {"tfc_setmodel", TFC_SetModel}, @@ -406,6 +430,8 @@ AMX_NATIVE_INFO base_Natives[] = { {"tfc_userkill" , TFC_UserKill}, {"tfc_setpddata", TFC_SetPDdata }, + + {"register_forward",register_forward }, //******************* 19 :) {NULL, NULL} }; diff --git a/dlls/tfc/tfcx/NRank.cpp b/dlls/tfc/tfcx/NRank.cpp index c373bf54..8364f15f 100755 --- a/dlls/tfc/tfcx/NRank.cpp +++ b/dlls/tfc/tfcx/NRank.cpp @@ -320,13 +320,13 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg int TA = 0; if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( 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; } diff --git a/dlls/tfc/tfcx/moduleconfig.cpp b/dlls/tfc/tfcx/moduleconfig.cpp index d903461f..926de3f7 100755 --- a/dlls/tfc/tfcx/moduleconfig.cpp +++ b/dlls/tfc/tfcx/moduleconfig.cpp @@ -55,8 +55,8 @@ int gmsgAmmoPickup; int mState; int mPlayerIndex; -int iFDamage; -int iFDeath; +Forward g_death_info; +Forward g_damage_info; RankSystem g_rank; Grenades g_grenades; @@ -353,9 +353,6 @@ void FN_AMXX_Detach() { g_grenades.clear(); g_rank.clear(); g_rank.unloadCalc(); + g_damage_info.clear(); + g_death_info.clear(); } - -void FN_AMXX_PLUGINSLOADED(){ - 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); -} \ No newline at end of file diff --git a/dlls/tfc/tfcx/moduleconfig.h b/dlls/tfc/tfcx/moduleconfig.h index 31c4c9a8..cb8e9835 100755 --- a/dlls/tfc/tfcx/moduleconfig.h +++ b/dlls/tfc/tfcx/moduleconfig.h @@ -32,7 +32,7 @@ #define FN_AMXX_DETTACH OnAmxxDettach // All plugins loaded // Do forward functions init here (MF_RegisterForward) -#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded +//#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded /**** METAMOD ****/ // If your module doesn't use metamod, you may close the file now :) diff --git a/dlls/tfc/tfcx/tfcx.h b/dlls/tfc/tfcx/tfcx.h index 2309d989..5fdde031 100755 --- a/dlls/tfc/tfcx/tfcx.h +++ b/dlls/tfc/tfcx/tfcx.h @@ -81,8 +81,8 @@ extern CPlayer* mPlayer; extern int mPlayerIndex; extern int mState; -extern int iFDamage; -extern int iFDeath; +extern Forward g_death_info; +extern Forward g_damage_info; //extern int gmsgCurWeapon; //extern int gmsgDamage; diff --git a/dlls/tfc/tfcx/usermsg.cpp b/dlls/tfc/tfcx/usermsg.cpp index c79a0dd8..1fa4b529 100755 --- a/dlls/tfc/tfcx/usermsg.cpp +++ b/dlls/tfc/tfcx/usermsg.cpp @@ -225,11 +225,11 @@ 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 ); } }