diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/bg_lib.h | 1 | ||||
| -rw-r--r-- | src/game/bg_pmove.c | 6 | ||||
| -rw-r--r-- | src/game/bg_voice.c | 2 | ||||
| -rw-r--r-- | src/game/g_active.c | 2 | ||||
| -rw-r--r-- | src/game/g_buildable.c | 8 | ||||
| -rw-r--r-- | src/game/g_cmds.c | 2 | ||||
| -rw-r--r-- | src/game/g_maprotation.c | 2 | ||||
| -rw-r--r-- | src/game/g_utils.c | 2 | ||||
| -rw-r--r-- | src/game/g_weapon.c | 2 | 
9 files changed, 14 insertions, 13 deletions
diff --git a/src/game/bg_lib.h b/src/game/bg_lib.h index ec62eeac..3eb6e19d 100644 --- a/src/game/bg_lib.h +++ b/src/game/bg_lib.h @@ -85,6 +85,7 @@ typedef unsigned  long uint32_t;                   __FILE__, __LINE__, #expr )  typedef int cmp_t( const void *, const void * );  void        qsort( void *a, size_t n, size_t es, cmp_t *cmp ); +#define RAND_MAX 0x7fff  void        srand( unsigned seed );  int         rand( void );  void        *bsearch( const void *key, const void *base, size_t nmemb, diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 16c49726..945a28a9 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -3330,7 +3330,7 @@ static void PM_Weapon( void )        case WP_ALEVEL1:          if( attack1 )          { -          num %= 6; +          num /= RAND_MAX / 6 + 1;            PM_ForceLegsAnim( NSPA_ATTACK1 );            PM_StartWeaponAnim( WANIM_ATTACK1 + num );          } @@ -3345,14 +3345,14 @@ static void PM_Weapon( void )        case WP_ALEVEL2:          if( attack1 )          { -          num %= 6; +          num /= RAND_MAX / 6 + 1;            PM_ForceLegsAnim( NSPA_ATTACK1 );            PM_StartWeaponAnim( WANIM_ATTACK1 + num );          }          break;        case WP_ALEVEL4: -        num %= 3; +        num /= RAND_MAX / 3 + 1;          PM_ForceLegsAnim( NSPA_ATTACK1 + num );          PM_StartWeaponAnim( WANIM_ATTACK1 + num );          break; diff --git a/src/game/bg_voice.c b/src/game/bg_voice.c index 7f4f4ae5..c0764dd6 100644 --- a/src/game/bg_voice.c +++ b/src/game/bg_voice.c @@ -625,7 +625,7 @@ voiceTrack_t *BG_VoiceTrackFind( voiceTrack_t *head, team_t team,      return NULL;    // return randomly selected match -  selectedMatch = rand() % matchCount; +  selectedMatch = rand() / ( RAND_MAX / matchCount + 1 );    vt = head;    i = 0;    j = 0; diff --git a/src/game/g_active.c b/src/game/g_active.c index 87cb7e94..aad05967 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -129,7 +129,7 @@ void P_WorldEffects( gentity_t *ent )          // play a gurp sound instead of a normal pain sound          if( ent->health <= ent->damage )            G_Sound( ent, CHAN_VOICE, G_SoundIndex( "*drown.wav" ) ); -        else if( rand( ) & 1 ) +        else if( rand( ) < RAND_MAX / 2 + 1 )            G_Sound( ent, CHAN_VOICE, G_SoundIndex( "sound/player/gurp1.wav" ) );          else            G_Sound( ent, CHAN_VOICE, G_SoundIndex( "sound/player/gurp2.wav" ) ); 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 ) ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 57cba07a..8461981f 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -651,7 +651,7 @@ void Cmd_Team_f( gentity_t *ent )      else if( level.alienTeamLocked || aliens > humans )        team = TEAM_HUMANS;      else -      team = TEAM_ALIENS + ( rand( ) % 2 ); +      team = TEAM_ALIENS + rand( ) / ( RAND_MAX / 2 + 1 );    }    else switch( G_TeamFromString( s ) )    { diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c index b37dbfd3..a8a9ea20 100644 --- a/src/game/g_maprotation.c +++ b/src/game/g_maprotation.c @@ -940,7 +940,7 @@ static qboolean G_EvaluateMapCondition( condition_t **condition )    switch( localCondition->lhs )    {      case CV_RANDOM: -      result = rand( ) & 1; +      result = rand( ) / ( RAND_MAX / 2 + 1 );        break;      case CV_NUMCLIENTS: diff --git a/src/game/g_utils.c b/src/game/g_utils.c index 45a00779..6968a6c0 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -222,7 +222,7 @@ gentity_t *G_PickTarget( char *targetname )      return NULL;    } -  return choice[ rand( ) % num_choices ]; +  return choice[ rand( ) / ( RAND_MAX / num_choices + 1 ) ];  } diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 2218bec2..c59f30ab 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -422,7 +422,7 @@ void shotgunFire( gentity_t *ent )    tent = G_TempEntity( muzzle, EV_SHOTGUN );    VectorScale( forward, 4096, tent->s.origin2 );    SnapVector( tent->s.origin2 ); -  tent->s.eventParm = rand() & 255;    // seed for spread pattern +  tent->s.eventParm = rand() / ( RAND_MAX / 0x100 + 1 );    // seed for spread pattern    tent->s.otherEntityNum = ent->s.number;    G_UnlaggedOn( ent, muzzle, SHOTGUN_RANGE );    ShotgunPattern( tent->s.pos.trBase, tent->s.origin2, tent->s.eventParm, ent );  | 
