Remove newlines from chat messages in Game VM

This has no affect due to ioquake3 engine already removing command
separators (which includes newlines) in Cmd_Args_Sanitize().
This commit is contained in:
Zack Middleton 2017-08-09 18:34:26 -05:00
parent f0b74a27c9
commit 3f267728c3

View file

@ -928,6 +928,16 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
} }
} }
static void SanitizeChatText( char *text ) {
int i;
for ( i = 0; text[i]; i++ ) {
if ( text[i] == '\n' || text[i] == '\r' ) {
text[i] = ' ';
}
}
}
/* /*
================== ==================
@ -950,6 +960,8 @@ static void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) {
p = ConcatArgs( 1 ); p = ConcatArgs( 1 );
} }
SanitizeChatText( p );
G_Say( ent, NULL, mode, p ); G_Say( ent, NULL, mode, p );
} }
@ -982,6 +994,8 @@ static void Cmd_Tell_f( gentity_t *ent ) {
p = ConcatArgs( 2 ); p = ConcatArgs( 2 );
SanitizeChatText( p );
G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, p ); G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, p );
G_Say( ent, target, SAY_TELL, p ); G_Say( ent, target, SAY_TELL, p );
// don't tell to the player self if it was already directed to this player // don't tell to the player self if it was already directed to this player
@ -1076,6 +1090,8 @@ static void Cmd_Voice_f( gentity_t *ent, int mode, qboolean arg0, qboolean voice
p = ConcatArgs( 1 ); p = ConcatArgs( 1 );
} }
SanitizeChatText( p );
G_Voice( ent, NULL, mode, p, voiceonly ); G_Voice( ent, NULL, mode, p, voiceonly );
} }
@ -1108,6 +1124,8 @@ static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
id = ConcatArgs( 2 ); id = ConcatArgs( 2 );
SanitizeChatText( id );
G_LogPrintf( "vtell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, id ); G_LogPrintf( "vtell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, id );
G_Voice( ent, target, SAY_TELL, id, voiceonly ); G_Voice( ent, target, SAY_TELL, id, voiceonly );
// don't tell to the player self if it was already directed to this player // don't tell to the player self if it was already directed to this player