diff --git a/dlls/engine/amxxapi.cpp b/dlls/engine/amxxapi.cpp index 4116f876..b80a0c57 100755 --- a/dlls/engine/amxxapi.cpp +++ b/dlls/engine/amxxapi.cpp @@ -11,6 +11,17 @@ int AmxStringToEngine(AMX *amx, cell param, int &len) return ALLOC_STRING(szString); } +void EngineError(AMX *amx, char *fmt, ...) +{ + va_list p; + va_start(p, fmt); + char errbuf[512]; + vsprintf(errbuf, fmt, p); + va_end(p); + MF_Log("%s (\"%s\", line %d)", errbuf, MF_GetScriptName(MF_FindScriptByAmx(amx)), amx->curline); + MF_RaiseAmxError(amx, AMX_ERR_NATIVE); +} + void OnAmxxAttach() { pfnTouchForward = 0; diff --git a/dlls/engine/amxxmodule.h b/dlls/engine/amxxmodule.h index b548edf1..35534730 100755 --- a/dlls/engine/amxxmodule.h +++ b/dlls/engine/amxxmodule.h @@ -240,6 +240,14 @@ enum { AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */ }; +#if !defined AMX_NO_ALIGN + #if defined __linux__ + #pragma pack() /* reset default packing */ + #else + #pragma pack(pop) /* reset previous packing */ + #endif +#endif + // ***** declare functions ***** @@ -257,9 +265,9 @@ void FN_META_QUERY(void); void FN_META_ATTACH(void); #endif // FN_META_ATTACH -#ifdef FN_META_DETTACH -void FN_META_DETTACH(void); -#endif // FN_META_DETTACH +#ifdef FN_META_DETACH +void FN_META_DETACH(void); +#endif // FN_META_DETACH @@ -1869,9 +1877,9 @@ void FN_AMXX_QUERY(void); void FN_AMXX_ATTACH(void); #endif // FN_AMXX_ATTACH -#ifdef FN_AMXX_DETTACH -void FN_AMXX_DETTACH(void); -#endif // FN_AMXX_DETTACH +#ifdef FN_AMXX_DETACH +void FN_AMXX_DETACH(void); +#endif // FN_AMXX_DETACH #ifdef FN_AMXX_PLUGINSLOADED void FN_AMXX_PLUGINSLOADED(void); @@ -1947,6 +1955,7 @@ typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*in 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_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/); +typedef int (*PFN_AMX_FINDNATIVE) (AMX* /*amx*/, char* /*func name*/, int* /*index*/); typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/); typedef int (*PFN_UNLOAD_AMXSCRIPT) (AMX* /*amx*/,void** /*code*/); typedef cell (*PFN_REAL_TO_CELL) (REAL /*x*/); @@ -1954,6 +1963,7 @@ typedef REAL (*PFN_CELL_TO_REAL) (cell /*x*/); typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*params*/); typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); +typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_BUILD_PATHNAME g_fn_BuildPathname; @@ -2005,6 +2015,8 @@ extern PFN_CELL_TO_REAL g_fn_CellToReal; extern PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward; extern PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName; extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward; +extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File; +extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative; #ifdef MAY_NEVER_BE_DEFINED // Function prototypes for intellisense and similar systems @@ -2098,8 +2110,10 @@ void MF_Log(const char *fmt, ...); #define MF_AmxExecv g_fn_AmxExecv #define MF_AmxFindPublic g_fn_AmxFindPublic #define MF_AmxAllot g_fn_AmxAllot +#define MF_AmxFindNative g_fn_AmxFindNative #define MF_LoadAmxScript g_fn_LoadAmxScript #define MF_UnloadAmxScript g_fn_UnloadAmxScript +#define MF_MergeDefinitionFile g_fn_MergeDefinition_File #define amx_ctof g_fn_CellToReal #define amx_ftoc g_fn_RealToCell #define MF_RegisterSPForwardByName g_fn_RegisterSPForwardByName @@ -2149,4 +2163,5 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons #define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr) #define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr) + #endif // #ifndef __AMXXMODULE_H__ diff --git a/dlls/engine/engine.cpp b/dlls/engine/engine.cpp index 4a1003d3..e2adf3db 100755 --- a/dlls/engine/engine.cpp +++ b/dlls/engine/engine.cpp @@ -100,7 +100,7 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params) Vector vVector = Vector(0, 0, 0); if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -324,7 +324,7 @@ static cell AMX_NATIVE_CALL set_speak(AMX *amx, cell *params) { int iNewSpeakFlags = params[2]; if (iIndex> 32 || !is_ent_valid(iIndex)) { - MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + EngineError(amx, "Invalid player %d", iIndex); return 0; } @@ -337,7 +337,7 @@ static cell AMX_NATIVE_CALL get_speak(AMX *amx, cell *params) { int iIndex = params[1]; if (!is_ent_valid(iIndex) || iIndex > 32) { - MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + EngineError(amx, "Invalid player %d", iIndex); return 0; } @@ -364,7 +364,7 @@ static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params) int iEnt = params[1]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -382,7 +382,7 @@ static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params) int iEnt = params[1]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -408,12 +408,12 @@ static cell AMX_NATIVE_CALL attach_view(AMX *amx, cell *params) int iTargetIndex = params[2]; if (iIndex > 32 || !is_ent_valid(iIndex)) { - MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + EngineError(amx, "Invalid player %d", iIndex); return 0; } if (!is_ent_valid(iTargetIndex)) { - MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iIndex); return 0; } @@ -430,7 +430,7 @@ static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) { int iCameraType = params[2]; if (iIndex > 32 || !is_ent_valid(iIndex)) { - MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + EngineError(amx, "Invalid player %d", iIndex); return 0; } @@ -896,28 +896,6 @@ static cell AMX_NATIVE_CALL traceresult(AMX *amx, cell *params) return 0; } -//(mahnsawce) -static cell AMX_NATIVE_CALL take_damage(AMX *amx, cell *params) -{ - int indexa = params[1]; - int indexb = params[2]; - int indexc = params[3]; - if (!is_ent_valid(indexa) || !is_ent_valid(indexb) || !is_ent_valid(indexc)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); - return 0; - } - REAL fnDamage = amx_ctof(params[4]); - int inType = params[5]; - edict_t* pEntitya = INDEXENT2(indexa); - edict_t* pEntityb = INDEXENT2(indexb); - edict_t* pEntityc = INDEXENT2(indexc); - CBaseEntity *pCEntity = NULL; - pCEntity = (CBaseEntity*)((INDEXENT2(indexa))->pvPrivateData); - pCEntity->TakeDamage(VARS(pEntityb),VARS(pEntityc),fnDamage,inType); - return 1; -} - - AMX_NATIVE_INFO engine_Natives[] = { {"halflife_time", halflife_time}, @@ -937,7 +915,6 @@ AMX_NATIVE_INFO engine_Natives[] = { {"trace_line", trace_line}, {"trace_hull", trace_hull}, {"traceresult", traceresult}, - {"take_damage", take_damage}, {"set_speak", set_speak}, {"get_speak", get_speak}, diff --git a/dlls/engine/engine.h b/dlls/engine/engine.h index 640f4be4..4da239a8 100755 --- a/dlls/engine/engine.h +++ b/dlls/engine/engine.h @@ -7,11 +7,6 @@ #include #include "CVector.h" #include "CString.h" -#ifndef CBASEPLAYER_H -#define CBASEPLAYER_H -#include -#include -#endif #include "amxxmodule.h" #include #include "messages.h" @@ -177,7 +172,10 @@ inline edict_t* INDEXENT2( int iEdictNum ) else return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); } -#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; } + +void EngineError(AMX *amx, char *fmt, ...); + +#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { EngineError(amx, "Invalid entity %d", x); return 0; } extern bool g_inKeyValue; extern KeyValueData *g_pkvd; diff --git a/dlls/engine/entity.cpp b/dlls/engine/entity.cpp index 11670e7a..fc272705 100755 --- a/dlls/engine/entity.cpp +++ b/dlls/engine/entity.cpp @@ -27,7 +27,7 @@ static cell AMX_NATIVE_CALL entity_range(AMX *amx, cell *params) int idxb = params[2]; if (!is_ent_valid(idxa) || !is_ent_valid(idxb)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity"); return 0; } @@ -48,7 +48,7 @@ static cell AMX_NATIVE_CALL call_think(AMX *amx, cell *params) int iEnt = params[1]; if (is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -66,7 +66,7 @@ static cell AMX_NATIVE_CALL fake_touch(AMX *amx, cell *params) int iPtd = params[2]; if (!is_ent_valid(iPtr) || !is_ent_valid(iPtd)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity"); return 0; } @@ -84,7 +84,7 @@ static cell AMX_NATIVE_CALL force_use(AMX *amx, cell *params) int iPtd = params[2]; if (!is_ent_valid(iPtr) || !is_ent_valid(iPtd)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity"); return 0; } @@ -140,7 +140,7 @@ static cell AMX_NATIVE_CALL DispatchKeyValue(AMX *amx, cell *params) cell *cVal = MF_GetAmxAddr(amx, params[1]); int iValue = *cVal; if (!is_ent_valid(iValue)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iValue); return 0; } edict_t *pEntity = INDEXENT2(iValue); @@ -173,7 +173,7 @@ static cell AMX_NATIVE_CALL get_keyvalue(AMX *amx, cell *params) { int idx = params[1]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } edict_t *pEntity = INDEXENT2(idx); @@ -203,7 +203,7 @@ static cell AMX_NATIVE_CALL DispatchSpawn(AMX *amx, cell *params) int iEnt = params[1]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -225,7 +225,7 @@ static cell AMX_NATIVE_CALL entity_get_float(AMX *amx, cell *params) REAL fVal = 0; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -359,7 +359,7 @@ static cell AMX_NATIVE_CALL entity_set_float(AMX *amx, cell *params) REAL fVal = amx_ctof(params[3]); if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -493,7 +493,7 @@ static cell AMX_NATIVE_CALL entity_get_int(AMX *amx, cell *params) int iRetValue = 0; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -613,7 +613,7 @@ static cell AMX_NATIVE_CALL entity_get_int(AMX *amx, cell *params) iRetValue = pEnt->v.deadflag; break; default: - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid property %d", iEnt); return 0; break; } @@ -628,7 +628,7 @@ static cell AMX_NATIVE_CALL entity_set_int(AMX *amx, cell *params) int iNewValue = params[3]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -763,7 +763,7 @@ static cell AMX_NATIVE_CALL entity_get_vector(AMX *amx, cell *params) Vector vRetValue = Vector(0, 0, 0); if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -859,7 +859,7 @@ static cell AMX_NATIVE_CALL entity_set_vector(AMX *amx, cell *params) cell *vAmx = MF_GetAmxAddr(amx, params[3]); if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -956,7 +956,7 @@ static cell AMX_NATIVE_CALL entity_get_string(AMX *amx, cell *params) const char *szRet = NULL; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1021,7 +1021,7 @@ static cell AMX_NATIVE_CALL entity_set_string(AMX *amx, cell *params) int iszString = AmxStringToEngine(amx, params[3], iLen); if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1083,7 +1083,7 @@ static cell AMX_NATIVE_CALL entity_get_edict(AMX *amx, cell *params) edict_t *pRet; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1142,7 +1142,7 @@ static cell AMX_NATIVE_CALL entity_set_edict(AMX *amx, cell *params) int iSetEnt = params[3]; if (!is_ent_valid(iEnt) || !is_ent_valid(iSetEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1199,7 +1199,7 @@ static cell AMX_NATIVE_CALL entity_get_byte(AMX *amx, cell *params) int iRetValue = 0; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1240,7 +1240,7 @@ static cell AMX_NATIVE_CALL entity_set_byte(AMX *amx, cell *params) int iNewValue = params[3]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1284,7 +1284,7 @@ static cell AMX_NATIVE_CALL entity_set_origin(AMX *amx, cell *params) int iEnt = params[1]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1306,7 +1306,7 @@ static cell AMX_NATIVE_CALL entity_set_model(AMX *amx, cell *params) int iEnt = params[1]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1328,7 +1328,7 @@ static cell AMX_NATIVE_CALL entity_set_size(AMX *amx, cell *params) int iEnt = params[1]; if (!is_ent_valid(iEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", iEnt); return 0; } @@ -1361,7 +1361,7 @@ static cell AMX_NATIVE_CALL get_offset_short(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1379,7 +1379,7 @@ static cell AMX_NATIVE_CALL set_offset_short(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1399,7 +1399,7 @@ static cell AMX_NATIVE_CALL get_offset_char(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1418,7 +1418,7 @@ static cell AMX_NATIVE_CALL set_offset_char(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1439,7 +1439,7 @@ static cell AMX_NATIVE_CALL get_offset_int(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1457,7 +1457,7 @@ static cell AMX_NATIVE_CALL set_offset_int(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1477,7 +1477,7 @@ static cell AMX_NATIVE_CALL get_offset_float(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1497,7 +1497,7 @@ static cell AMX_NATIVE_CALL set_offset_float(AMX *amx, cell *params) int off = params[2]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1526,7 +1526,7 @@ static cell AMX_NATIVE_CALL find_ent_in_sphere(AMX *amx, cell *params) int idx = params[1]; if (!is_ent_valid(idx)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", idx); return 0; } @@ -1578,7 +1578,7 @@ static cell AMX_NATIVE_CALL find_sphere_class(AMX *amx, cell *params) // find_sp vec3_t vecOrigin; if (params[1] > 0) { if (!is_ent_valid(params[1])) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", params[1]); return 0; } @@ -1689,7 +1689,7 @@ static cell AMX_NATIVE_CALL find_ent_by_owner(AMX *amx, cell *params) // native int oEnt = params[3]; // Check index to start searching at, 0 must be possible. if (!is_ent_valid(iEnt) || !is_ent_valid(oEnt)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity"); return 0; } @@ -1727,7 +1727,7 @@ static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params) /* 4 param * char* szModel; if (!is_ent_valid(index)) { - MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + EngineError(amx, "Invalid Entity %d", index); return 0; } diff --git a/dlls/engine/forwards.cpp b/dlls/engine/forwards.cpp index 0851e351..7aab07b5 100755 --- a/dlls/engine/forwards.cpp +++ b/dlls/engine/forwards.cpp @@ -37,7 +37,7 @@ int fstrcmp(const char *s1, const char *s2) } int Spawn(edict_t *pEntity) { - if (SpawnForward) { + if (SpawnForward != -1) { int retVal = 0; int id = ENTINDEX(pEntity); retVal = MF_ExecuteForward(SpawnForward, id); @@ -49,7 +49,7 @@ int Spawn(edict_t *pEntity) { void ChangeLevel(char* s1, char* s2) { - if (ChangelevelForward) { + if (ChangelevelForward != -1) { int retVal = 0; char *map = s1; retVal = MF_ExecuteForward(ChangelevelForward, map); @@ -61,7 +61,7 @@ void ChangeLevel(char* s1, char* s2) void PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2) { - if (PlaybackForward) { + if (PlaybackForward != -1) { edict_t *e = (edict_t *)pInvoker; int retVal = 0; static cell cOrigin[3]; @@ -90,7 +90,7 @@ void KeyValue(edict_t *pEntity, KeyValueData *pkvd) g_inKeyValue=true; g_pkvd=pkvd; int index = ENTINDEX(pEntity); - if (DispatchKeyForward) { + if (DispatchKeyForward != -1) { retVal = MF_ExecuteForward(DispatchKeyForward, index); g_inKeyValue=false; if (retVal > 0) @@ -111,9 +111,9 @@ void StartFrame() } } - if (StartFrameForward) + if (StartFrameForward != -1) MF_ExecuteForward(StartFrameForward); - else if (VexdServerForward) + else if (VexdServerForward != -1) MF_ExecuteForward(VexdServerForward); RETURN_META(MRES_IGNORED); @@ -139,7 +139,7 @@ void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int RETURN_META(MRES_IGNORED); } } - if (CmdStartForward) { + if (CmdStartForward != -1) { incmd = true; retVal = MF_ExecuteForward(CmdStartForward, ENTINDEX(pEntity), g_cmd->impulse); incmd = false; @@ -156,7 +156,7 @@ void ClientKill(edict_t *pEntity) { int retVal = 0; - if (ClientKillForward) { + if (ClientKillForward != -1) { retVal = MF_ExecuteForward(ClientKillForward, ENTINDEX(pEntity)); if (retVal) RETURN_META(MRES_SUPERCEDE); @@ -209,7 +209,7 @@ void PlayerPostThink_Post(edict_t *pEntity) } } - if (PlayerPostThinkForward) + if (PlayerPostThinkForward != -1) { if (MF_ExecuteForward(PlayerPostThinkForward, ENTINDEX(pEntity))) RETURN_META(MRES_SUPERCEDE); @@ -260,11 +260,11 @@ void pfnTouch(edict_t *pToucher, edict_t *pTouched) } } /* Execute pfnTouch forwards */ - if (pfnTouchForward) { + if (pfnTouchForward != -1) { retVal = MF_ExecuteForward(pfnTouchForward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal) RETURN_META(MRES_SUPERCEDE); - } else if (VexdTouchForward) { + } else if (VexdTouchForward != -1) { retVal = MF_ExecuteForward(VexdTouchForward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal) RETURN_META(MRES_SUPERCEDE); diff --git a/dlls/engine/messages.cpp b/dlls/engine/messages.cpp index 26feaa3c..119f5d38 100755 --- a/dlls/engine/messages.cpp +++ b/dlls/engine/messages.cpp @@ -303,8 +303,13 @@ static cell AMX_NATIVE_CALL register_message(AMX *amx, cell *params) if (params[1]>0 && params[1] < 256) { int id = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[2], 0, &len), FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); // MF_Log("Registering message %d with result %d", params[1], id); - msgHooks[params[1]] = id; - return id; + if (id != -1) + { + msgHooks[params[1]] = id; + return id; + } else { + return -1; + } } return 0;