mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Don't send or display chat messages which are whitespace only (#180)
This commit is contained in:
parent
c0b3e6f99f
commit
247655a3d7
3 changed files with 36 additions and 13 deletions
|
@ -518,7 +518,7 @@ void CGameMessageMgr::SortMessagesByTime(messageStruct** messages, int count) {
|
|||
|
||||
void CPlayerMsg::Clear(void)
|
||||
{
|
||||
at4[0] = 0;
|
||||
text[0] = 0;
|
||||
at0 = 0;
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,7 @@ void CPlayerMsg::Term(void)
|
|||
void CPlayerMsg::Draw(void)
|
||||
{
|
||||
char buffer[44];
|
||||
strcpy(buffer, at4);
|
||||
strcpy(buffer, text);
|
||||
if ((int)totalclock & 16)
|
||||
strcat(buffer, "_");
|
||||
int x = gViewMode == 3 ? gViewX0S : 0;
|
||||
|
@ -546,8 +546,8 @@ bool CPlayerMsg::AddChar(char ch)
|
|||
{
|
||||
if (at0 < 40)
|
||||
{
|
||||
at4[at0++] = ch;
|
||||
at4[at0] = 0;
|
||||
text[at0++] = ch;
|
||||
text[at0] = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -556,20 +556,32 @@ bool CPlayerMsg::AddChar(char ch)
|
|||
void CPlayerMsg::DelChar(void)
|
||||
{
|
||||
if (at0 > 0)
|
||||
at4[--at0] = 0;
|
||||
text[--at0] = 0;
|
||||
}
|
||||
|
||||
void CPlayerMsg::Set(const char * pzString)
|
||||
{
|
||||
strncpy(at4, pzString, 40);
|
||||
strncpy(text, pzString, 40);
|
||||
at0 = ClipHigh(strlen(pzString), 40);
|
||||
at4[at0] = 0;
|
||||
text[at0] = 0;
|
||||
}
|
||||
|
||||
void CPlayerMsg::Send(void)
|
||||
{
|
||||
netBroadcastMessage(myconnectindex, at4);
|
||||
viewSetMessage(at4);
|
||||
if (VanillaMode() || !IsWhitespaceOnly(text))
|
||||
{
|
||||
netBroadcastMessage(myconnectindex, text);
|
||||
if (!VanillaMode())
|
||||
{
|
||||
char *myName = gProfile[myconnectindex].name;
|
||||
char szTemp[128];
|
||||
sprintf(szTemp, "%s: %s", myName, text);
|
||||
viewSetMessage(szTemp, 10); // 10: dark blue
|
||||
}
|
||||
else
|
||||
viewSetMessage(text);
|
||||
}
|
||||
|
||||
Term();
|
||||
keyFlushScans();
|
||||
}
|
||||
|
@ -611,7 +623,7 @@ void CPlayerMsg::ProcessKeys(void)
|
|||
break;
|
||||
case sc_Enter:
|
||||
case sc_kpad_Enter:
|
||||
if (gCheatMgr.Check(at4))
|
||||
if (gCheatMgr.Check(text))
|
||||
Term();
|
||||
else
|
||||
Send();
|
||||
|
@ -629,6 +641,15 @@ void CPlayerMsg::ProcessKeys(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool CPlayerMsg::IsWhitespaceOnly(const char * const pzString)
|
||||
{
|
||||
const char *p = pzString;
|
||||
while (*p != 0)
|
||||
if (*p++ > 32)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCheatMgr::CHEATINFO CCheatMgr::s_CheatInfo[] = {
|
||||
{"NQLGB", kCheatMpkfa, 0 }, // MPKFA (Invincibility)
|
||||
{"DBQJONZBTT", kCheatCapInMyAss, 0 }, // CAPINMYASS (Disable invincibility )
|
||||
|
|
|
@ -81,8 +81,8 @@ class CPlayerMsg
|
|||
{
|
||||
public:
|
||||
int at0;
|
||||
char at4[41];
|
||||
CPlayerMsg() { at0 = 0; at4[0] = 0; }
|
||||
char text[41];
|
||||
CPlayerMsg() { at0 = 0; text[0] = 0; }
|
||||
void Clear(void);
|
||||
void Term(void);
|
||||
void Draw(void);
|
||||
|
@ -91,6 +91,8 @@ public:
|
|||
void Set(const char *pzString);
|
||||
void Send(void);
|
||||
void ProcessKeys(void);
|
||||
private:
|
||||
bool IsWhitespaceOnly(const char* const pzString);
|
||||
};
|
||||
|
||||
class CCheatMgr
|
||||
|
|
|
@ -501,7 +501,7 @@ void netGetPackets(void)
|
|||
pPacket += 4;
|
||||
if (*pPacket != '/' || (*pPacket == 0 && *(pPacket+1) == 0) || (*(pPacket+1) >= '1' && *(pPacket+1) <= '8' && *(pPacket+1)-'1' == myconnectindex))
|
||||
{
|
||||
sprintf(buffer, "%s: %s", gProfile[nPlayer].name, pPacket);
|
||||
sprintf(buffer, VanillaMode() ? "%s : %s" : "%s: %s", gProfile[nPlayer].name, pPacket);
|
||||
viewSetMessage(buffer, VanillaMode() ? 0 : 10); // 10: dark blue
|
||||
sndStartSample("DMRADIO", 128, -1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue