Fix long chat messages causing net command failures

This commit is contained in:
LJ Sonic 2022-01-03 22:37:19 +01:00
parent 159be00109
commit 1377824799

View file

@ -634,7 +634,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
SINT8 target;
UINT8 flags;
const char *dispname;
char *msg;
char msgbuf[HU_MAXMSGLEN + 1];
char *msg = msgbuf;
boolean action = false;
char *ptr;
INT32 spam_eatmsg = 0;
@ -643,8 +644,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
target = READSINT8(*p);
flags = READUINT8(*p);
msg = (char *)*p;
SKIPSTRINGN(*p, HU_MAXMSGLEN);
READSTRINGN(*p, msgbuf, HU_MAXMSGLEN);
if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
{
@ -913,7 +913,11 @@ static void HU_sendChatMessage(void)
if (c >= ' ' && !(c & 0x80))
buf[ci] = c;
};
buf[ci] = '\0';
if (ci-2 < HU_MAXMSGLEN)
{
buf[ci] = '\0';
ci++;
}
memset(w_chat, '\0', sizeof(w_chat));
c_input = 0;
@ -981,7 +985,7 @@ static void HU_sendChatMessage(void)
{
buf[0] = teamtalk ? -1 : target; // target
buf[1] = 0; // flags
SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1);
SendNetXCmd(XD_SAY, buf, ci);
}
}