diff options
author | Andrey Nazarov <skuller@skuller.net> | 2010-06-09 18:15:17 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2010-06-09 18:15:17 +0000 |
commit | b00af1d828adb3adbababf945930d9dc34e4d305 (patch) | |
tree | 5dfea3566f653148af5d05ad522f7918c905b127 | |
parent | 9e2f9613f568b5532ad1872849a594aca250288a (diff) |
Expand the first ‘@’ character found in ‘logfile_prefix’ to a single letter corresponding to message type (T - talk, D - developer, W - warning, E - error, A - everything else).
Made player chat lines colored in dedicated server console.
-rw-r--r-- | source/cl_parse.c | 4 | ||||
-rw-r--r-- | source/common.c | 31 | ||||
-rw-r--r-- | source/q_shared.h | 1 | ||||
-rw-r--r-- | source/sv_game.c | 2 |
4 files changed, 26 insertions, 12 deletions
diff --git a/source/cl_parse.c b/source/cl_parse.c index fd82425..aa1340d 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -1339,9 +1339,7 @@ static void CL_ParsePrint( void ) { string[len] = '\n'; } - Com_SetColor( COLOR_ALT ); - Com_Printf( "%s", string ); - Com_SetColor( COLOR_NONE ); + Com_LPrintf( PRINT_TALK, "%s", string ); Con_SkipNotify( qfalse ); diff --git a/source/common.c b/source/common.c index 097ad63..7494b4e 100644 --- a/source/common.c +++ b/source/common.c @@ -238,7 +238,7 @@ static size_t format_local_time( char *buffer, size_t size, const char *fmt ) { return strftime( buffer, size, fmt, tm ); } -static void logfile_write( const char *string ) { +static void logfile_write( print_type_t type, const char *string ) { char text[MAXPRINTMSG]; char buf[MAX_QPATH]; char *p, *maxp; @@ -246,7 +246,21 @@ static void logfile_write( const char *string ) { int c; if( logfile_prefix->string[0] ) { + p = strchr( logfile_prefix->string, '@' ); + if( p ) { + // expand it in place, hacky + switch( type ) { + case PRINT_TALK: *p = 'T'; break; + case PRINT_DEVELOPER: *p = 'D'; break; + case PRINT_WARNING: *p = 'W'; break; + case PRINT_ERROR: *p = 'E'; break; + default: *p = 'A'; break; + } + } len = format_local_time( buf, sizeof( buf ), logfile_prefix->string ); + if( p ) { + *p = '@'; + } } else { len = 0; } @@ -339,6 +353,12 @@ void Com_LPrintf( print_type_t type, const char *fmt, ... ) { Com_Redirect( msg, len ); } else { switch( type ) { + case PRINT_TALK: + Com_SetColor( COLOR_ALT ); + break; + case PRINT_DEVELOPER: + Com_SetColor( COLOR_BLUE ); + break; case PRINT_WARNING: Com_SetColor( COLOR_YELLOW ); break; @@ -364,16 +384,11 @@ void Com_LPrintf( print_type_t type, const char *fmt, ... ) { // logfile if( com_logFile ) { - logfile_write( msg ); + logfile_write( type, msg ); } - switch( type ) { - case PRINT_WARNING: - case PRINT_ERROR: + if( type ) { Com_SetColor( COLOR_NONE ); - break; - default: - break; } } diff --git a/source/q_shared.h b/source/q_shared.h index a075ee4..0cdb97c 100644 --- a/source/q_shared.h +++ b/source/q_shared.h @@ -121,6 +121,7 @@ typedef enum { typedef enum { PRINT_ALL, // general messages + PRINT_TALK, // print in green color PRINT_DEVELOPER, // only print when "developer 1" PRINT_WARNING, // print in yellow color PRINT_ERROR // print in red color diff --git a/source/sv_game.c b/source/sv_game.c index dae19d9..f09d891 100644 --- a/source/sv_game.c +++ b/source/sv_game.c @@ -208,7 +208,7 @@ static void PF_cprintf( edict_t *ent, int level, const char *fmt, ... ) { } if( !ent ) { - Com_Printf( "%s", msg ); + Com_LPrintf( level == PRINT_CHAT ? PRINT_TALK : PRINT_ALL, "%s", msg ); return; } |