This commit is contained in:
Louis-Antoine 2020-01-15 15:57:38 +01:00
parent ec5db89e55
commit 0197a83db7

View file

@ -1073,11 +1073,11 @@ static void HU_queueChatChar(char c)
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
{
INT32 spc = 1; // used if nodenum[1] is a space.
char nodenum[3];
INT32 spc = 1; // used if playernum[1] is a space.
char playernum[3];
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:
// 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;
}
strncpy(nodenum, msg+3, 3);
strncpy(playernum, msg+3, 3);
// 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
if (nodenum[1] == ' ')
// check if playernum[1] is a space
if (playernum[1] == ' ')
spc = 0;
// let it slide
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;
}
}
@ -1106,12 +1106,12 @@ static void HU_queueChatChar(char c)
{
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;
}
}
target = atoi(nodenum); // turn that into a number
target = atoi(playernum); // turn that into a number
//CONS_Printf("%d\n", target);
// 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;
}
// we need to get rid of the /pm<node>
// we need to get rid of the /pm<player num>
newmsg = msg+5+spc;
strlcpy(msg, newmsg, 255);
}
@ -1782,14 +1782,14 @@ static void HU_DrawChat(void)
// filter: (code needs optimization pls help I'm bad with C)
if (w_chat[3])
{
char nodenum[3];
char playernum[3];
UINT32 n;
// 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] != ' '))
break;
strncpy(nodenum, w_chat+3, 3);
n = atoi(nodenum); // turn that into a number
strncpy(playernum, w_chat+3, 3);
n = atoi(playernum); // turn that into a number
// special cases:
if ((n == 0) && !(w_chat[4] == '0'))