diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2009-10-03 12:34:36 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:05 +0000 |
commit | 0e2ab7aa3b0ff0d598967ae38a016e312a0aa58b (patch) | |
tree | 7297137505a7eb2120e29a2d73de0ce579504ad2 /src | |
parent | 35e262d005e1dee8b17229bb00ee4c5d70b6d03d (diff) |
* Silence compiler warnings from r1160
* Fix improper behavior of console chat command
* Fix console say/chat/say_team commands not being logged
* Add teamPrefix to log/console print of say_team messages
* Minor cleanups to chat logging code
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_cmds.c | 20 | ||||
-rw-r--r-- | src/game/g_local.h | 1 | ||||
-rw-r--r-- | src/game/g_svcmds.c | 44 |
3 files changed, 38 insertions, 27 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index eb001457..deb45159 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -695,7 +695,7 @@ static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, cons // specs with ADMF_SPEC_ALLCHAT flag can see team chat } - if( BG_ClientListTest( &other->client->sess.ignoreList, ent-g_entities ) ) + if( ent && BG_ClientListTest( &other->client->sess.ignoreList, ent-g_entities ) ) ignore = qtrue; trap_SendServerCommand( other-g_entities, va( "%s \"%s%s%c%c%s%s\"", @@ -715,7 +715,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) char text[ MAX_SAY_TEXT ]; char location[ 64 ]; - if( g_chatTeamPrefix.integer ) + if( ent && g_chatTeamPrefix.integer ) { prefix = BG_TeamName( ent->client->pers.teamSelection ); prefix = va( "[%c] ", toupper( *prefix ) ); @@ -727,14 +727,20 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { default: case SAY_ALL: - G_LogPrintf( "say: %s^7: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "say: %s%s^7: " S_COLOR_GREEN "%s\n", prefix, + ( ent ) ? ent->client->pers.netname : "console", chatText ); Com_sprintf( name, sizeof( name ), "%s%s" S_COLOR_WHITE ": ", prefix, - ent->client->pers.netname ); + ( ent ) ? ent->client->pers.netname : "console" ); color = COLOR_GREEN; break; case SAY_TEAM: - G_LogPrintf( "sayteam: %s^7: %s\n", ent->client->pers.netname, chatText ); + // console say_team is handled in g_svscmds, not here + if( !ent || !ent->client ) + Com_Error( ERR_FATAL, "SAY_TEAM by non-client entity\n" ); + + G_LogPrintf( "sayteam: %s%s^7: " S_COLOR_CYAN "%s\n", prefix, + ent->client->pers.netname, chatText ); if( Team_GetLocationMsg( ent, location, sizeof( location ) ) ) Com_sprintf( name, sizeof( name ), "(%s" S_COLOR_WHITE ") (%s): ", ent->client->pers.netname, location ); @@ -748,10 +754,10 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) if( target && OnSameTeam( target, ent ) && Team_GetLocationMsg( ent, location, sizeof( location ) ) ) Com_sprintf( name, sizeof( name ), "[%s" S_COLOR_WHITE "] (%s): ", - ent->client->pers.netname, location ); + ( ent ) ? ent->client->pers.netname : "console", location ); else Com_sprintf( name, sizeof( name ), "[%s" S_COLOR_WHITE "]: ", - ent->client->pers.netname ); + ( ent ) ? ent->client->pers.netname : "console" ); color = COLOR_MAGENTA; break; } diff --git a/src/game/g_local.h b/src/game/g_local.h index 389530a2..8aea02dc 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -680,6 +680,7 @@ void G_ToggleFollow( gentity_t *ent ); void G_MatchOnePlayer( int *plist, int num, char *err, int len ); int G_ClientNumberFromString( char *s ); int G_ClientNumbersFromString( char *s, int *plist, int max ); +void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ); int G_SayArgc( void ); qboolean G_SayArgv( int n, char *buffer, int bufferLength ); char *G_SayConcatArgs( int start ); diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 7f63ddd2..d74fb147 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -313,9 +313,13 @@ static void Svcmd_TeamWin_f( void ) case TEAM_ALIENS: G_BaseSelfDestruct( TEAM_HUMANS ); break; + case TEAM_HUMANS: G_BaseSelfDestruct( TEAM_ALIENS ); break; + + default: + return; } } @@ -345,6 +349,7 @@ static void Svcmd_MapRotation_f( void ) static void Svcmd_TeamMessage_f( void ) { char teamNum[ 2 ]; + const char* prefix; team_t team; if( trap_Argc( ) < 3 ) @@ -362,21 +367,11 @@ static void Svcmd_TeamMessage_f( void ) return; } - G_TeamCommand( team, va( "tchat \"console: ^5%s\"", ConcatArgs( 2 ) ) ); -} + prefix = BG_TeamName( team ); + prefix = va( "[%c] ", toupper( *prefix ) ); -static void Svcmd_SendMessage( void ) -{ - char cmd[ 5 ]; - trap_Argv( 1, cmd, sizeof( cmd ) ); - - if( trap_Argc( ) < 2 ) - { - G_Printf( "usage: %s <message>\n", cmd ); - return; - } - - trap_SendServerCommand( -1, va( "chat \"console: ^2%s\"", ConcatArgs( 1 ) ) ); + G_TeamCommand( team, va( "tchat \"(console): " S_COLOR_CYAN "%s\"", ConcatArgs( 2 ) ) ); + G_LogPrintf( "sayteam: %sconsole: " S_COLOR_CYAN "%s\n", prefix, ConcatArgs( 2 ) ); } static void Svcmd_CenterPrint_f( void ) @@ -488,15 +483,24 @@ static void Svcmd_PrintQueue_f( void ) } } -// dumb wrapper for "a" and "m" +static void Svcmd_Chat_f( void ) +{ + trap_SendServerCommand( -1, va( "chat \"%s\"", ConcatArgs( 1 ) ) ); + G_LogPrintf("chat: %s\n", ConcatArgs( 1 ) ); +} + +// dumb wrapper for "a" and "m" and "say" static void Svcmd_MessageWrapper( void ) { - char cmd[ 2 ]; + char cmd[ 5 ]; trap_Argv( 0, cmd, sizeof( cmd ) ); + if( !Q_stricmp( cmd, "a" ) ) Cmd_AdminMessage_f( NULL ); - else + else if( !Q_stricmp( cmd, "m" ) ) Cmd_PrivateMessage_f( NULL ); + else if( !Q_stricmp( cmd, "say" ) ) + G_Say( NULL, NULL, SAY_ALL, ConcatArgs( 1 ) ); } struct @@ -521,10 +525,10 @@ struct { "evacuation", qfalse, Svcmd_Evacuation_f }, { "printqueue", qfalse, Svcmd_PrintQueue_f }, // don't handle communication commands unless dedicated - { "say_team", qtrue, Svcmd_TeamMessage_f }, - { "say", qtrue, Svcmd_SendMessage }, - { "chat", qtrue, Svcmd_SendMessage }, { "cp", qtrue, Svcmd_CenterPrint_f }, + { "say_team", qtrue, Svcmd_TeamMessage_f }, + { "say", qtrue, Svcmd_MessageWrapper }, + { "chat", qtrue, Svcmd_Chat_f }, { "m", qtrue, Svcmd_MessageWrapper }, { "a", qtrue, Svcmd_MessageWrapper } }; |