diff options
author | Ben Millwood <thebenmachine@gmail.com> | 2009-11-06 13:16:32 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:18 +0000 |
commit | f5a27415ca17d0ff1fc4f9285725bcf7f3715586 (patch) | |
tree | 56f74cf8da69a7a72567626d6ff36fe0c5185756 /src/game/g_buildable.c | |
parent | d2c8b518b1e73ac7c5cd0fcf773bd572c3041fb7 (diff) |
* Fix for lonely buildables dividing by zero
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r-- | src/game/g_buildable.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 1a1b6197..a2288d93 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -1270,6 +1270,10 @@ void AHive_Think( gentity_t *self ) VectorSubtract( self->s.origin, range, mins ); num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); + + if( num == 0 ) + return; + start = rand( ) % num; for( i = start; i < num + start; i++ ) { @@ -1659,7 +1663,8 @@ void ATrapper_FindEnemy( gentity_t *ent, int range ) int i; int start; - //iterate through entities + // iterate through entities + // note that if we exist then level.num_entities != 0 start = rand( ) % level.num_entities; for( i = start; i < level.num_entities + start; i++ ) { @@ -2448,6 +2453,10 @@ void HMGTurret_FindEnemy( gentity_t *self ) VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); + + if( num == 0 ) + return; + start = rand( ) % num; for( i = start; i < num + start ; i++ ) { |