Revert "WIP: XD_REQSAY"

This reverts commit 00e25ee593.
This commit is contained in:
AJ Martinez 2023-04-28 17:14:32 -07:00
parent 00e25ee593
commit 07eb7dea19
5 changed files with 59 additions and 88 deletions

View file

@ -3625,9 +3625,6 @@ void D_ClientServerInit(void)
RegisterNetXCmd(XD_ADDPLAYER, Got_AddPlayer);
RegisterNetXCmd(XD_REMOVEPLAYER, Got_RemovePlayer);
RegisterNetXCmd(XD_ADDBOT, Got_AddBot);
RegisterNetXCmd(XD_SAY, Got_Saycmd);
RegisterNetXCmd(XD_REQSAY, Got_RequestSaycmd);
#ifdef DUMPCONSISTENCY
CV_RegisterVar(&cv_dumpconsistency);
#endif

View file

@ -65,7 +65,6 @@
#include "k_race.h"
#include "g_party.h"
#include "k_vote.h"
#include "hu_stuff.h" // HU_ flags
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
#include "m_avrecorder.h"
@ -580,6 +579,7 @@ size_t schedule_len = 0;
// Automation commands
char *automate_commands[AEV__MAX];
const char *automate_names[AEV__MAX] =
{
"RoundStart", // AEV_ROUNDSTART
@ -589,8 +589,6 @@ const char *automate_names[AEV__MAX] =
UINT32 livestudioaudience_timer = 90;
static tic_t stop_spamming[MAXPLAYERS];
/// \warning Keep this up-to-date if you add/remove/rename net text commands
const char *netxcmdnames[MAXNETXCMD - 1] =
{
@ -634,7 +632,6 @@ const char *netxcmdnames[MAXNETXCMD - 1] =
"AUTOMATE", // XD_AUTOMATE
"REQMAPQUEUE", // XD_REQMAPQUEUE
"MAPQUEUE", // XD_MAPQUEUE
"REQSAY", // XD_REQSAY
};
// =========================================================================
@ -3491,74 +3488,6 @@ static void Got_MapQueuecmd(UINT8 **cp, INT32 playernum)
CONS_Printf("queuemap: A map was added to the round queue (pos. %u)\n", queueposition+1);
}
void Got_RequestSaycmd(UINT8 **p, INT32 playernum)
{
SINT8 target;
UINT8 flags;
const char *dispname;
char *msg;
boolean action = false;
char *ptr;
INT32 spam_eatmsg = 0;
UINT8 *original = *p;
// Only the server processes this message.
if (client)
return;
CONS_Debug(DBG_NETPLAY,"Received REQSAY cmd from Player %d (%s)\n", playernum+1, player_names[playernum]);
target = READSINT8(*p);
flags = READUINT8(*p);
msg = (char *)*p;
SKIPSTRINGL(*p, HU_MAXMSGLEN + 1);
if ((cv_mute.value || flags & (HU_CSAY|HU_SHOUT)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
{
CONS_Alert(CONS_WARNING, cv_mute.value ?
M_GetText("Illegal reqsay command received from %s while muted\n") : M_GetText("Illegal csay command received from non-admin %s\n"),
player_names[playernum]);
if (server)
SendKick(playernum, KICK_MSG_CON_FAIL);
return;
}
//check for invalid characters (0x80 or above)
{
size_t i;
const size_t j = strlen(msg);
for (i = 0; i < j; i++)
{
if (msg[i] & 0x80)
{
CONS_Alert(CONS_WARNING, M_GetText("Illegal reqsay command received from %s containing invalid characters\n"), player_names[playernum]);
if (server)
SendKick(playernum, KICK_MSG_CON_FAIL);
return;
}
}
}
// before we do anything, let's verify the guy isn't spamming, get this easier on us.
//if (stop_spamming[playernum] != 0 && cv_chatspamprotection.value && !(flags & HU_CSAY))
if (stop_spamming[playernum] != 0 && consoleplayer != playernum && cv_chatspamprotection.value && !(flags & (HU_CSAY|HU_SHOUT)))
{
CONS_Debug(DBG_NETPLAY,"Received REQSAY cmd too quickly from Player %d (%s), assuming as spam and blocking message.\n", playernum+1, player_names[playernum]);
stop_spamming[playernum] = 4;
spam_eatmsg = 1;
}
else
stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you?
if (spam_eatmsg)
return; // don't proceed if we were supposed to eat the message.
SendNetXCmd(XD_SAY, original, *p - original);
}
static void Command_Pause(void)
{
UINT8 buf[2];

View file

@ -181,7 +181,6 @@ typedef enum
XD_AUTOMATE, // 36
XD_REQMAPQUEUE, // 37
XD_MAPQUEUE, // 38
XD_REQSAY, // 39
MAXNETXCMD
} netxcmd_t;
@ -289,8 +288,6 @@ void D_Cheat(INT32 playernum, INT32 cheat, ...);
// used for the player setup menu
boolean CanChangeSkin(INT32 playernum);
void Got_RequestSaycmd(UINT8 **cp, INT32 playernum);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -65,6 +65,12 @@
#define HU_INPUTX 0
#define HU_INPUTY 0
typedef enum
{
HU_SHOUT = 1, // Shout message
HU_CSAY = 1<<1, // Middle-of-screen server message
} sayflags_t;
//-------------------------------------------
// heads up font
//-------------------------------------------
@ -174,6 +180,7 @@ static void Command_Sayto_f(void);
static void Command_Sayteam_f(void);
static void Command_CSay_f(void);
static void Command_Shout(void);
static void Got_Saycmd(UINT8 **p, INT32 playernum);
void HU_LoadGraphics(void)
{
@ -219,6 +226,7 @@ void HU_Init(void)
COM_AddCommand("sayteam", Command_Sayteam_f);
COM_AddCommand("csay", Command_CSay_f);
COM_AddCommand("shout", Command_Shout);
RegisterNetXCmd(XD_SAY, Got_Saycmd);
// only allocate if not present, to save us a lot of headache
if (missingpat == NULL)
@ -687,7 +695,7 @@ static tic_t stop_spamming[MAXPLAYERS];
* \sa DoSayCommand
* \author Graue <graue@oceanbase.org>
*/
void Got_Saycmd(UINT8 **p, INT32 playernum)
static void Got_Saycmd(UINT8 **p, INT32 playernum)
{
SINT8 target;
UINT8 flags;
@ -699,9 +707,57 @@ void Got_Saycmd(UINT8 **p, INT32 playernum)
CONS_Debug(DBG_NETPLAY,"Received SAY cmd from Player %d (%s)\n", playernum+1, player_names[playernum]);
target = READSINT8(*p);
flags = READUINT8(*p);
msg = (char *)*p;
SKIPSTRINGL(*p, HU_MAXMSGLEN + 1);
if ((cv_mute.value || flags & (HU_CSAY|HU_SHOUT)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
{
CONS_Alert(CONS_WARNING, cv_mute.value ?
M_GetText("Illegal say command received from %s while muted\n") : M_GetText("Illegal csay command received from non-admin %s\n"),
player_names[playernum]);
if (server)
SendKick(playernum, KICK_MSG_CON_FAIL);
return;
}
//check for invalid characters (0x80 or above)
{
size_t i;
const size_t j = strlen(msg);
for (i = 0; i < j; i++)
{
if (msg[i] & 0x80)
{
CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[playernum]);
if (server)
SendKick(playernum, KICK_MSG_CON_FAIL);
return;
}
}
}
// before we do anything, let's verify the guy isn't spamming, get this easier on us.
//if (stop_spamming[playernum] != 0 && cv_chatspamprotection.value && !(flags & HU_CSAY))
if (stop_spamming[playernum] != 0 && consoleplayer != playernum && cv_chatspamprotection.value && !(flags & (HU_CSAY|HU_SHOUT)))
{
CONS_Debug(DBG_NETPLAY,"Received SAY cmd too quickly from Player %d (%s), assuming as spam and blocking message.\n", playernum+1, player_names[playernum]);
stop_spamming[playernum] = 4;
spam_eatmsg = 1;
}
else
stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you?
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg))
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)
{
@ -1105,7 +1161,7 @@ static void HU_sendChatMessage(void)
buf[0] = target;
buf[1] = ((server || IsPlayerAdmin(consoleplayer)) && cv_autoshout.value) ? HU_SHOUT : 0; // flags
SendNetXCmd(XD_REQSAY, buf, 2 + strlen(&buf[2]) + 1);
SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1);
}
}

View file

@ -162,14 +162,6 @@ void HU_ClearTitlecardCEcho(void);
extern UINT32 hu_demotime;
extern UINT32 hu_demolap;
void Got_Saycmd(UINT8 **p, INT32 playernum);
typedef enum
{
HU_SHOUT = 1, // Shout message
HU_CSAY = 1<<1, // Middle-of-screen server message
} sayflags_t;
#ifdef __cplusplus
} // extern "C"
#endif