From 891c63f8c12ed10b7a0e400fd39a1ac5abd3a03d Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sat, 29 May 2004 14:04:03 +0000 Subject: * Fixed bug where passing nonsense to the team command would result in nonsense * Average number of players code now works --- src/game/g_cmds.c | 5 +++++ src/game/g_main.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) (limited to 'src/game') diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index b382c28a..26367e83 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -496,6 +496,11 @@ void Cmd_Team_f( gentity_t *ent ) else team = PTE_ALIENS + ( rand( ) % 2 ); } + else + { + trap_SendServerCommand( ent-g_entities, va( "print \"Unknown team: %s\n\"", s ) ); + return; + } G_ChangeTeam( ent, team ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 5283ff35..4b2aa39d 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1049,6 +1049,29 @@ void G_CalculateStages( void ) } } +/* +============ +CalculateAvgPlayers + +Calculates the average number of players playing this game +============ +*/ +void G_CalculateAvgPlayers( void ) +{ + //calculate average number of clients for stats + level.averageNumAlienClients = + ( ( level.averageNumAlienClients * level.numAlienSamples ) + + level.numAlienClients ) / + (float)( level.numAlienSamples + 1 ); + level.numAlienSamples++; + + level.averageNumHumanClients = + ( ( level.averageNumHumanClients * level.numHumanSamples ) + + level.numHumanClients ) / + (float)( level.numHumanSamples + 1 ); + level.numHumanSamples++; +} + /* ============ CalculateRanks @@ -1129,17 +1152,6 @@ void CalculateRanks( void ) } } - //calculate average number of clients for stats - level.averageNumAlienClients = - ( ( level.averageNumAlienClients * level.numAlienSamples ) - + level.numAlienClients ) / - (float)( ++level.numAlienSamples ); - - level.averageNumHumanClients = - ( ( level.averageNumHumanClients * level.numHumanSamples ) - + level.numHumanClients ) / - (float)( ++level.numHumanSamples ); - qsort( level.sortedClients, level.numConnectedClients, sizeof( level.sortedClients[ 0 ] ), SortRanks ); @@ -1590,6 +1602,9 @@ void CheckExitRules( void ) if( level.time - level.startTime >= g_timelimit.integer * 60000 ) { trap_SendServerCommand( -1, "print \"Timelimit hit.\n\"" ); + G_LogPrintf( "STATS T:L A:%f H:%f M:%s D:%d\n", level.averageNumAlienClients, + level.averageNumHumanClients, + s, level.time - level.startTime ); LogExit( "Timelimit hit." ); return; } @@ -1938,6 +1953,7 @@ void G_RunFrame( int levelTime ) G_CalculateStages( ); G_SpawnClients( PTE_ALIENS ); G_SpawnClients( PTE_HUMANS ); + G_CalculateAvgPlayers( ); // see if it is time to end the level CheckExitRules( ); -- cgit