12 #include "../stdafx.h" 17 #include "../network/network.h" 18 #include "../network/network_server.h" 19 #include "../network/network_internal.h" 20 #include "../company_func.h" 21 #include "../fileio_func.h" 22 #include "../date_func.h" 25 #include "../safeguards.h" 35 const uint32 s = this->
state[0];
36 const uint32 t = this->
state[1];
38 this->
state[0] = s +
ROR(t ^ 0x1234567F, 7) + 1;
39 return this->
state[1] =
ROR(s, 3) - 1;
50 return ((uint64)this->
Next() * (uint64)limit) >> 32;
59 this->
state[0] = seed;
60 this->
state[1] = seed;
70 _interactive_random.
SetSeed(seed * 0x1234567);
74 uint32 DoRandom(
int line,
const char *file)
76 if (
_networking && (!
_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
80 return _random.
Next();
83 uint32 DoRandomRange(uint32 limit,
int line,
const char *file)
85 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 every else where is 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.
CompanyByte _current_company
Company currently doing an action.
Randomizer _random
Random used in the game state calculations.
uint32 Next()
Generate the next pseudo random number.
bool _network_server
network-server is active
uint32 state[2]
The state of the randomizer.
Structure to encapsulate the pseudo random number generators.
Date _date
Current date in days (day counter)