mirror of
https://github.com/ioquake/jedi-academy.git
synced 2024-11-10 15:22:14 +00:00
don't hardcode windows value of RAND_MAX and fix namespace issues
This commit is contained in:
parent
0c448c94df
commit
2c2667afcc
1 changed files with 4 additions and 8 deletions
|
@ -972,24 +972,20 @@ inline float Q_crandom( int *seed ) {
|
||||||
|
|
||||||
// Returns a float min <= x < max (exclusive; will get max - 0.00001; but never max
|
// Returns a float min <= x < max (exclusive; will get max - 0.00001; but never max
|
||||||
inline float Q_flrand(float min, float max) {
|
inline float Q_flrand(float min, float max) {
|
||||||
return ((rand() * (max - min)) / 32768.0F) + min;
|
return ((rand() * (max - min)) / (float)(RAND_MAX)) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an integer min <= x <= max (ie inclusive)
|
// Returns an integer min <= x <= max (ie inclusive)
|
||||||
inline int Q_irand(int min, int max) {
|
inline int Q_irand(int min, int max) {
|
||||||
max++; //so it can round down
|
max++; //so it can round down
|
||||||
return ((rand() * (max - min)) >> 15) + min;
|
return ((rand() * (max - min)) / (RAND_MAX)) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns a float between 0 and 1.0
|
//returns a float between 0 and 1.0
|
||||||
inline float random() {
|
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
|
||||||
return (rand() / ((float)0x7fff));
|
|
||||||
}
|
|
||||||
|
|
||||||
//returns a float between -1 and 1.0
|
//returns a float between -1 and 1.0
|
||||||
inline float crandom() {
|
#define crandom() (2.0F * (random() - 0.5F))
|
||||||
return (2.0F * (random() - 0.5F));
|
|
||||||
}
|
|
||||||
|
|
||||||
float erandom( float mean );
|
float erandom( float mean );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue