diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2011-02-21 08:37:02 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:18:01 +0000 |
commit | cf1f5dc37a767c2ebe3c88fc106a23e5cc13b15a (patch) | |
tree | 23ee24c2113cc32eadc648a77c8b766d141c95a7 /src/game/g_buildable.c | |
parent | 194bcc454fa4964185c721577d3605fe11a97660 (diff) |
* (bug 4908) Show BP from marked buildables on the HUD
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r-- | src/game/g_buildable.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index dd603309..2be2bf45 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -335,7 +335,7 @@ G_GetBuildPoints Get the number of build points from a position ================== */ -int G_GetBuildPoints( const vec3_t pos, team_t team, int extraDistance ) +int G_GetBuildPoints( const vec3_t pos, team_t team ) { if( G_TimeTilSuddenDeath( ) <= 0 ) { @@ -368,6 +368,52 @@ int G_GetBuildPoints( const vec3_t pos, team_t team, int extraDistance ) /* ================== +G_GetMarkedBuildPoints + +Get the number of marked build points from a position +================== +*/ +int G_GetMarkedBuildPoints( const vec3_t pos, team_t team ) +{ + gentity_t *ent; + int i; + int sum = 0; + + if( G_TimeTilSuddenDeath( ) <= 0 ) + return 0; + + if( !g_markDeconstruct.integer ) + return 0; + + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + { + if( ent->s.eType != ET_BUILDABLE ) + continue; + + if( team == TEAM_HUMANS && + ent->s.modelindex != BA_H_REACTOR && + ent->s.modelindex != BA_H_REPEATER && + ent->parentNode != G_PowerEntityForPoint( pos ) ) + continue; + + if( !ent->inuse ) + continue; + + if( ent->health <= 0 ) + continue; + + if( ent->buildableTeam != team ) + continue; + + if( ent->deconstruct ) + sum += BG_Buildable( ent->s.modelindex )->buildPoints; + } + + return sum; +} + +/* +================== G_InPowerZone See if a buildable is inside of another power zone. @@ -3053,7 +3099,7 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable, if( team == TEAM_ALIENS ) { - remainingBP = G_GetBuildPoints( origin, team, 0 ); + remainingBP = G_GetBuildPoints( origin, team ); remainingSpawns = level.numAlienSpawns; bpError = IBE_NOALIENBP; spawn = BA_A_SPAWN; @@ -3064,7 +3110,7 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable, if( buildable == BA_H_REACTOR || buildable == BA_H_REPEATER ) remainingBP = level.humanBuildPoints; else - remainingBP = G_GetBuildPoints( origin, team, 0 ); + remainingBP = G_GetBuildPoints( origin, team ); remainingSpawns = level.numHumanSpawns; bpError = IBE_NOHUMANBP; |