From f5a27415ca17d0ff1fc4f9285725bcf7f3715586 Mon Sep 17 00:00:00 2001 From: Ben Millwood Date: Fri, 6 Nov 2009 13:16:32 +0000 Subject: * Fix for lonely buildables dividing by zero --- src/game/g_buildable.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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++ ) { -- cgit