This commit is contained in:
Louis-Antoine 2020-01-15 15:57:38 +01:00
parent 6d703add73
commit fc01862eeb

View file

@ -1073,11 +1073,11 @@ static void HU_queueChatChar(char c)
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
{ {
INT32 spc = 1; // used if nodenum[1] is a space. INT32 spc = 1; // used if playernum[1] is a space.
char nodenum[3]; char playernum[3];
const char *newmsg; const char *newmsg;
// what we're gonna do now is check if the node exists // what we're gonna do now is check if the player exists
// with that logic, characters 4 and 5 are our numbers: // with that logic, characters 4 and 5 are our numbers:
// teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko. // teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko.
@ -1087,17 +1087,17 @@ static void HU_queueChatChar(char c)
return; return;
} }
strncpy(nodenum, msg+3, 3); strncpy(playernum, msg+3, 3);
// check for undesirable characters in our "number" // check for undesirable characters in our "number"
if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) if (((playernum[0] < '0') || (playernum[0] > '9')) || ((playernum[1] < '0') || (playernum[1] > '9')))
{ {
// check if nodenum[1] is a space // check if playernum[1] is a space
if (nodenum[1] == ' ') if (playernum[1] == ' ')
spc = 0; spc = 0;
// let it slide // let it slide
else else
{ {
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false); HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<player num> \'.", false);
return; return;
} }
} }
@ -1106,12 +1106,12 @@ static void HU_queueChatChar(char c)
{ {
if (msg[5] != ' ') if (msg[5] != ' ')
{ {
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false); HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<player num> \'.", false);
return; return;
} }
} }
target = atoi(nodenum); // turn that into a number target = atoi(playernum); // turn that into a number
//CONS_Printf("%d\n", target); //CONS_Printf("%d\n", target);
// check for target player, if it doesn't exist then we can't send the message! // check for target player, if it doesn't exist then we can't send the message!
@ -1123,7 +1123,7 @@ static void HU_queueChatChar(char c)
return; return;
} }
// we need to get rid of the /pm<node> // we need to get rid of the /pm<player num>
newmsg = msg+5+spc; newmsg = msg+5+spc;
strlcpy(msg, newmsg, 255); strlcpy(msg, newmsg, 255);
} }
@ -1782,14 +1782,14 @@ static void HU_DrawChat(void)
// filter: (code needs optimization pls help I'm bad with C) // filter: (code needs optimization pls help I'm bad with C)
if (w_chat[3]) if (w_chat[3])
{ {
char nodenum[3]; char playernum[3];
UINT32 n; UINT32 n;
// right, that's half important: (w_chat[4] may be a space since /pm0 msg is perfectly acceptable!) // right, that's half important: (w_chat[4] may be a space since /pm0 msg is perfectly acceptable!)
if ( ( ((w_chat[3] != 0) && ((w_chat[3] < '0') || (w_chat[3] > '9'))) || ((w_chat[4] != 0) && (((w_chat[4] < '0') || (w_chat[4] > '9'))))) && (w_chat[4] != ' ')) if ( ( ((w_chat[3] != 0) && ((w_chat[3] < '0') || (w_chat[3] > '9'))) || ((w_chat[4] != 0) && (((w_chat[4] < '0') || (w_chat[4] > '9'))))) && (w_chat[4] != ' '))
break; break;
strncpy(nodenum, w_chat+3, 3); strncpy(playernum, w_chat+3, 3);
n = atoi(nodenum); // turn that into a number n = atoi(playernum); // turn that into a number
// special cases: // special cases:
if ((n == 0) && !(w_chat[4] == '0')) if ((n == 0) && !(w_chat[4] == '0'))