10 #include "../stdafx.h" 15 #include "../network/network.h" 16 #include "../network/network_server.h" 17 #include "../network/network_internal.h" 18 #include "../company_func.h" 19 #include "../fileio_func.h" 20 #include "../date_func.h" 23 #include "../safeguards.h" 33 const uint32 s = this->
state[0];
34 const uint32 t = this->
state[1];
36 this->
state[0] = s +
ROR(t ^ 0x1234567F, 7) + 1;
37 return this->
state[1] =
ROR(s, 3) - 1;
48 return ((uint64)this->
Next() * (uint64)limit) >> 32;
57 this->
state[0] = seed;
58 this->
state[1] = seed;
68 _interactive_random.
SetSeed(seed * 0x1234567);
72 uint32 DoRandom(
int line,
const char *file)
74 if (
_networking && (!
_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
78 return _random.
Next();
81 uint32 DoRandomRange(uint32 limit,
int line,
const char *file)
83 return ((uint64)DoRandom(line, file) * (uint64)limit) >> 32;
bool _networking
are we in networking mode?
void SetRandomSeed(uint32 seed)
(Re)set the state of the random number generators.
Functions related to bit mathematics.
Pseudo random number generator.
DateFract _date_fract
Fractional part of the day.
Randomizer _interactive_random
Random used everywhere else, where it does not (directly) influence the game state.
void SetSeed(uint32 seed)
(Re)set the state of the random number generator.
static T ROR(const T x, const uint8 n)
ROtate x Right by n.
#define DEBUG(name, level,...)
Output a line of debugging information.
uint32 _frame_counter
The current frame.
Randomizer _random
Random used in the game state calculations.
uint32 Next()
Generate the next pseudo random number.
bool _network_server
network-server is active
CompanyID _current_company
Company currently doing an action.
uint32 state[2]
The state of the randomizer.
Structure to encapsulate the pseudo random number generators.
Date _date
Current date in days (day counter)