TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Random.cpp File Reference
#include "Random.h"
#include "Common.h"
#include "Errors.h"
#include "SFMT.h"
#include <boost/thread/tss.hpp>
+ Include dependency graph for Random.cpp:

Functions

static SFMTRandGetRng ()
 
int32 irand (int32 min, int32 max)
 
uint32 urand (uint32 min, uint32 max)
 
uint32 urandms (uint32 min, uint32 max)
 
float frand (float min, float max)
 
uint32 rand32 ()
 
double rand_norm ()
 
double rand_chance ()
 

Variables

static
boost::thread_specific_ptr
< SFMTRand
sfmtRand
 

Function Documentation

float frand ( float  min,
float  max 
)
59 {
60  ASSERT(max >= min);
61  return float(GetRng()->Random() * (max - min) + min);
62 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

static SFMTRand* GetRng ( )
static
27 {
28  SFMTRand* rand = sfmtRand.get();
29 
30  if (!rand)
31  {
32  rand = new SFMTRand();
33  sfmtRand.reset(rand);
34  }
35 
36  return rand;
37 }
Definition: SFMT.h:158
static boost::thread_specific_ptr< SFMTRand > sfmtRand
Definition: Random.cpp:24

+ Here is the caller graph for this function:

int32 irand ( int32  min,
int32  max 
)
40 {
41  ASSERT(max >= min);
42  return int32(GetRng()->IRandom(min, max));
43 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
int32_t int32
Definition: g3dmath.h:167
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 rand32 ( )
65 {
66  return GetRng()->BRandom();
67 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
uint32_t BRandom()
Definition: SFMT.h:240

+ Here is the call graph for this function:

double rand_chance ( )
75 {
76  return GetRng()->Random() * 100.0;
77 }
double Random()
Definition: SFMT.h:227
static SFMTRand * GetRng()
Definition: Random.cpp:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double rand_norm ( )
70 {
71  return GetRng()->Random();
72 }
double Random()
Definition: SFMT.h:227
static SFMTRand * GetRng()
Definition: Random.cpp:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 urand ( uint32  min,
uint32  max 
)
46 {
47  ASSERT(max >= min);
48  return GetRng()->URandom(min, max);
49 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
#define ASSERT
Definition: Errors.h:55
uint32_t URandom(uint32_t min, uint32_t max)
Definition: SFMT.h:208

+ Here is the call graph for this function:

uint32 urandms ( uint32  min,
uint32  max 
)
52 {
53  ASSERT(max >= min);
54  ASSERT(INT_MAX / IN_MILLISECONDS >= max);
55  return GetRng()->URandom(min * IN_MILLISECONDS, max * IN_MILLISECONDS);
56 }
static SFMTRand * GetRng()
Definition: Random.cpp:26
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Definition: Common.h:103
#define ASSERT
Definition: Errors.h:55
uint32_t URandom(uint32_t min, uint32_t max)
Definition: SFMT.h:208

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation