summaryrefslogtreecommitdiff
path: root/src/game/g_buildable.c
diff options
context:
space:
mode:
authorM. Kristall <mkpdev@gmail.com>2011-08-14 21:16:09 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:18:13 +0000
commitd432478aad0b3f0e9254762fc41471212c315652 (patch)
tree8351e44465f156b6cfee622098cdde955b531c72 /src/game/g_buildable.c
parentd34172288e4d5313a6c97ea56987315b67b022d0 (diff)
* (bug 3781) Improve randomness in some cases (Lakitu7 made me do it)
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r--src/game/g_buildable.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index f0016765..6f48aadd 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1300,7 +1300,7 @@ void AHive_Think( gentity_t *self )
if( num == 0 )
return;
- start = rand( ) % num;
+ start = rand( ) / ( RAND_MAX / num + 1 );
for( i = start; i < num + start; i++ )
{
if( AHive_CheckTarget( self, g_entities + entityList[ i % num ] ) )
@@ -1477,7 +1477,7 @@ void ATrapper_FindEnemy( gentity_t *ent, int range )
// iterate through entities
// note that if we exist then level.num_entities != 0
- start = rand( ) % level.num_entities;
+ start = rand( ) / ( RAND_MAX / level.num_entities + 1 );
for( i = start; i < level.num_entities + start; i++ )
{
target = g_entities + ( i % level.num_entities );
@@ -2284,7 +2284,7 @@ void HMGTurret_FindEnemy( gentity_t *self )
if( num == 0 )
return;
- start = rand( ) % num;
+ start = rand( ) / ( RAND_MAX / num + 1 );
for( i = start; i < num + start ; i++ )
{
target = &g_entities[ entityList[ i % num ] ];
@@ -4072,7 +4072,7 @@ void G_LayoutSelect( void )
"found, using map default\n" );
return;
}
- layoutNum = ( rand( ) % cnt ) + 1;
+ layoutNum = rand( ) / ( RAND_MAX / cnt + 1 ) + 1;
cnt = 0;
Q_strncpyz( layouts2, layouts, sizeof( layouts2 ) );