OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Random.cpp File Reference
#include "C4Include.h"
#include "lib/C4Random.h"
#include <random>
#include <pcg/pcg_random.hpp>
Include dependency graph for C4Random.cpp:

Go to the source code of this file.

Functions

void FixedRandom (uint64_t seed)
 
uint32_t Random ()
 
uint32_t Random (uint32_t iRange)
 
uint32_t UnsyncedRandom ()
 
uint32_t UnsyncedRandom (uint32_t iRange)
 
uint32_t SeededRandom (uint64_t iSeed, uint32_t iRange)
 

Variables

int RandomCount = 0
 

Function Documentation

void FixedRandom ( uint64_t  seed)

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 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:

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  iRange)

Definition at line 63 of file C4Random.cpp.

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

Variable Documentation

int RandomCount = 0

Definition at line 27 of file C4Random.cpp.

Referenced by FixedRandom(), and RecordRandom().