From 2134a7e36da58fa3ee4ecc37edfa92bb4df4e98a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 30 Aug 2004 22:24:43 +0000 Subject: [PATCH] Messages can now be registered by multiple plugins (thanks fsfod) --- dlls/engine/CString.h | 3 ++- dlls/engine/Makefile.pl | 7 ++++--- dlls/engine/amxxapi.cpp | 4 ++-- dlls/engine/engine.h | 3 ++- dlls/engine/entity.cpp | 3 ++- dlls/engine/messages.cpp | 16 +++++++++++----- dlls/engine/messages.h | 2 +- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/dlls/engine/CString.h b/dlls/engine/CString.h index b6e95f1e..12b5cbc4 100755 --- a/dlls/engine/CString.h +++ b/dlls/engine/CString.h @@ -135,4 +135,5 @@ private: int mSize; }; -#endif //_INCLUDE_CSTRING_H \ No newline at end of file +#endif //_INCLUDE_CSTRING_H + diff --git a/dlls/engine/Makefile.pl b/dlls/engine/Makefile.pl index 251ce61a..241f8532 100755 --- a/dlls/engine/Makefile.pl +++ b/dlls/engine/Makefile.pl @@ -15,6 +15,7 @@ $PROJECT = "engine_amxx"; $sdk = "../hlsdk/SourceCode"; $mm = "../metamod/metamod"; +$gccf = "gcc"; @CPP_SOURCE_FILES = ("amxxmodule.cpp", "forwards.cpp", "messages.cpp", "entity.cpp", "globals.cpp", "amxxapi.cpp", "engine.cpp"); @@ -45,7 +46,7 @@ while ($cmd = shift) } } -$gcc = `gcc --version`; +$gcc = `$gccf --version`; if ($gcc =~ /2\.9/) { $OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2"; @@ -134,7 +135,7 @@ for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++) $ofile = $file; $ofile =~ s/\.cpp/\.o/; $ofile = "$outdir/$ofile"; - $gcc = "gcc $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile"; + $gcc = "$gccf $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile"; if (-e $ofile) { $file_time = (stat($file))[9]; @@ -172,6 +173,6 @@ for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++) } } -$gcc = "gcc $cflags -shared -ldl -lm @LINK -o $outdir/$bin"; +$gcc = "$gccf $cflags -shared -ldl -lm @LINK -o $outdir/$bin"; print "$gcc\n"; `$gcc`; diff --git a/dlls/engine/amxxapi.cpp b/dlls/engine/amxxapi.cpp index b80a0c57..7de6b8f2 100755 --- a/dlls/engine/amxxapi.cpp +++ b/dlls/engine/amxxapi.cpp @@ -196,7 +196,7 @@ void ServerDeactivate() Msg.clear(); register int i = 0; for (i=0; i<256; i++) { - msgHooks[i] = 0; + msgHooks[i].clear(); msgBlocks[i] = 0; } @@ -227,7 +227,7 @@ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) Msg.clear(); register int i = 0; for (i=0; i<256; i++) { - msgHooks[i] = 0; + msgHooks[i].clear(); msgBlocks[i] = 0; } diff --git a/dlls/engine/engine.h b/dlls/engine/engine.h index 00783a3e..98e1ca89 100755 --- a/dlls/engine/engine.h +++ b/dlls/engine/engine.h @@ -200,4 +200,5 @@ extern CVector Impulses; extern CVector Thinks; extern CVector Touches; -#endif //_ENGINE_INCLUDE_H \ No newline at end of file +#endif //_ENGINE_INCLUDE_H + diff --git a/dlls/engine/entity.cpp b/dlls/engine/entity.cpp index fc272705..a2bf589e 100755 --- a/dlls/engine/entity.cpp +++ b/dlls/engine/entity.cpp @@ -1805,4 +1805,5 @@ AMX_NATIVE_INFO ent_Natives[] = { {NULL, NULL}, /////////////////// -}; \ No newline at end of file +}; + diff --git a/dlls/engine/messages.cpp b/dlls/engine/messages.cpp index 256f7cc2..a0b9f196 100755 --- a/dlls/engine/messages.cpp +++ b/dlls/engine/messages.cpp @@ -1,7 +1,8 @@ #include "engine.h" CVector Msg; -int msgHooks[256] = {0}; +CVector msgHooks[256]; +//int msgHooks[256] = {0}; int msgBlocks[256] = {0}; int msgDest; int msgType; @@ -94,7 +95,7 @@ void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) if (msgBlocks[msg_type]) { inblock = true; RETURN_META(MRES_SUPERCEDE); - } else if (msgHooks[msg_type]) { + } else if (msgHooks[msg_type].size()) { inhook = true; msgCount = 0; msgDest = msg_dest; @@ -269,7 +270,7 @@ void WriteEntity(int iValue) void MessageEnd(void) { - int mres = 0; + int mres = 0, mresB = 0; unsigned int i = 0; if (inblock) { inblock = false; @@ -277,7 +278,12 @@ void MessageEnd(void) msgBlocks[msgType] = BLOCK_NOT; RETURN_META(MRES_SUPERCEDE); } else if (inhook) { - mres = MF_ExecuteForward(msgHooks[msgType], msgType, msgDest, ENTINDEX(msgpEntity)); + for (i=0; i mres) + mres = mresB; + } inhook = false; if (mres & 1) { @@ -305,7 +311,7 @@ static cell AMX_NATIVE_CALL register_message(AMX *amx, cell *params) // MF_Log("Registering message %d with result %d", params[1], id); if (id != -1) { - msgHooks[params[1]] = id; + msgHooks[params[1]].push_back(id); return id; } else { return -1; diff --git a/dlls/engine/messages.h b/dlls/engine/messages.h index 26dc610f..ee5d6937 100755 --- a/dlls/engine/messages.h +++ b/dlls/engine/messages.h @@ -42,7 +42,7 @@ public: extern AMX_NATIVE_INFO msg_Natives[]; extern CVector Msg; -extern int msgHooks[256]; +extern CVector msgHooks[256]; extern int msgBlocks[256]; #endif //_MSGS_INCLUDE_H