omg sidluke why was this using amxmod api still?!?!

This commit is contained in:
David Anderson 2005-08-01 03:19:46 +00:00
parent 4fe39dd5cc
commit 71eac5c544
11 changed files with 33 additions and 109 deletions

View File

@ -278,44 +278,3 @@ void CPlayer::killPlayer(){
pEdict->v.weaponmodel = 0; pEdict->v.weaponmodel = 0;
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,27 +184,5 @@ 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

@ -194,8 +194,10 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
calc.physAddr2[i] = rr->bodyHits[i]; calc.physAddr2[i] = rr->bodyHits[i];
cell result = 0; cell result = 0;
int err; int err;
if ((err = MF_AmxExec(&calc.amx,&result, calc.func ,2,calc.amxAddr1,calc.amxAddr2 )) != AMX_ERR_NONE) MF_AmxPush(&calc.amx, calc.amxAddr2);
LOG_CONSOLE( PLID, "Run time error %d on line %ld (plugin \"%s\")", err,calc.amx.curline,LOCALINFO("csstats_score")); MF_AmxPush(&calc.amx, calc.amxAddr1);
if ((err = MF_AmxExec(&calc.amx,&result, calc.func)) != AMX_ERR_NONE)
MF_LogError(&calc.amx, err, "Fatal error calculating stats");
rr->score = result; rr->score = result;
} }
else rr->score = rr->kills - rr->deaths; else rr->score = rr->kills - rr->deaths;

View File

@ -372,31 +372,6 @@ 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;
int err;
switch( params[1] ){
case 0:
if( (err=MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex)) == AMX_ERR_NONE )
g_damage_info.put( amx , iFunctionIndex );
else
MF_LogError(amx, err, "Error finding function \"client_damage\"");
return 0;
break;
case 1:
if( (err=MF_AmxFindPublic(amx, "client_death", &iFunctionIndex)) == AMX_ERR_NONE )
g_death_info.put( amx , iFunctionIndex );
else
MF_LogError(amx, err, "Error finding function \"client_death\"");
return 0;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid forward id %d", params[1]);
return 0;
}
return 1;
}
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){ static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){
return TFCMAX_WEAPONS; return TFCMAX_WEAPONS;
} }
@ -413,6 +388,11 @@ static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){
return 1; return 1;
} }
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
{
return 1;
}
// Native list. // Native list.
AMX_NATIVE_INFO base_Natives[] = { AMX_NATIVE_INFO base_Natives[] = {
{"tfc_setmodel", TFC_SetModel}, {"tfc_setmodel", TFC_SetModel},

View File

@ -287,13 +287,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;
g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA ); MF_ExecuteForward(g_damage_info, 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);
g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA ); MF_ExecuteForward(g_death_info, pAtt->index, pVic->index, dmg, weapon, aim, TA);
return 1; return 1;
} }

View File

@ -2502,6 +2502,7 @@ PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction; PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction; PFN_REQ_FNPTR g_fn_RequestFunction;
PFN_AMX_PUSH g_fn_AmxPush;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2610,6 +2611,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH); REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS); REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT); REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
// Memory // Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR); REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2717,7 +2719,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_IsPlayerHLTV(0); MF_IsPlayerHLTV(0);
MF_GetPlayerArmor(0); MF_GetPlayerArmor(0);
MF_GetPlayerHealth(0); MF_GetPlayerHealth(0);
MF_AmxExec(0, 0, 0, 0); MF_AmxExec(0, 0, 0);
MF_AmxExecv(0, 0, 0, 0, 0); MF_AmxExecv(0, 0, 0, 0, 0);
MF_AmxFindPublic(0, 0, 0); MF_AmxFindPublic(0, 0, 0);
MF_AmxAllot(0, 0, 0, 0); MF_AmxAllot(0, 0, 0, 0);

View File

@ -1987,7 +1987,7 @@ typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ ); const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const void* /*addr*/ ); const unsigned int /*type*/, const void* /*addr*/ );
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, ... /*params*/); typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/); typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/); typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/); typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
@ -2002,6 +2002,7 @@ typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/); typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -2065,6 +2066,7 @@ extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction; extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction; extern PFN_REQ_FNPTR g_fn_RequestFunction;
extern PFN_AMX_PUSH g_fn_AmxPush;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
@ -2123,6 +2125,8 @@ edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { } void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { } void * MF_RequestFunction (const char *description) { }
int MF_AmxPush (AMX *amx, cell *params) { }
int MF_AmxExec (AMX *amx, cell *retval, int idx) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
@ -2187,6 +2191,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction #define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction; #define MF_RequestFunction g_fn_RequestFunction;
#define MF_AmxPush g_fn_AmxPush
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -55,8 +55,8 @@ int gmsgAmmoPickup;
int mState; int mState;
int mPlayerIndex; int mPlayerIndex;
Forward g_death_info; int g_death_info;
Forward g_damage_info; int g_damage_info;
RankSystem g_rank; RankSystem g_rank;
Grenades g_grenades; Grenades g_grenades;
@ -349,10 +349,8 @@ void OnAmxxAttach() {
} }
void OnAmxxDetach() { void OnPluginsLoaded()
g_grenades.clear(); {
g_rank.clear(); g_damage_info = MF_RegisterForward("client_damage", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
g_rank.unloadCalc(); g_damage_info = MF_RegisterForward("client_death", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
g_damage_info.clear();
g_death_info.clear();
} }

View File

@ -29,10 +29,10 @@
// Do native functions init here (MF_AddNatives) // Do native functions init here (MF_AddNatives)
#define FN_AMXX_ATTACH OnAmxxAttach #define FN_AMXX_ATTACH OnAmxxAttach
// AMXX dettach // AMXX dettach
#define FN_AMXX_DETACH OnAmxxDetach // #define FN_AMXX_DETACH OnAmxxDetach
// 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 Forward g_death_info; extern int g_death_info;
extern Forward g_damage_info; extern int 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;
g_damage_info.exec( pAttacker->index, mPlayer->index, damage, weapon, aim, TA ); MF_ExecuteForward(g_damage_info, 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);
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA ); MF_ExecuteForward(g_death_info, pAttacker->index, mPlayer->index, damage, weapon, aim, TA);
} }
} }