OpenClonk
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

◆ FixedRandom()

void FixedRandom ( uint64_t  seed)

Definition at line 37 of file C4Random.cpp.

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

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

Here is the caller graph for this function:

◆ Random() [1/2]

◆ Random() [2/2]

uint32_t Random ( uint32_t  iRange)

Definition at line 50 of file C4Random.cpp.

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

◆ SeededRandom()

uint32_t SeededRandom ( uint64_t  iSeed,
uint32_t  iRange 
)

Definition at line 69 of file C4Random.cpp.

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

Referenced by C4Sky::Init().

Here is the caller graph for this function:

◆ UnsyncedRandom() [1/2]

◆ UnsyncedRandom() [2/2]

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

◆ RandomCount

int RandomCount = 0

Definition at line 27 of file C4Random.cpp.

Referenced by RecordRandom().