Messages can now be registered by multiple plugins (thanks fsfod)

This commit is contained in:
David Anderson 2004-08-30 22:24:43 +00:00
parent 6da1dc3e4a
commit 2134a7e36d
7 changed files with 24 additions and 14 deletions

View File

@ -136,3 +136,4 @@ private:
};
#endif //_INCLUDE_CSTRING_H

View File

@ -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`;

View File

@ -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;
}

View File

@ -201,3 +201,4 @@ extern CVector<EntClass *> Thinks;
extern CVector<Touch *> Touches;
#endif //_ENGINE_INCLUDE_H

View File

@ -1806,3 +1806,4 @@ AMX_NATIVE_INFO ent_Natives[] = {
{NULL, NULL},
///////////////////
};

View File

@ -1,7 +1,8 @@
#include "engine.h"
CVector<argMsg*> Msg;
int msgHooks[256] = {0};
CVector<int> 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<msgHooks[msgType].size(); i++)
{
mresB = MF_ExecuteForward(msgHooks[msgType].at(i), msgType, msgDest, ENTINDEX(msgpEntity));
if (mresB > 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;

View File

@ -42,7 +42,7 @@ public:
extern AMX_NATIVE_INFO msg_Natives[];
extern CVector<argMsg*> Msg;
extern int msgHooks[256];
extern CVector<int> msgHooks[256];
extern int msgBlocks[256];
#endif //_MSGS_INCLUDE_H