mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 06:45:37 +03:00
removed amx_version cvar
added amxmodx_modules cvar using new forward functions
This commit is contained in:
parent
dab5306655
commit
d98d6af9e3
@ -93,10 +93,26 @@ int mState;
|
|||||||
int g_srvindex;
|
int g_srvindex;
|
||||||
|
|
||||||
cvar_t init_amxmodx_version = {"amxmodx_version", "", FCVAR_SERVER | FCVAR_SPONLY};
|
cvar_t init_amxmodx_version = {"amxmodx_version", "", FCVAR_SERVER | FCVAR_SPONLY};
|
||||||
|
cvar_t init_amxmodx_modules = {"amxmodx_modules", "", FCVAR_SPONLY};
|
||||||
cvar_t* amxmodx_version = NULL;
|
cvar_t* amxmodx_version = NULL;
|
||||||
|
cvar_t* amxmodx_modules = NULL;
|
||||||
cvar_t* hostname = NULL;
|
cvar_t* hostname = NULL;
|
||||||
cvar_t* mp_timelimit = NULL;
|
cvar_t* mp_timelimit = NULL;
|
||||||
|
|
||||||
|
// main forwards
|
||||||
|
int FF_ClientCommand = -1;
|
||||||
|
int FF_ClientConnect = -1;
|
||||||
|
int FF_ClientDisconnect = -1;
|
||||||
|
int FF_ClientInfoChanged = -1;
|
||||||
|
int FF_ClientPutInServer = -1;
|
||||||
|
int FF_PluginInit = -1;
|
||||||
|
int FF_PluginCfg = -1;
|
||||||
|
int FF_PluginPrecache = -1;
|
||||||
|
int FF_PluginLog = -1;
|
||||||
|
int FF_PluginEnd = -1;
|
||||||
|
int FF_InconsistentFile = -1;
|
||||||
|
int FF_ClientAuthorized = -1;
|
||||||
|
|
||||||
// Precache stuff from force consistency calls
|
// Precache stuff from force consistency calls
|
||||||
// or check for pointed files won't be done
|
// or check for pointed files won't be done
|
||||||
int PrecacheModel(char *s) {
|
int PrecacheModel(char *s) {
|
||||||
@ -129,22 +145,19 @@ int PrecacheSound(char *s) {
|
|||||||
// On InconsistentFile call forward function from plugins
|
// On InconsistentFile call forward function from plugins
|
||||||
int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message )
|
int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message )
|
||||||
{
|
{
|
||||||
if ( !g_forwards.forwardsExist( FF_InconsistentFile ) )
|
if (FF_InconsistentFile < 0)
|
||||||
RETURN_META_VALUE(MRES_IGNORED, FALSE);
|
RETURN_META_VALUE(MRES_IGNORED, FALSE);
|
||||||
|
|
||||||
if ( MDLL_InconsistentFile(player,filename,disconnect_message) )
|
if ( MDLL_InconsistentFile(player,filename,disconnect_message) )
|
||||||
{
|
{
|
||||||
cell ret = 0;
|
cell ret = 0;
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER((edict_t *)player);
|
CPlayer *pPlayer = GET_PLAYER_POINTER((edict_t *)player);
|
||||||
CForwardMngr::iterator a = g_forwards.begin( FF_InconsistentFile );
|
|
||||||
|
|
||||||
#ifdef ENABLEEXEPTIONS
|
#ifdef ENABLEEXEPTIONS
|
||||||
try{
|
try
|
||||||
#endif
|
|
||||||
|
|
||||||
while ( a )
|
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
if ( (*a).getPlugin()->isExecutable( (*a).getFunction() ) )
|
if ( (*a).getPlugin()->isExecutable( (*a).getFunction() ) )
|
||||||
{
|
{
|
||||||
AMX* c = (*a).getPlugin()->getAMX();
|
AMX* c = (*a).getPlugin()->getAMX();
|
||||||
@ -168,17 +181,16 @@ int InconsistentFile( const edict_t *player, const char *filename, char *disconn
|
|||||||
}
|
}
|
||||||
if ( ret & 1 ) RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
|
if ( ret & 1 ) RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
if (executeForwards(FF_InconsistentFile, pPlayer->index, filename, disconnect_message) == 1)
|
||||||
++a;
|
RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
|
||||||
}
|
|
||||||
#ifdef ENABLEEXEPTIONS
|
#ifdef ENABLEEXEPTIONS
|
||||||
}catch( ... )
|
}
|
||||||
|
catch( ... )
|
||||||
{
|
{
|
||||||
AMXXLOG_Log( "[AMXX] fatal error at inconsistent file forward execution");
|
AMXXLOG_Log( "[AMXX] fatal error at inconsistent file forward execution");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, TRUE );
|
RETURN_META_VALUE(MRES_SUPERCEDE, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,15 +254,9 @@ int Spawn( edict_t *pent ) {
|
|||||||
int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat
|
int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat
|
||||||
// Set some info about amx version and modules
|
// Set some info about amx version and modules
|
||||||
// :TODO: Remove modules num from amxmodx_version, make amxmodx_modules cvar
|
// :TODO: Remove modules num from amxmodx_version, make amxmodx_modules cvar
|
||||||
if ( loaded ){
|
CVAR_SET_STRING(init_amxmodx_version.name, AMX_VERSION);
|
||||||
char buffer[64];
|
char buffer[32];
|
||||||
sprintf( buffer,"%s (%d module%s)",
|
CVAR_SET_STRING(init_amxmodx_modules.name, itoa(loaded, buffer, 10));
|
||||||
AMX_VERSION, loaded , (loaded == 1) ? "" : "s" );
|
|
||||||
CVAR_SET_STRING( "amxmodx_version", buffer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CVAR_SET_STRING( "amxmodx_version", AMX_VERSION );
|
|
||||||
}
|
|
||||||
|
|
||||||
// ###### Load Vault
|
// ###### Load Vault
|
||||||
g_vault.setSource( build_pathname("%s", get_localinfo("amxx_vault", "addons/amxx/configs/vault.ini")) );
|
g_vault.setSource( build_pathname("%s", get_localinfo("amxx_vault", "addons/amxx/configs/vault.ini")) );
|
||||||
@ -269,9 +275,25 @@ int Spawn( edict_t *pent ) {
|
|||||||
// ###### Load AMX scripts
|
// ###### Load AMX scripts
|
||||||
g_plugins.loadPluginsFromFile( get_localinfo("amxx_plugins", "addons/amxx/plugins.ini") );
|
g_plugins.loadPluginsFromFile( get_localinfo("amxx_plugins", "addons/amxx/plugins.ini") );
|
||||||
|
|
||||||
|
// Register forwards
|
||||||
|
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
|
||||||
|
FF_ClientCommand = registerForward("client_command", ET_IGNORE, FP_CELL, FP_DONE);
|
||||||
|
FF_ClientConnect = registerForward("client_connect", ET_IGNORE, FP_CELL, FP_DONE);
|
||||||
|
FF_ClientDisconnect = registerForward("client_disconnect", ET_IGNORE, FP_CELL, FP_DONE);
|
||||||
|
FF_ClientInfoChanged = registerForward("client_infochanged", ET_IGNORE, FP_CELL, FP_DONE);
|
||||||
|
FF_ClientPutInServer = registerForward("client_putinserver", ET_IGNORE, FP_CELL, FP_DONE);
|
||||||
|
FF_PluginCfg = registerForward("plugin_cfg", ET_IGNORE, FP_DONE);
|
||||||
|
FF_PluginPrecache = registerForward("plugin_precache", ET_IGNORE, FP_DONE);
|
||||||
|
FF_PluginLog = registerForward("plugin_log", ET_IGNORE, FP_DONE);
|
||||||
|
FF_PluginEnd = registerForward("plugin_end", ET_IGNORE, FP_DONE);
|
||||||
|
FF_InconsistentFile = registerForward("inconsistent_file", ET_STOP, FP_CELL, FP_STRING, FP_STRINGEX, FP_DONE);
|
||||||
|
FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_DONE);
|
||||||
|
|
||||||
|
modules_callPluginsLoaded();
|
||||||
|
|
||||||
// ###### Call precache forward function
|
// ###### Call precache forward function
|
||||||
g_dontprecache = false;
|
g_dontprecache = false;
|
||||||
g_forwards.executeForwards(FF_PluginPrecache);
|
executeForwards(FF_PluginPrecache);
|
||||||
g_dontprecache = true;
|
g_dontprecache = true;
|
||||||
|
|
||||||
for(CList<ForceObject>::iterator a = g_forcegeneric.begin(); a ; ++a){
|
for(CList<ForceObject>::iterator a = g_forcegeneric.begin(); a ; ++a){
|
||||||
@ -376,8 +398,8 @@ void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
|
|||||||
pPlayer->Init( pEdictList + i , i );
|
pPlayer->Init( pEdictList + i , i );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_PluginInit);
|
executeForwards(FF_PluginInit);
|
||||||
g_forwards.executeForwards(FF_PluginCfg);
|
executeForwards(FF_PluginCfg);
|
||||||
|
|
||||||
// Correct time in Counter-Strike and other mods (except DOD)
|
// Correct time in Counter-Strike and other mods (except DOD)
|
||||||
if ( !g_bmod_dod) g_game_timeleft = 0;
|
if ( !g_bmod_dod) g_game_timeleft = 0;
|
||||||
@ -395,7 +417,7 @@ void ServerDeactivate() {
|
|||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||||
if (pPlayer->ingame){
|
if (pPlayer->ingame){
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_ClientDisconnect , 1,pPlayer->index);
|
executeForwards(FF_ClientDisconnect, pPlayer->index);
|
||||||
|
|
||||||
pPlayer->Disconnect();
|
pPlayer->Disconnect();
|
||||||
--g_players_num;
|
--g_players_num;
|
||||||
@ -403,7 +425,7 @@ void ServerDeactivate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_players_num = 0;
|
g_players_num = 0;
|
||||||
g_forwards.executeForwards(FF_PluginEnd);
|
executeForwards(FF_PluginEnd);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
@ -443,7 +465,7 @@ BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszA
|
|||||||
|
|
||||||
bool a = pPlayer->Connect(pszName,pszAddress);
|
bool a = pPlayer->Connect(pszName,pszAddress);
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_ClientConnect , 1,pPlayer->index);
|
executeForwards(FF_ClientConnect, pPlayer->index);
|
||||||
|
|
||||||
if ( a )
|
if ( a )
|
||||||
{
|
{
|
||||||
@ -453,7 +475,7 @@ BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszA
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pPlayer->Authorize();
|
pPlayer->Authorize();
|
||||||
g_forwards.executeForwards(FF_ClientAuthorized , 1, pPlayer->index );
|
executeForwards(FF_ClientAuthorized, pPlayer->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
||||||
@ -462,7 +484,7 @@ BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszA
|
|||||||
void ClientDisconnect( edict_t *pEntity ) {
|
void ClientDisconnect( edict_t *pEntity ) {
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||||
if (pPlayer->ingame) {
|
if (pPlayer->ingame) {
|
||||||
g_forwards.executeForwards(FF_ClientDisconnect , 1,pPlayer->index);
|
executeForwards(FF_ClientDisconnect, pPlayer->index);
|
||||||
pPlayer->Disconnect();
|
pPlayer->Disconnect();
|
||||||
--g_players_num;
|
--g_players_num;
|
||||||
}
|
}
|
||||||
@ -475,7 +497,7 @@ void ClientPutInServer_Post( edict_t *pEntity ) {
|
|||||||
pPlayer->PutInServer();
|
pPlayer->PutInServer();
|
||||||
++g_players_num;
|
++g_players_num;
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_ClientPutInServer , 1,pPlayer->index);
|
executeForwards(FF_ClientPutInServer, pPlayer->index);
|
||||||
|
|
||||||
}
|
}
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
@ -484,7 +506,7 @@ void ClientPutInServer_Post( edict_t *pEntity ) {
|
|||||||
void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) {
|
void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) {
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_ClientInfoChanged , 1,pPlayer->index);
|
executeForwards(FF_ClientInfoChanged, pPlayer->index);
|
||||||
|
|
||||||
const char* name = INFOKEY_VALUE(infobuffer,"name");
|
const char* name = INFOKEY_VALUE(infobuffer,"name");
|
||||||
|
|
||||||
@ -497,16 +519,16 @@ void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) {
|
|||||||
{
|
{
|
||||||
pPlayer->Connect( name ,"127.0.0.1"/*CVAR_GET_STRING("net_address")*/);
|
pPlayer->Connect( name ,"127.0.0.1"/*CVAR_GET_STRING("net_address")*/);
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_ClientConnect , 1,pPlayer->index);
|
executeForwards(FF_ClientConnect, pPlayer->index);
|
||||||
|
|
||||||
pPlayer->Authorize();
|
pPlayer->Authorize();
|
||||||
g_forwards.executeForwards(FF_ClientAuthorized , 1, pPlayer->index );
|
executeForwards(FF_ClientAuthorized, pPlayer->index);
|
||||||
|
|
||||||
|
|
||||||
pPlayer->PutInServer();
|
pPlayer->PutInServer();
|
||||||
++g_players_num;
|
++g_players_num;
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_ClientPutInServer , 1,pPlayer->index);
|
executeForwards(FF_ClientPutInServer, pPlayer->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
@ -522,30 +544,12 @@ void ClientCommand( edict_t *pEntity ) {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
/* because of PLUGIN_HANDLED_MAIN we must call function (client_command) manualy */
|
if (executeForwards(FF_ClientCommand, pPlayer->index) > 0)
|
||||||
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
CForwardMngr::iterator a = g_forwards.begin( FF_ClientCommand );
|
|
||||||
|
|
||||||
while ( a )
|
|
||||||
{
|
|
||||||
if ( (*a).getPlugin()->isExecutable( (*a).getFunction() ) )
|
|
||||||
{
|
|
||||||
|
|
||||||
if ((err = amx_Exec((*a).getPlugin()->getAMX(), &ret , (*a).getFunction(), 1, pPlayer->index)) != AMX_ERR_NONE)
|
|
||||||
AMXXLOG_Log("[AMXX] Run time error %d on line %ld (plugin \"%s\")",
|
|
||||||
err,(*a).getPlugin()->getAMX()->curline,(*a).getPlugin()->getName() );
|
|
||||||
|
|
||||||
if ( ret & 2 ) result = MRES_SUPERCEDE;
|
|
||||||
if ( ret & 1 ) RETURN_META(MRES_SUPERCEDE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
++a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLEEXEPTIONS
|
#ifdef ENABLEEXEPTIONS
|
||||||
}catch( ... )
|
}
|
||||||
|
catch( ... )
|
||||||
{
|
{
|
||||||
AMXXLOG_Log( "[AMXX] fatal error at commmand forward execution");
|
AMXXLOG_Log( "[AMXX] fatal error at commmand forward execution");
|
||||||
}
|
}
|
||||||
@ -653,7 +657,7 @@ void StartFrame_Post( void ) {
|
|||||||
if ( strcmp( auth, "STEAM_ID_PENDING" ) )
|
if ( strcmp( auth, "STEAM_ID_PENDING" ) )
|
||||||
{
|
{
|
||||||
(*a)->Authorize();
|
(*a)->Authorize();
|
||||||
g_forwards.executeForwards(FF_ClientAuthorized , 1,(*a)->index);
|
executeForwards(FF_ClientAuthorized, (*a)->index);
|
||||||
a.remove();
|
a.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -899,16 +903,16 @@ void AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...) {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_forwards.executeForwards(FF_PluginLog);
|
executeForwards(FF_PluginLog);
|
||||||
}
|
}
|
||||||
else if (g_forwards.forwardsExist( FF_PluginLog ))
|
else if (FF_PluginLog >= 0)
|
||||||
{
|
{
|
||||||
va_list logArgPtr;
|
va_list logArgPtr;
|
||||||
va_start ( logArgPtr , szFmt );
|
va_start ( logArgPtr , szFmt );
|
||||||
g_logevents.setLogString( szFmt , logArgPtr );
|
g_logevents.setLogString( szFmt , logArgPtr );
|
||||||
va_end ( logArgPtr );
|
va_end ( logArgPtr );
|
||||||
g_logevents.parseLogString( );
|
g_logevents.parseLogString( );
|
||||||
g_forwards.executeForwards(FF_PluginLog);
|
executeForwards(FF_PluginLog);
|
||||||
}
|
}
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
@ -951,6 +955,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||||||
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
|
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
|
||||||
gpGamedllFuncs=pGamedllFuncs;
|
gpGamedllFuncs=pGamedllFuncs;
|
||||||
CVAR_REGISTER(&init_amxmodx_version);
|
CVAR_REGISTER(&init_amxmodx_version);
|
||||||
|
CVAR_REGISTER(&init_amxmodx_modules);
|
||||||
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
||||||
REG_SVR_COMMAND("amxx",amx_command);
|
REG_SVR_COMMAND("amxx",amx_command);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user