aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llrand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmath/llrand.cpp')
-rw-r--r--linden/indra/llmath/llrand.cpp59
1 files changed, 24 insertions, 35 deletions
diff --git a/linden/indra/llmath/llrand.cpp b/linden/indra/llmath/llrand.cpp
index 38e0639..4c214c4 100644
--- a/linden/indra/llmath/llrand.cpp
+++ b/linden/indra/llmath/llrand.cpp
@@ -1,6 +1,6 @@
1/** 1/**
2 * @file llrand.cpp 2 * @file llrand.cpp
3 * @brief a few useful math functions. 3 * @brief Global random generator.
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
@@ -30,45 +30,34 @@
30#include "llrand.h" 30#include "llrand.h"
31#include "lluuid.h" 31#include "lluuid.h"
32 32
33/* Put this back if you re-enabled slamFPCW 33static LLRandLagFib2281 gRandomGenerator(LLUUID::getRandomSeed());
34#if LL_WINDOWS
35#include <float.h>
36#else
37#include <stdlib.h>
38#endif
39*/
40 34
41void slamFPCW( void ) 35S32 ll_rand()
42{ 36{
43/* 37 return (S32)(gRandomGenerator() * RAND_MAX);
44#if LL_WINDOWS
45 // for Intel based CPUs, slam the FP control word directly
46 WORD wTemp, wSave;
47
48 __asm fstcw wSave
49 if ( (wSave & 0x300) // Not single mode
50 ||(0x3f != (wSave & 0x3f)) // Exceptions enabled
51 ||(wSave & 0xC00)) // Not round to nearest mode
52 {
53 __asm
54 {
55 mov ax, wSave
56 and ax, not 300h ;; single mode
57 or ax, 3fh ;; disable all exceptions
58 and ax, not 0xC00 ;; round to nearest mode
59 mov wTemp, ax
60 fldcw wTemp
61 }
62 }
63#endif
64*/
65} 38}
66 39
67LLRand gLindenLabRandomNumber(LLUUID::getRandomSeed()); 40S32 ll_rand(S32 val)
41{
42 return (S32)(gRandomGenerator() * val);
43}
44
45F32 ll_frand()
46{
47 return (F32)gRandomGenerator();
48}
68 49
69F32 frand(F32 val) 50F32 ll_frand(F32 val)
70{ 51{
71// return (val * (F32)rand()/(F32)RAND_MAX); 52 return (F32)gRandomGenerator() * val;
72 return gLindenLabRandomNumber.llfrand(val);
73} 53}
74 54
55F64 ll_drand()
56{
57 return gRandomGenerator();
58}
59
60F64 ll_drand(F64 val)
61{
62 return gRandomGenerator() * val;
63}