diff options
author | M. Kristall <mkpdev@gmail.com> | 2009-10-09 03:52:15 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:43 +0000 |
commit | 71d9cec2436a62af59b20f53d7d94ad8890b3746 (patch) | |
tree | 0a63295f2c4c231f1d0e8bfe98d4311b78c1b64a /src | |
parent | 051c2dbb494611aa953609d366cc8c6c16916c87 (diff) |
* (bug 3194) potential log ambiguities (requires log parser updates)
* Fix broken r1753
* Some minor refactoring / cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_cmds.c | 57 | ||||
-rw-r--r-- | src/game/g_local.h | 4 | ||||
-rw-r--r-- | src/game/g_main.c | 21 | ||||
-rw-r--r-- | src/game/g_svcmds.c | 15 | ||||
-rw-r--r-- | src/game/g_utils.c | 2 |
5 files changed, 38 insertions, 61 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 9d77e0c9..6d9fc217 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -700,7 +700,7 @@ static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, cons name, Q_COLOR_ESCAPE, color, message, S_COLOR_WHITE ) ); } -void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) +void G_Say( gentity_t *ent, int mode, const char *chatText ) { int j; gentity_t *other; @@ -733,7 +733,8 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { default: case SAY_ALL: - G_LogPrintf( "say: %s%s^7: " S_COLOR_GREEN "%s\n", prefix, + G_LogPrintf( "Say: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_GREEN "%s\n", + ( ent ) ? ent - g_entities : -1, ( ent ) ? ent->client->pers.netname : "console", chatText ); Com_sprintf( name, sizeof( name ), "%s%s" S_COLOR_WHITE ": ", prefix, ( ent ) ? ent->client->pers.netname : "console" ); @@ -745,8 +746,8 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) 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 ); + G_LogPrintf( "SayTeam: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_CYAN "%s\n", + ent - g_entities, 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 ); @@ -759,12 +760,6 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) Q_strncpyz( text, chatText, sizeof( text ) ); - if( target ) - { - G_SayTo( ent, target, mode, color, name, text ); - return; - } - // send it to all the apropriate clients for( j = 0; j < level.maxclients; j++ ) { @@ -795,7 +790,8 @@ static void Cmd_SayArea_f( gentity_t *ent ) prefix = BG_TeamName( ent->client->pers.teamSelection ); prefix = va( "[%c] ", toupper( *prefix ) ); - G_LogPrintf( "sayarea: %s%s^7: %s\n", prefix, ent->client->pers.netname, msg ); + G_LogPrintf( "SayArea: %d \"%s" S_COLOR_WHITE "\": " S_COLOR_BLUE "%s\n", + ent - g_entities, ent->client->pers.netname, msg ); Com_sprintf( name, sizeof( name ), "%s<%s%c%c> ", prefix, ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); @@ -809,7 +805,7 @@ static void Cmd_SayArea_f( gentity_t *ent ) //Send to ADMF_SPEC_ALLCHAT candidates for( i = 0; i < level.maxclients; i++ ) { - if( (&g_entities[ i ])->client->pers.teamSelection == TEAM_NONE && + if( g_entities[ i ].client->pers.teamSelection == TEAM_NONE && G_admin_permission( &g_entities[ i ], ADMF_SPEC_ALLCHAT ) ) { G_SayTo( ent, &g_entities[ i ], SAY_TEAM, color, name, msg ); @@ -857,7 +853,7 @@ static void Cmd_Say_f( gentity_t *ent ) p = ConcatArgs( 1 ); - G_Say( ent, NULL, mode, p ); + G_Say( ent, mode, p ); } /* @@ -1251,8 +1247,8 @@ void Cmd_CallVote_f( gentity_t *ent ) " called a vote: %s^7\n\"", ent->client->pers.netname, level.voteDisplayString ) ); - G_LogPrintf("Vote: %s^7 called a vote: %s^7\n", - ent->client->pers.netname, level.voteDisplayString ); + G_LogPrintf( "CallVote: %d \"%s" S_COLOR_WHITE "\": %s\n", + ent - g_entities, ent->client->pers.netname, level.voteString ); ent->client->pers.voteCount++; @@ -1497,9 +1493,9 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) G_TeamCommand( team, va( "print \"%s " S_COLOR_WHITE "called a team vote: %s\n\"", ent->client->pers.netname, level.teamVoteDisplayString[ cs_offset ] ) ); - G_LogPrintf( "Teamvote: %s^7 called a teamvote (%s): %s\n", - ent->client->pers.netname, BG_TeamName(team), - level.teamVoteDisplayString[ cs_offset ] ); + G_LogPrintf( "CallTeamVote: %d \"%s" S_COLOR_WHITE "\": %s\n", + ent - g_entities, ent->client->pers.netname, + level.teamVoteDisplayString[ cs_offset ] ); // start the voting, the caller autoamtically votes yes level.teamVoteTime[ cs_offset ] = level.time; @@ -3438,8 +3434,9 @@ void Cmd_PrivateMessage_f( gentity_t *ent ) ADMP( va( "^%cPrivate message: ^7%s\n", color, msg ) ); ADMP( va( "%s\n", str ) ); - G_LogPrintf( "%s: %s^7: %s^7: %s\n", - ( teamonly ) ? "tprivmsg" : "privmsg", + G_LogPrintf( "%s: %d \"%s" S_COLOR_WHITE "\" \"%s\": %s\n", + ( teamonly ) ? "TPrivMsg" : "PrivMsg", + ( ent ) ? ent - g_entities : -1, ( ent ) ? ent->client->pers.netname : "console", name, msg ); } @@ -3469,16 +3466,10 @@ Send a message to all active admins void Cmd_AdminMessage_f( gentity_t *ent ) { char cmd[ sizeof( "say_team" ) ]; - char prefix[ 50 ]; - char *msg; int skiparg = 0; // Check permissions and add the appropriate user [prefix] - if( !ent ) - { - Com_sprintf( prefix, sizeof( prefix ), "[CONSOLE]:" ); - } - else if( !G_admin_permission( ent, ADMF_ADMINCHAT ) ) + if( !G_admin_permission( ent, ADMF_ADMINCHAT ) ) { if( !g_publicAdminMessages.integer ) { @@ -3487,17 +3478,10 @@ void Cmd_AdminMessage_f( gentity_t *ent ) } else { - Com_sprintf( prefix, sizeof( prefix ), "[PLAYER] %s" S_COLOR_WHITE ":", - ent->client->pers.netname ); ADMP( "Your message has been sent to any available admins " "and to the server logs.\n" ); } } - else - { - Com_sprintf( prefix, sizeof( prefix ), "[ADMIN] %s" S_COLOR_WHITE ":", - ent->client->pers.netname ); - } // Skip say/say_team if this was used from one of those G_SayArgv( 0, cmd, sizeof( cmd ) ); @@ -3512,9 +3496,6 @@ void Cmd_AdminMessage_f( gentity_t *ent ) return; } - msg = G_SayConcatArgs( 1 + skiparg ); - - // Send it - G_AdminMessage( prefix, "%s", msg ); + G_AdminMessage( ent, "%s", G_SayConcatArgs( 1 + skiparg ) ); } diff --git a/src/game/g_local.h b/src/game/g_local.h index 492bce49..48451f12 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -687,7 +687,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 ); +void G_Say( gentity_t *ent, int mode, const char *chatText ); int G_SayArgc( void ); qboolean G_SayArgv( int n, char *buffer, int bufferLength ); char *G_SayConcatArgs( int start ); @@ -961,7 +961,7 @@ void G_MapConfigs( const char *mapname ); void CalculateRanks( void ); void FindIntermissionPoint( void ); void G_RunThink( gentity_t *ent ); -void QDECL G_AdminMessage( const char *prefix, const char *fmt, ... ); +void QDECL G_AdminMessage( gentity_t *ent, const char *fmt, ... ); void QDECL G_LogPrintf( const char *fmt, ... ); void SendScoreboardMessageToAllClients( void ); void QDECL G_Printf( const char *fmt, ... ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 902f9a0c..da521eb3 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1661,11 +1661,11 @@ Print to all active server admins, and to the logfile, and to the server console Prepend *prefix, or '[SERVER]' if no *prefix is given ================= */ -void QDECL G_AdminMessage( const char *prefix, const char *fmt, ... ) +void QDECL G_AdminMessage( gentity_t *ent, const char *fmt, ... ) { va_list argptr; char string[ 1024 ]; - char outstring[ 1024 ]; + char outstring[ 1024 ] = S_COLOR_MAGENTA; int i; // Format the text @@ -1673,26 +1673,21 @@ void QDECL G_AdminMessage( const char *prefix, const char *fmt, ... ) Q_vsnprintf( string, sizeof( string ), fmt, argptr ); va_end( argptr ); - // If there is no prefix, assume that this function was called directly - // and we should add one - if( !prefix || !prefix[ 0 ] ) - { - prefix = "[SERVER]:"; - } - // Create the final string - Com_sprintf( outstring, sizeof( outstring ), "%s " S_COLOR_MAGENTA "%s", - prefix, string ); + Q_strcat( outstring, sizeof( outstring ), string ); + Com_sprintf( string, sizeof( string ), "chat \"%s\"", outstring ); // Send to all appropriate clients for( i = 0; i < level.maxclients; i++ ) { if( G_admin_permission( &g_entities[ i ], ADMF_ADMINCHAT ) ) - trap_SendServerCommand( i, va( "chat \"%s\"", outstring ) ); + trap_SendServerCommand( i, string ); } // Send to the logfile and server console - G_LogPrintf("adminmsg: %s\n", outstring ); + G_LogPrintf( "AdminMsg: %d \"%s" S_COLOR_WHITE "\": %s\n", + ent ? ent - g_entities : -1, ent ? ent->client->pers.netname : "console", + outstring ); } diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index acef3b18..c81ffca1 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -376,7 +376,7 @@ static void Svcmd_TeamMessage_f( void ) prefix = va( "[%c] ", toupper( *prefix ) ); G_TeamCommand( team, va( "tchat \"(console): " S_COLOR_CYAN "%s\"", ConcatArgs( 2 ) ) ); - G_LogPrintf( "sayteam: %sconsole: " S_COLOR_CYAN "%s\n", prefix, ConcatArgs( 2 ) ); + G_LogPrintf( "SayTeam: -1 \"console\": " S_COLOR_CYAN "%s\n", ConcatArgs( 2 ) ); } static void Svcmd_CenterPrint_f( void ) @@ -473,13 +473,13 @@ static void Svcmd_PrintQueue_f( void ) trap_Argv( 1, team, sizeof( team ) ); - switch( team[0] ) + switch( G_TeamFromString( team ) ) { - case 'a': + case TEAM_ALIENS: G_PrintSpawnQueue( &level.alienSpawnQueue ); break; - case 'h': + case TEAM_HUMANS: G_PrintSpawnQueue( &level.humanSpawnQueue ); break; @@ -490,8 +490,9 @@ static void Svcmd_PrintQueue_f( void ) static void Svcmd_Chat_f( void ) { - trap_SendServerCommand( -1, va( "chat \"%s\"", ConcatArgs( 1 ) ) ); - G_LogPrintf("chat: %s\n", ConcatArgs( 1 ) ); + char *s = ConcatArgs( 1 ); + trap_SendServerCommand( -1, va( "chat \"%s\"", s ) ); + G_LogPrintf("chat: %s\n", s ); } // dumb wrapper for "a" and "m" and "say" @@ -505,7 +506,7 @@ static void Svcmd_MessageWrapper( void ) else if( !Q_stricmp( cmd, "m" ) ) Cmd_PrivateMessage_f( NULL ); else if( !Q_stricmp( cmd, "say" ) ) - G_Say( NULL, NULL, SAY_ALL, ConcatArgs( 1 ) ); + G_Say( NULL, SAY_ALL, ConcatArgs( 1 ) ); } struct diff --git a/src/game/g_utils.c b/src/game/g_utils.c index 6655c2d4..d90898eb 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -995,7 +995,7 @@ qboolean G_AddressParse( const char *str, addr_t *addr, int *netmask ) { if( *p ) return qfalse; - *subnet = max; + *netmask = max; } return qtrue; } |