Synchronize rate limit variables and limit PlayerMsg hook

This commit is contained in:
Hanicef 2024-09-06 12:21:34 +02:00
parent 8a6beee52a
commit 53db028bdb
3 changed files with 20 additions and 6 deletions

View file

@ -587,8 +587,8 @@ static void Command_CSay_f(void)
DoSayCommand(0, 1, HU_CSAY);
}
static tic_t spam_tokens[MAXPLAYERS] = { 1 }; // fill the buffer with 1 so the motd can be sent.
static tic_t spam_tics[MAXPLAYERS];
UINT8 spam_tokens[MAXPLAYERS] = { 1 }; // fill the buffer with 1 so the motd can be sent.
tic_t spam_tics[MAXPLAYERS];
/** Receives a message, processing an ::XD_SAY command.
* \sa DoSayCommand
@ -649,14 +649,12 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
else
spam_tokens[playernum] -= 1;
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
if (spam_eatmsg)
return; // don't proceed if we were supposed to eat the message.
if (LUA_HookPlayerMsg(playernum, target, flags, msg))
return;
if (spam_eatmsg)
return; // don't proceed if we were supposed to eat the message.
// If it's a CSAY, just CECHO and be done with it.
if (flags & HU_CSAY)
{

View file

@ -79,6 +79,9 @@ void HU_AddChatText(const char *text, boolean playsound);
// set true when entering a chat message
extern boolean chat_on;
extern UINT8 spam_tokens[MAXPLAYERS];
extern tic_t spam_tics[MAXPLAYERS];
extern patch_t *emeraldpics[3][8];
extern patch_t *rflagico;
extern patch_t *bflagico;

View file

@ -35,6 +35,7 @@
#include "p_polyobj.h"
#include "lua_script.h"
#include "p_slopes.h"
#include "hu_stuff.h"
savedata_t savedata;
UINT8 *save_p;
@ -4611,6 +4612,12 @@ static void P_NetArchiveMisc(boolean resending)
WRITEUINT8(save_p, 0x2f);
else
WRITEUINT8(save_p, 0x2e);
for (i = 0; i < MAXPLAYERS; i++)
{
WRITEUINT8(save_p, spam_tokens[i]);
WRITEUINT32(save_p, spam_tics[i]);
}
}
static inline boolean P_NetUnArchiveMisc(boolean reloading)
@ -4708,6 +4715,12 @@ static inline boolean P_NetUnArchiveMisc(boolean reloading)
if (READUINT8(save_p) == 0x2f)
paused = true;
for (i = 0; i < MAXPLAYERS; i++)
{
spam_tokens[i] = READUINT8(save_p);
spam_tics[i] = READUINT32(save_p);
}
return true;
}