summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2004-05-29 14:04:03 +0000
committerTim Angus <tim@ngus.net>2004-05-29 14:04:03 +0000
commit891c63f8c12ed10b7a0e400fd39a1ac5abd3a03d (patch)
tree3944b0d528023dae40e2c57e3f466a70d33d3912 /src/game
parent2ee76d11bb34641e021f69b3509da5c62e7afdb0 (diff)
* Fixed bug where passing nonsense to the team command would result in nonsense
* Average number of players code now works
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_cmds.c5
-rw-r--r--src/game/g_main.c38
2 files changed, 32 insertions, 11 deletions
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
@@ -1051,6 +1051,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
Recalculates the score ranks of all players
@@ -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( );