summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Millwood <thebenmachine@gmail.com>2009-10-03 12:54:17 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:19 +0000
commitef9a9184ccd9848d8bf6b4a76272eac34475be60 (patch)
tree3a688aeb4f76a3d8286dca73e5e56df71eb3da70 /src
parenta9aefb6d2bbfcd40602837685f6b6b257620aeec (diff)
The reactor can only power as much BP as it can hold, and marked unpowered buildables don't give free BP
Diffstat (limited to 'src')
-rw-r--r--src/game/g_buildable.c60
1 files changed, 57 insertions, 3 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 152ed564..33fd9b35 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -183,8 +183,63 @@ static qboolean G_FindPower( gentity_t *self )
// Always prefer a reactor if there is one in range
if( ent->s.modelindex == BA_H_REACTOR && distance <= REACTOR_BASESIZE )
{
- self->parentNode = ent;
- return qtrue;
+ // Only power as much BP as the reactor can hold
+ if( self->s.modelindex != BA_NONE )
+ {
+ int buildPoints = g_humanBuildPoints.integer;
+
+ // Scan the buildables in the reactor zone
+ for( j = MAX_CLIENTS, ent2 = g_entities + j; j < level.num_entities; j++, ent2++ )
+ {
+ gentity_t *powerEntity;
+
+ if( ent2->s.eType != ET_BUILDABLE )
+ continue;
+
+ if( ent2 == self )
+ continue;
+
+ powerEntity = ent2->parentNode;
+
+ if( powerEntity && powerEntity->s.modelindex == BA_H_REACTOR && ( powerEntity == ent ) )
+ {
+ buildPoints -= BG_Buildable( ent2->s.modelindex )->buildPoints;
+ }
+ }
+
+ buildPoints -= BG_Buildable( self->s.modelindex )->buildPoints;
+
+ if( buildPoints >= 0 )
+ {
+ closestPower = ent;
+ minDistance = distance;
+ }
+ else
+ {
+ // a buildable can still be built if it shares BP from two zones
+
+ // TODO: handle combined power zones here
+ }
+
+ if( buildPoints >= 0 )
+ {
+ self->parentNode = ent;
+ return qtrue;
+ }
+ else
+ {
+ // a buildable can still be built if it shares BP from two zones
+
+ // TODO: handle combined power zones here
+ }
+ }
+
+ // Dummy buildables don't need to look for zones
+ else
+ {
+ self->parentNode = ent;
+ return qtrue;
+ }
}
else if( distance < minDistance )
{
@@ -3170,7 +3225,6 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable,
if( team == TEAM_HUMANS &&
buildable != BA_H_REACTOR &&
buildable != BA_H_REPEATER &&
- G_PowerEntityForPoint( ent->s.origin ) &&
G_PowerEntityForPoint( ent->s.origin ) != G_PowerEntityForPoint( origin ) )
continue;