diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 8730bcd..59dbe13 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -91,7 +91,7 @@ g_admin_cmd_t g_admin_cmds[ ] = {"customgrav", G_admin_customgrav, "Q", "set the gravity for a specific player. Normal gives normal server gravity", - "[^3name|slot#^7] [^3#/normal^7]" + "[^3name|slot#^7] [^3#^7]" }, {"denybuild", G_admin_denybuild, "d", @@ -865,7 +865,7 @@ static void admin_log( gentity_t *admin, char *cmd, int skiparg ) { fileHandle_t f; int len, i, j; - char string[ MAX_STRING_CHARS ]; + char string[ MAX_STRING_CHARS ], decolored[ MAX_STRING_CHARS ]; int min, tens, sec; g_admin_admin_t *a; g_admin_level_t *l; @@ -956,7 +956,17 @@ static void admin_log( gentity_t *admin, char *cmd, int skiparg ) cmd, G_SayConcatArgs( 1 + skiparg ) ); } - trap_FS_Write( string, strlen( string ), f ); + + if( g_decolorLogfiles.integer ) + { + G_DecolorString( string, decolored ); + trap_FS_Write( decolored, strlen( decolored ), f ); + } + else + { + trap_FS_Write( string, strlen( string ), f ); + } + trap_FS_FCloseFile( f ); if ( !Q_stricmp( cmd, "attempted" ) ) @@ -5292,17 +5302,12 @@ qboolean G_admin_customgrav( gentity_t *ent, int skiparg ) int minargc; gentity_t *vic; - if( !ent ) - { - ADMP( "^3!customgrav: ^7console cannot use this command\n" ); - return qfalse; - } - minargc = 3 + skiparg; + minargc = 2 + skiparg; if( G_SayArgc() < minargc ) { - ADMP( "^3!customgrav: ^7usage: !customgrav [name|slot#] [gravity#|normal]\n" ); + ADMP( "^3!customgrav: ^7usage: !customgrav [name|slot#] [gravity#]\n" ); return qfalse; } @@ -5326,15 +5331,17 @@ qboolean G_admin_customgrav( gentity_t *ent, int skiparg ) G_SayArgv( 2 + skiparg, lvl, sizeof( lvl ) ); -if( !Q_stricmp( lvl, "normal" ) ) +minargc = 3 + skiparg; + +if( G_SayArgc() < minargc ) { vic->client->pers.cusgrav = qfalse; -ADMP( "^3!customgrav: ^7their custom gravity has been disabled\n" ); +ADMP( "^3!customgrav: ^7player's custom gravity has been disabled\n" ); } + else { - -ADMP( va( "^3!customgrav: ^7their gravity has been set to %s\n", ( atoi(lvl) == 0 ) ? "0" : lvl ) ); +ADMP( va( "^3!customgrav: ^7player's gravity has been set to %s\n", ( atoi(lvl) == 0 ) ? "0" : lvl ) ); vic->client->pers.cusgrav = qtrue; vic->client->pers.cusgravlvl = atoi(lvl); } @@ -5352,12 +5359,6 @@ qboolean G_admin_explode( gentity_t *ent, int skiparg ) int minargc; gentity_t *vic; - if( !ent ) - { - ADMP( "^3!explode: ^7console cannot use this command\n" ); - return qfalse; - } - minargc = 2 + skiparg; if( G_SayArgc() < minargc ) diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index f7229df..b49ef12 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -667,7 +667,7 @@ void ASpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int BG_FindHumanNameForBuildable( self->s.modelindex ), attacker->client->pers.netname ) ); } - G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n", + G_LogPrintf( "Decon: %i %i %i: %s^7 destroyed %s by %s\n", attacker->client->ps.clientNum, self->s.modelindex, mod, attacker->client->pers.netname, BG_FindNameForBuildable( self->s.modelindex ), @@ -960,7 +960,7 @@ void ABarricade_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, BG_FindHumanNameForBuildable( self->s.modelindex ), attacker->client->pers.netname ) ); } - G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n", + G_LogPrintf( "Decon: %i %i %i: %s^7 destroyed %s by %s\n", attacker->client->ps.clientNum, self->s.modelindex, mod, attacker->client->pers.netname, BG_FindNameForBuildable( self->s.modelindex ), @@ -1424,7 +1424,7 @@ void AHovel_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int BG_FindHumanNameForBuildable( self->s.modelindex ), attacker->client->pers.netname ) ); } - G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n", + G_LogPrintf( "Decon: %i %i %i: %s^7 destroyed %s by %s\n", attacker->client->ps.clientNum, self->s.modelindex, mod, attacker->client->pers.netname, BG_FindNameForBuildable( self->s.modelindex ), @@ -2449,7 +2449,7 @@ void HSpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int BG_FindHumanNameForBuildable( self->s.modelindex ), attacker->client->pers.netname ) ); } - G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n", + G_LogPrintf( "Decon: %i %i %i: %s^7 destroyed %s by %s\n", attacker->client->ps.clientNum, self->s.modelindex, mod, attacker->client->pers.netname, BG_FindNameForBuildable( self->s.modelindex ), diff --git a/src/game/g_client.c b/src/game/g_client.c index 6cdc9fb..f6ae2d2 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1200,9 +1200,29 @@ void ClientUserinfoChanged( int clientNum ) if( strcmp( oldname, client->pers.netname ) ) { trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE - " renamed to %s\n\"", oldname, client->pers.netname ) ); - G_LogPrintf( "ClientRename: %i [%s] (%s) \"%s\" -> \"%s\"\n", clientNum, + " renamed to %s^7\n\"", oldname, client->pers.netname ) ); + if( g_decolorLogfiles.integer) + { + char decolored[ MAX_STRING_CHARS ] = ""; + if( g_decolorLogfiles.integer == 1 ) + { + Com_sprintf( decolored, sizeof(decolored), " (\"%s^7\" -> \"%s^7\")", oldname, client->pers.netname ); + G_DecolorString( decolored, decolored ); + G_LogPrintfColored( "ClientRename: %i [%s] (%s) \"%s^7\" -> \"%s^7\"%s\n", clientNum, + client->pers.ip, client->pers.guid, oldname, client->pers.netname, decolored ); + } + else + { + G_LogPrintf( "ClientRename: %i [%s] (%s) \"%s^7\" -> \"%s^7\"%s\n", clientNum, + client->pers.ip, client->pers.guid, oldname, client->pers.netname, decolored ); + } + + } + else + { + G_LogPrintf( "ClientRename: %i [%s] (%s) \"%s^7\" -> \"%s^7\"\n", clientNum, client->pers.ip, client->pers.guid, oldname, client->pers.netname ); + } G_admin_namelog_update( client, qfalse ); } } @@ -1411,8 +1431,28 @@ char *ClientConnect( int clientNum, qboolean firstTime ) // get and distribute relevent paramters ClientUserinfoChanged( clientNum ); - G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s\"\n", clientNum, + + if( g_decolorLogfiles.integer ) + { + char decolored[ MAX_STRING_CHARS ] = ""; + if( g_decolorLogfiles.integer == 1 ) + { + Com_sprintf( decolored, sizeof(decolored), " (\"%s^7\")", client->pers.netname ); + G_DecolorString( decolored, decolored ); + G_LogPrintfColored( "ClientConnect: %i [%s] (%s) \"%s^7\"%s\n", clientNum, + client->pers.ip, client->pers.guid, client->pers.netname, decolored ); + } + else + { + G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s^7\"%s\n", clientNum, + client->pers.ip, client->pers.guid, client->pers.netname, decolored ); + } + } + else + { + G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s^7\"\n", clientNum, client->pers.ip, client->pers.guid, client->pers.netname ); + } // don't do the "xxx connected" messages if they were caried over from previous level if( firstTime ) @@ -1867,7 +1907,7 @@ void ClientDisconnect( int clientNum ) tent->s.clientNum = ent->s.clientNum; } - G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s\"\n", clientNum, + G_LogPrintf( "ClientDisconnect: %i [%s] (%s) \"%s^7\"\n", clientNum, ent->client->pers.ip, ent->client->pers.guid, ent->client->pers.netname ); trap_UnlinkEntity( ent ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 1041b42..67cbe73 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1048,15 +1048,15 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { default: case PTE_NONE: - prefix = "[S] "; + prefix = "[^3S^7] "; break; case PTE_ALIENS: - prefix = "[A] "; + prefix = "[^1A^7] "; break; case PTE_HUMANS: - prefix = "[H] "; + prefix = "[^4H^] "; } } else @@ -1066,14 +1066,14 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) { default: case SAY_ALL: - G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "say: %s^7: %s^7\n", ent->client->pers.netname, chatText ); Com_sprintf( name, sizeof( name ), "%s%s%c%c"EC": ", prefix, ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_GREEN; break; case SAY_TEAM: - G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "sayteam: %s^7: %s^7\n", ent->client->pers.netname, chatText ); if( Team_GetLocationMsg( ent, location, sizeof( location ) ) ) Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC") (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location ); @@ -1361,7 +1361,7 @@ static void Cmd_Tell_f( gentity_t *ent ) p = ConcatArgs( 2 ); - G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, p ); + G_LogPrintf( "tell: %s^7 to %s^7: %s^7\n", ent->client->pers.netname, target->client->pers.netname, p ); G_Say( ent, target, SAY_TELL, p ); // don't tell to the player self if it was already directed to this player // also don't send the chat back to a bot @@ -2650,7 +2650,7 @@ void Cmd_Destroy_f( gentity_t *ent ) BG_FindHumanNameForBuildable( traceEnt->s.modelindex ), ent->client->pers.netname ) ); - G_LogPrintf( "Decon: %i %i 0: %s deconstructed %s\n", + G_LogPrintf( "Decon: %i %i 0: %s^7 deconstructed %s\n", ent->client->ps.clientNum, traceEnt->s.modelindex, ent->client->pers.netname, @@ -3818,6 +3818,13 @@ static void Cmd_Ignore_f( gentity_t *ent ) return; } + + if( g_floodMinTime.integer && + G_Flood_Limited( ent ) ) + { + trap_SendServerCommand( ent-g_entities, "print \"Your donations are flood-limited; wait before trying again\n\"" ); + return; + } team = ent->client->pers.teamSelection; @@ -4021,7 +4028,13 @@ static void Cmd_Ignore_f( gentity_t *ent ) return; } - + + if( g_floodMinTime.integer && + G_Flood_Limited( ent ) ) + { + trap_SendServerCommand( ent-g_entities, "print \"Your donations are flood-limited; wait before trying again\n\"" ); + return; + } if( ent->client->pers.teamSelection == PTE_ALIENS ) divisor = level.numAlienClients-1; @@ -4496,7 +4509,7 @@ void G_PrivateMessage( gentity_t *ent ) ADMP( va( "%s\n", str ) ); - G_LogPrintf( "%s: %s: %s: %s\n", + G_LogPrintf( "%s: %s^7: %s^7: %s^7\n", ( teamonly ) ? "tprivmsg" : "privmsg", ( ent ) ? ent->client->pers.netname : "console", name, msg ); diff --git a/src/game/g_combat.c b/src/game/g_combat.c index aa1904f..4bd0918 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -197,7 +197,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int else obit = modNames[ meansOfDeath ]; - G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n", + G_LogPrintf("Kill: %i %i %i: %s^7 killed %s^7 by %s\n", killer, self->s.number, meansOfDeath, killerName, self->client->pers.netname, obit ); diff --git a/src/game/g_local.h b/src/game/g_local.h index 076964a..34f3c42 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1050,6 +1050,7 @@ void CalculateRanks( void ); void FindIntermissionPoint( void ); void G_RunThink( gentity_t *ent ); void QDECL G_LogPrintf( const char *fmt, ... ); +void QDECL G_LogPrintfColored( const char *fmt, ... ); void QDECL G_LogOnlyPrintf( const char *fmt, ... ); void SendScoreboardMessageToAllClients( void ); void QDECL G_Printf( const char *fmt, ... ); @@ -1323,6 +1324,8 @@ extern vmCvar_t g_minLevelToSpecMM1; extern vmCvar_t g_KillerHP; +extern vmCvar_t g_decolorLogfiles; + extern vmCvar_t g_privateMessages; extern vmCvar_t g_buildLogMaxLength; extern vmCvar_t g_publicSayadmins; diff --git a/src/game/g_main.c b/src/game/g_main.c index d70a215..f8bf923 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -164,6 +164,8 @@ vmCvar_t g_antiSpawnBlock; vmCvar_t g_KillerHP; +vmCvar_t g_decolorLogfiles; + vmCvar_t g_tag; vmCvar_t g_radiationDamage; @@ -356,6 +358,8 @@ static cvarTable_t gameCvarTable[ ] = { &g_KillerHP, "g_KillerHP", "0", CVAR_ARCHIVE, 0, qtrue }, + { &g_decolorLogfiles, "g_decolorLogfiles", "0", CVAR_ARCHIVE, 0, qfalse }, + { &g_tag, "g_tag", "main", CVAR_INIT, 0, qfalse }, { &g_dretchPunt, "g_dretchPunt", "1", CVAR_ARCHIVE, 0, qfalse }, @@ -1783,6 +1787,49 @@ Print to the logfile with a time stamp if it is open ================= */ void QDECL G_LogPrintf( const char *fmt, ... ) +{ + va_list argptr; + char string[ 1024 ], decolored[ 1024 ]; + int min, tens, sec; + + sec = level.time / 1000; + + min = sec / 60; + sec -= min * 60; + tens = sec / 10; + sec -= tens * 10; + + Com_sprintf( string, sizeof( string ), "%3i:%i%i ", min, tens, sec ); + + va_start( argptr, fmt ); + vsprintf( string +7 , fmt,argptr ); + va_end( argptr ); + + if( g_dedicated.integer ) + G_Printf( "%s", string + 7 ); + + if( !level.logFile ) + return; + + if( g_decolorLogfiles.integer ) + { + G_DecolorString( string, decolored ); + trap_FS_Write( decolored, strlen( decolored ), level.logFile ); + } + else + { + trap_FS_Write( string, strlen( string ), level.logFile ); + } +} + +/* +================= +G_LogPrintfColored + +Bypasses g_decolorLogfiles for events that need colors in the logs +================= +*/ +void QDECL G_LogPrintfColored( const char *fmt, ... ) { va_list argptr; char string[ 1024 ];