summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2011-02-21 08:37:02 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:18:01 +0000
commitcf1f5dc37a767c2ebe3c88fc106a23e5cc13b15a (patch)
tree23ee24c2113cc32eadc648a77c8b766d141c95a7 /src/game
parent194bcc454fa4964185c721577d3605fe11a97660 (diff)
* (bug 4908) Show BP from marked buildables on the HUD
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_public.h5
-rw-r--r--src/game/g_active.c4
-rw-r--r--src/game/g_buildable.c52
-rw-r--r--src/game/g_local.h3
4 files changed, 57 insertions, 7 deletions
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index eb6bb8af..6ba46f6e 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -274,8 +274,9 @@ typedef enum
PERS_CREDIT, // human credit
PERS_QUEUEPOS, // position in the spawn queue
PERS_NEWWEAPON, // weapon to switch to
- PERS_BP
- // netcode has space for 4 more
+ PERS_BP,
+ PERS_MARKEDBP
+ // netcode has space for 3 more
} persEnum_t;
#define PS_WALLCLIMBINGFOLLOW 0x00000001
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 89882760..a7cd08c0 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -1713,7 +1713,9 @@ void ClientThink_real( gentity_t *ent )
}
client->ps.persistant[ PERS_BP ] = G_GetBuildPoints( client->ps.origin,
- client->ps.stats[ STAT_TEAM ], BG_Class( client->ps.stats[ STAT_CLASS ] )->buildDist );
+ client->ps.stats[ STAT_TEAM ] );
+ client->ps.persistant[ PERS_MARKEDBP ] = G_GetMarkedBuildPoints( client->ps.origin,
+ client->ps.stats[ STAT_TEAM ] );
if( client->ps.persistant[ PERS_BP ] < 0 )
client->ps.persistant[ PERS_BP ] = 0;
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;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 703e305e..a420d39e 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -796,7 +796,8 @@ void G_LayoutLoad( void );
void G_BaseSelfDestruct( team_t team );
int G_NextQueueTime( int queuedBP, int totalBP, int queueBaseRate );
void G_QueueBuildPoints( gentity_t *self );
-int G_GetBuildPoints( const vec3_t pos, team_t team, int dist );
+int G_GetBuildPoints( const vec3_t pos, team_t team );
+int G_GetMarkedBuildPoints( const vec3_t pos, team_t team );
qboolean G_FindPower( gentity_t *self, qboolean searchUnspawned );
gentity_t *G_PowerEntityForPoint( const vec3_t origin );
gentity_t *G_PowerEntityForEntity( gentity_t *ent );