From cfbc2d72a7878cbbdc7980603878213d64873202 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Wed, 28 Mar 2001 23:18:34 +0000 Subject: Refined power some more. An actual limit is present now. --- src/game/g_main.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'src/game/g_main.c') diff --git a/src/game/g_main.c b/src/game/g_main.c index 8a26fba2..4da1a4b1 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -165,6 +165,8 @@ void G_RunFrame( int levelTime ); void G_ShutdownGame( int restart ); void CheckExitRules( void ); +void countSpawns( void ); +void calculateBuildPoints( void ); /* ================ @@ -493,7 +495,11 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) { G_RemapTeamShaders(); //TA: so the server counts the spawns without a client attached - CalculateRanks( ); + countSpawns( ); + + //TA: FIXME: grab these values from a worldspawn variable + level.humanBuildPoints = level.humanBuildPointsTotal = 1000; + level.droidBuildPoints = level.droidBuildPointsTotal = 1000; } @@ -774,6 +780,47 @@ void countSpawns( void ) } +/* +============ +calculateBuildPoints + +Recalculate the quantity of building points available to the teams +============ +*/ +void calculateBuildPoints( void ) +{ + int i; + int bclass; + gentity_t *ent; + + level.humanBuildPoints = level.humanBuildPointsPowered = level.humanBuildPointsTotal; + level.droidBuildPoints = level.droidBuildPointsTotal; + + for ( i = 1, ent = g_entities + i ; i < level.num_entities ; i++, ent++ ) + { + if (!ent->inuse) + continue; + + bclass = BG_FindBuildNumForEntityName( ent->classname ); + + if( bclass != BA_NONE ) + { + if( BG_FindTeamForBuildable( bclass ) == BIT_HUMANS ) + { + level.humanBuildPoints -= BG_FindBuildPointsForBuildable( bclass ); + + if( ent->powered ) + level.humanBuildPointsPowered -= BG_FindBuildPointsForBuildable( bclass ); + } + else + { + level.droidBuildPoints -= BG_FindBuildPointsForBuildable( bclass ); + } + } + } +} + + /* ============ CalculateRanks @@ -805,8 +852,6 @@ void CalculateRanks( void ) { level.numteamVotingClients[i] = 0; } - countSpawns( ); - for ( i = 0 ; i < level.maxclients ; i++ ) { if ( level.clients[i].pers.connected != CON_DISCONNECTED ) @@ -893,8 +938,11 @@ void CalculateRanks( void ) { } } - trap_SetConfigstring( CS_ABPOINTS, va("%i", level.droidBuildPoints ) ); + trap_SetConfigstring( CS_DBPOINTS, va("%i", level.droidBuildPoints ) ); + trap_SetConfigstring( CS_DTBPOINTS, va("%i", level.droidBuildPointsTotal ) ); trap_SetConfigstring( CS_HBPOINTS, va("%i", level.humanBuildPoints ) ); + trap_SetConfigstring( CS_HTBPOINTS, va("%i", level.humanBuildPointsTotal ) ); + trap_SetConfigstring( CS_HPBPOINTS, va("%i", level.humanBuildPointsPowered ) ); // set the CS_SCORES1/2 configstrings, which will be visible to everyone if ( g_gametype.integer >= GT_TEAM ) { @@ -1852,6 +1900,11 @@ end = trap_Milliseconds(); // see if it is time to do a tournement restart CheckTournament(); + + //TA: + countSpawns(); + calculateBuildPoints(); + Com_Printf( "%d %d %d\n", level.humanBuildPointsTotal, level.humanBuildPoints, level.humanBuildPointsPowered ); // see if it is time to end the level CheckExitRules(); -- cgit