From b93d8d1efb9e3628898129c2f967ea00e51dfb97 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 17 Sep 2026 11:40:41 +0200 Subject: [PATCH] =?UTF-8?q?smol=20fix=20for=20pm=C2=B4s=20in=20DoSayComman?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sending a pm might change the length of the string which we need to reconsider when sending the cmd --- src/hu_stuff.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8f131b3d2..62665f332 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -472,9 +472,7 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) strlcat(msg, COM_Argv(ix + usedargs), msgspace); } - const size_t msglength = strlen(msg); - - if (msglength > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { // what we're gonna do now is check if the node exists // with that logic, characters 4 and 5 are our numbers: @@ -528,7 +526,7 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) strlcpy(msg, newmsg, HU_MAXMSGLEN + 1); } - SendNetXCmd(XD_SAY, buf, msglength + 1 + msg-buf); + SendNetXCmd(XD_SAY, buf, strlen(msg) + 1 + msg-buf); } /** Send a message to everyone. @@ -779,12 +777,11 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum) return; } - const size_t msglength = strlen(msg); - //check for invalid characters (0x80 or above) { size_t i; - const size_t j = msglength; + const size_t j = strlen(msg); + for (i = 0; i < j; i++) { if (msg[i] & 0x80) @@ -831,7 +828,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum) } // Handle "/me" actions, but only in messages to everyone. - if (target == 0 && msglength > 4 && strnicmp(msg, "/me ", 4) == 0) + if (target == 0 && strlen(msg) > 4 && strnicmp(msg, "/me ", 4) == 0) { msg += 4; action = true;