#define max(A,B) ((A) > (B) ? (A) : (B))
#endif
-#define lhrandom(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN))
+//#define lhrandom(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN))
+#define lhrandom(MIN,MAX) (((double)rand() / RAND_MAX) * ((MAX)-(MIN)) + (MIN))
#define invpow(base,number) (log(number) / log(base))
#define log2i(n) ((((n) & 0xAAAAAAAA) != 0 ? 1 : 0) | (((n) & 0xCCCCCCCC) != 0 ? 2 : 0) | (((n) & 0xF0F0F0F0) != 0 ? 4 : 0) | (((n) & 0xFF00FF00) != 0 ? 8 : 0) | (((n) & 0xFFFF0000) != 0 ? 16 : 0))
*/
void PF_random (void)
{
- float num;
-
- num = (rand ()&0x7fff) / ((float)0x7fff);
-
- G_FLOAT(OFS_RETURN) = num;
+ G_FLOAT(OFS_RETURN) = lhrandom(0, 1);
}
/*
*/
void VM_random (void)
{
- float num;
-
VM_SAFEPARMCOUNT(0,VM_random);
- num = (rand ()&0x7fff) / ((float)0x7fff);
-
- PRVM_G_FLOAT(OFS_RETURN) = num;
+ PRVM_G_FLOAT(OFS_RETURN) = lhrandom(0, 1);
}
/*
s = PRVM_G_STRING(OFS_PARM0);
PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
VM_CheckEmptyString (s);
-
+
if(!S_PrecacheSound (s,true, true))
Con_Printf("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
}