summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_cmds.c11
-rw-r--r--src/game/g_local.h5
-rw-r--r--src/game/g_main.c24
3 files changed, 37 insertions, 3 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 1a631389..b382c28a 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1313,16 +1313,23 @@ Activate an item
void Cmd_ActivateItem_f( gentity_t *ent )
{
char s[ MAX_TOKEN_CHARS ];
- int upgrade;
+ int upgrade, weapon;
trap_Argv( 1, s, sizeof( s ) );
upgrade = BG_FindUpgradeNumForName( s );
+ weapon = BG_FindWeaponNumForName( s );
if( ent->client->pers.teamSelection != PTE_HUMANS )
return;
- if( BG_gotItem( upgrade, ent->client->ps.stats ) )
+ if( upgrade != UP_NONE && BG_gotItem( upgrade, ent->client->ps.stats ) )
BG_activateItem( upgrade, ent->client->ps.stats );
+ else if( weapon != WP_NONE )
+ {
+ //force a weapon change
+ ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
+ trap_SendServerCommand( ent-g_entities, va( "weaponswitch %d", weapon ) );
+ }
else
trap_SendServerCommand( ent-g_entities, va( "print \"You don't have the %s\n\"", s ) );
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 8d891279..82681dc5 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -531,6 +531,11 @@ typedef struct
int numAlienClients;
int numHumanClients;
+ float averageNumAlienClients;
+ int numAlienSamples;
+ float averageNumHumanClients;
+ int numHumanSamples;
+
int numLiveAlienClients;
int numLiveHumanClients;
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 0fd433b7..5283ff35 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1129,6 +1129,17 @@ 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 );
@@ -1549,8 +1560,11 @@ can see the last frag.
*/
void CheckExitRules( void )
{
- int i;
+ int i;
gclient_t *cl;
+ char s[ MAX_STRING_CHARS ];
+
+ trap_Cvar_VariableStringBuffer( "mapname", s, sizeof( s ) );
// if at the intermission, wait for all non-bots to
// signal ready, then go to next level
@@ -1589,6 +1603,10 @@ void CheckExitRules( void )
//humans win
level.lastWin = PTE_HUMANS;
trap_SendServerCommand( -1, "print \"Humans win.\n\"");
+ G_LogPrintf( "STATS T:H A:%f H:%f M:%s D:%d\n", level.averageNumAlienClients,
+ level.averageNumHumanClients,
+ s, level.time - level.startTime );
+
LogExit( "Humans win." );
return;
}
@@ -1599,6 +1617,10 @@ void CheckExitRules( void )
//aliens win
level.lastWin = PTE_ALIENS;
trap_SendServerCommand( -1, "print \"Aliens win.\n\"");
+ G_LogPrintf( "STATS T:A A:%f H:%f M:%s D:%d\n", level.averageNumAlienClients,
+ level.averageNumHumanClients,
+ s, level.time - level.startTime );
+
LogExit( "Aliens win." );
return;
}