forwards change

This commit is contained in:
Lukasz Wlasinksi 2004-07-01 10:12:50 +00:00
parent ed7b584b49
commit 3c99a32272
8 changed files with 99 additions and 14 deletions

View File

@ -276,3 +276,43 @@ void CPlayer::killPlayer(){
pEdict->v.weapons = 0; 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;
}
}

View File

@ -184,5 +184,27 @@ public:
void clear(); 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 #endif // CMISC_H

View File

@ -391,6 +391,30 @@ static cell AMX_NATIVE_CALL TFC_UserKill(AMX *amx, cell *params){ // player,wid
return 1; 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. // Native list.
AMX_NATIVE_INFO base_Natives[] = { AMX_NATIVE_INFO base_Natives[] = {
{"tfc_setmodel", TFC_SetModel}, {"tfc_setmodel", TFC_SetModel},
@ -406,6 +430,8 @@ AMX_NATIVE_INFO base_Natives[] = {
{"tfc_userkill" , TFC_UserKill}, {"tfc_userkill" , TFC_UserKill},
{"tfc_setpddata", TFC_SetPDdata }, {"tfc_setpddata", TFC_SetPDdata },
{"register_forward",register_forward },
//******************* 19 :) //******************* 19 :)
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -320,13 +320,13 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
int TA = 0; int TA = 0;
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) ) if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
TA = 1; 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() ) if ( pVic->IsAlive() )
return 1; return 1;
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA); 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; return 1;
} }

View File

@ -55,8 +55,8 @@ int gmsgAmmoPickup;
int mState; int mState;
int mPlayerIndex; int mPlayerIndex;
int iFDamage; Forward g_death_info;
int iFDeath; Forward g_damage_info;
RankSystem g_rank; RankSystem g_rank;
Grenades g_grenades; Grenades g_grenades;
@ -353,9 +353,6 @@ void FN_AMXX_Detach() {
g_grenades.clear(); g_grenades.clear();
g_rank.clear(); g_rank.clear();
g_rank.unloadCalc(); 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);
} }

View File

@ -32,7 +32,7 @@
#define FN_AMXX_DETTACH OnAmxxDettach #define FN_AMXX_DETTACH OnAmxxDettach
// All plugins loaded // All plugins loaded
// Do forward functions init here (MF_RegisterForward) // Do forward functions init here (MF_RegisterForward)
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded //#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
/**** METAMOD ****/ /**** METAMOD ****/
// If your module doesn't use metamod, you may close the file now :) // If your module doesn't use metamod, you may close the file now :)

View File

@ -81,8 +81,8 @@ extern CPlayer* mPlayer;
extern int mPlayerIndex; extern int mPlayerIndex;
extern int mState; extern int mState;
extern int iFDamage; extern Forward g_death_info;
extern int iFDeath; extern Forward g_damage_info;
//extern int gmsgCurWeapon; //extern int gmsgCurWeapon;
//extern int gmsgDamage; //extern int gmsgDamage;

View File

@ -225,11 +225,11 @@ void Client_Damage_End(void* mValue){
TA = 0; TA = 0;
if ( (mPlayer->teamId == pAttacker->teamId) && (mPlayer != pAttacker) ) if ( (mPlayer->teamId == pAttacker->teamId) && (mPlayer != pAttacker) )
TA = 1; 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() ){ if( !mPlayer->IsAlive() ){
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA); 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 );
} }
} }