From f3cfd31668d510a860a6723f890b504663af49c1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 3 Oct 2004 07:04:08 +0000 Subject: [PATCH] Added AlertMessage to fakemeta --- amxmodx/CLogEvent.cpp | 28 +++++++++------------------- amxmodx/meta_api.cpp | 6 ++++-- dlls/fakemeta/forward.cpp | 27 ++++++++++++++++++++++++++- dlls/fakemeta/forward.h | 3 ++- plugins/include/fakemeta_const.inc | 1 + 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/amxmodx/CLogEvent.cpp b/amxmodx/CLogEvent.cpp index b2da62aa..c6e07692 100755 --- a/amxmodx/CLogEvent.cpp +++ b/amxmodx/CLogEvent.cpp @@ -153,9 +153,11 @@ void LogEventsMngr::executeLogEvents() { int err; bool valid; - for(CLogEvent* a = logevents[ logArgc ]; a ; a = a->next){ + for(CLogEvent* a = logevents[ logArgc ]; a ; a = a->next) + { valid = true; - for( CLogEvent::LogCond* b = a->filters; b ; b = b->next){ + for( CLogEvent::LogCond* b = a->filters; b ; b = b->next) + { valid = false; for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) { if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){ @@ -163,27 +165,15 @@ void LogEventsMngr::executeLogEvents() break; } } - if (!valid) break; + if (!valid) + break; } -#ifdef ENABLEEXEPTIONS - try + if (valid) { -#endif - - if (valid){ - if ((err = amx_Exec(a->plugin->getAMX(), NULL , a->func , 0)) != AMX_ERR_NONE) - LogError(a->plugin->getAMX(), err, ""); - } - -#ifdef ENABLEEXEPTIONS + if ((err = amx_Exec(a->plugin->getAMX(), NULL , a->func , 0)) != AMX_ERR_NONE) + LogError(a->plugin->getAMX(), err, ""); } - catch( ... ) - { - AMXXLOG_Log( "[AMXX] fatal error at log forward function execution"); - } -#endif - } } diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 3497e3d9..a7fcdb1b 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -281,7 +281,7 @@ int C_Spawn( edict_t *pent ) { 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_PluginLog = registerForward("plugin_log", ET_STOP, 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); @@ -985,7 +985,9 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...) g_logevents.parseLogString( ); if (g_logevents.logEventsExist()) g_logevents.executeLogEvents( ); - executeForwards(FF_PluginLog); + cell retVal = executeForwards(FF_PluginLog); + if (retVal) + RETURN_META(MRES_HANDLED); } RETURN_META(MRES_IGNORED); diff --git a/dlls/fakemeta/forward.cpp b/dlls/fakemeta/forward.cpp index 550f9737..b5c4cf2a 100755 --- a/dlls/fakemeta/forward.cpp +++ b/dlls/fakemeta/forward.cpp @@ -111,6 +111,28 @@ void TraceLine_post(const float *v1, const float *v2, int fNoMonsters, edict_t * RETURN_META(MRES_IGNORED); } +void AlertMessage(ALERT_TYPE atype, char *szFmt, ...) +{ + static char buf[2048]; + va_list ap; + va_start(ap, szFmt); + vsprintf(buf, szFmt, ap); + va_end(ap); + FM_ENG_HANDLE(FM_AlertMessage, (Engine[FM_AlertMessage].at(i), atype, buf)); + RETURN_META(mswi(lastFmRes)); +} + +void AlertMessage_post(ALERT_TYPE atype, char *szFmt, ...) +{ + static char buf[2048]; + va_list ap; + va_start(ap, szFmt); + vsprintf(buf, szFmt, ap); + va_end(ap); + FM_ENG_HANDLE(FM_AlertMessage, (Engine[FM_AlertMessage].at(i), atype, buf)); + RETURN_META(MRES_IGNORED); +} + // pfnModelIndex SIMPLE_INT_HOOK_CONSTSTRING(ModelIndex); @@ -872,7 +894,10 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params) ENGHOOK(IsMapValid); break; - + case FM_AlertMessage: + fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_STRING, FP_DONE); + ENGHOOK(AlertMessage); + break; /* * Begin of DLLFuncs diff --git a/dlls/fakemeta/forward.h b/dlls/fakemeta/forward.h index ed91ff3d..5dbbc2f2 100755 --- a/dlls/fakemeta/forward.h +++ b/dlls/fakemeta/forward.h @@ -1,7 +1,7 @@ #ifndef _INCLUDE_FORWARD_H #define _INCLUDE_FORWARD_H -#define ENGFUNC_NUM 108 +#define ENGFUNC_NUM 118 #define FMV_STRING 1 #define FMV_FLOAT 2 @@ -148,6 +148,7 @@ enum { // Create baselines for certain "unplaced" items. FM_CreateInstancedBaselines, // done FM_AllowLagCompensation, // done + FM_AlertMessage, }; extern CVector Engine[]; diff --git a/plugins/include/fakemeta_const.inc b/plugins/include/fakemeta_const.inc index 10bd2d97..d961715a 100755 --- a/plugins/include/fakemeta_const.inc +++ b/plugins/include/fakemeta_const.inc @@ -436,6 +436,7 @@ enum { // Create baselines for certain "unplaced" items. FM_CreateInstancedBaseline, // done FM_AllowLagCompensation, // done + FM_AlertMessage, //done (at_type, message[]) }; enum TraceResult