OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
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;
72 uint32 DoRandom(
int line,
const char *file)
74 if (
_networking && (!
_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
81 uint32 DoRandomRange(uint32 limit,
int line,
const char *file)
83 return ((uint64)DoRandom(line, file) * (uint64)limit) >> 32;
uint32 _frame_counter
The current frame.
uint32 Next()
Generate the next pseudo random number.
DateFract _date_fract
Fractional part of the day.
bool _network_server
network-server is active
Randomizer _random
Random used in the game state calculations.
Randomizer _interactive_random
Random used everywhere else, where it does not (directly) influence the game state.
Date _date
Current date in days (day counter)
#define DEBUG(name, level,...)
Output a line of debugging information.
bool _networking
are we in networking mode?
uint32 state[2]
The state of the randomizer.
CompanyID _current_company
Company currently doing an action.
void SetRandomSeed(uint32 seed)
(Re)set the state of the random number generators.
Structure to encapsulate the pseudo random number generators.
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.