summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-17 22:02:17 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:53 +0000
commite3ae06926953e9c9da00e2c97e3ed8fee0e3cc6a (patch)
treea7e671e829bb33b4bb67a92ecdbec34cb943113d
parentf9683711bedc6c22889d151fe27313cb724bfbe2 (diff)
* Guard against buildable health going negative
-rw-r--r--src/game/g_buildable.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 1ac2fd28..36f17b66 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -2026,7 +2026,7 @@ void HReactor_Think( gentity_t *self )
if( self->spawned && ( self->health > 0 ) )
{
qboolean fired = qfalse;
-
+
// Creates a tesla trail for every target
num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
for( i = 0; i < num; i++ )
@@ -2062,7 +2062,7 @@ void HReactor_Think( gentity_t *self )
if( self->dcc )
self->nextthink = level.time + REACTOR_ATTACK_DCC_REPEAT;
- else
+ else
self->nextthink = level.time + REACTOR_ATTACK_REPEAT;
}
@@ -2777,7 +2777,6 @@ void G_BuildableThink( gentity_t *ent, int msec )
for( i = 0; i < MAX_CLIENTS; i++ )
ent->credits[ i ] = 0;
}
-
}
if( ent->clientSpawnTime > 0 )
@@ -2789,8 +2788,8 @@ void G_BuildableThink( gentity_t *ent, int msec )
ent->dcc = ( ent->buildableTeam != TEAM_HUMANS ) ? 0 : G_FindDCC( ent );
// Set health
- ent->s.generic1 = ent->health;
-
+ ent->s.generic1 = MAX( ent->health, 0 );
+
// Set flags
ent->s.eFlags &= ~( EF_B_POWERED | EF_B_SPAWNED | EF_B_MARKED );
if( ent->powered )
@@ -3697,10 +3696,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
built->physicsBounce = BG_Buildable( buildable )->bounce;
built->s.groundEntityNum = -1;
- built->s.generic1 = built->health;
-
- if( built->s.generic1 < 0 )
- built->s.generic1 = 0;
+ built->s.generic1 = MAX( built->health, 0 );
if( BG_Buildable( buildable )->team == TEAM_ALIENS )
{