OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Random.h File Reference
#include <cinttypes>
Include dependency graph for C4Random.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void FixedRandom (uint64_t dwSeed)
 
uint32_t Random (uint32_t iRange)
 
uint32_t UnsyncedRandom ()
 
uint32_t UnsyncedRandom (uint32_t range)
 
uint32_t SeededRandom (uint64_t iSeed, uint32_t iRange)
 
void RecordRandom (uint32_t range, uint32_t val)
 

Variables

int RandomCount
 

Function Documentation

void FixedRandom ( uint64_t  dwSeed)

Definition at line 37 of file C4Random.cpp.

References RandomCount.

Referenced by c4_random_handle_seed(), C4Game::FixRandom(), and main().

38 {
39  RandomRng.seed(seed);
40  RandomCount = 0;
41 }
int RandomCount
Definition: C4Random.cpp:27

Here is the caller graph for this function:

uint32_t Random ( uint32_t  iRange)

Definition at line 50 of file C4Random.cpp.

References RecordRandom().

51 {
52  if (!iRange) return 0u;
53  uint32_t result = RandomRng(iRange);
54  RecordRandom(iRange, result);
55  return result;
56 }
void RecordRandom(uint32_t range, uint32_t val)

Here is the call graph for this function:

void RecordRandom ( uint32_t  range,
uint32_t  val 
)

Definition at line 22 of file C4RandomRecord.cpp.

References AddDbgRec(), C4RCRandom::Cnt, Config, C4ConfigGeneral::DebugRec, C4Config::General, RandomCount, C4RCRandom::Range, RCT_Random, and C4RCRandom::Val.

Referenced by Random().

23 {
24  RandomCount++;
26  {
27  // next pseudorandom value
28  C4RCRandom rc;
29  rc.Cnt=RandomCount;
30  rc.Range=range;
31  rc.Val=val;
32  AddDbgRec(RCT_Random, &rc, sizeof(rc));
33  }
34 }
C4Config Config
Definition: C4Config.cpp:833
int RandomCount
Definition: C4Random.cpp:27
C4ConfigGeneral General
Definition: C4Config.h:251
uint32_t Range
Definition: C4Record.h:143
uint32_t Val
Definition: C4Record.h:144
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
int32_t DebugRec
Definition: C4Config.h:60

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t SeededRandom ( uint64_t  iSeed,
uint32_t  iRange 
)

Definition at line 69 of file C4Random.cpp.

Referenced by C4Sky::Init().

70 {
71  if (!iRange) return 0;
72  pcg32 rng(iSeed);
73  return rng(iRange);
74 }

Here is the caller graph for this function:

uint32_t UnsyncedRandom ( uint32_t  range)

Definition at line 63 of file C4Random.cpp.

64 {
65  if (!iRange) return 0u;
66  return UnsyncedRandomRng(iRange);
67 }

Variable Documentation

int RandomCount

Definition at line 27 of file C4Random.cpp.

Referenced by FixedRandom(), and RecordRandom().