Files
@ r10346:abb5a49d7f1a
Branch filter:
Location: cpp/openttd-patchpack/source/src/core/random_func.cpp - annotation
r10346:abb5a49d7f1a
1.2 KiB
text/x-c
(svn r14597) -Update: WebTranslator2 update to 2008-11-19 18:43:03
afrikaans - 165 fixed, 227 changed by nubllett (156), burgerd (236)
dutch - 2 fixed, 5 changed by Excel20 (7)
french - 2 fixed by glx (2)
german - 6 fixed, 2 changed by jonathan159 (2), MaSch (6)
hungarian - 1 fixed, 20 changed by oklmernok (21)
macedonian - 90 fixed by sashozs (90)
serbian - 560 fixed by AtzaMan (560)
slovak - 1 fixed by James (1)
spanish - 1 fixed by eusebio (1)
afrikaans - 165 fixed, 227 changed by nubllett (156), burgerd (236)
dutch - 2 fixed, 5 changed by Excel20 (7)
french - 2 fixed by glx (2)
german - 6 fixed, 2 changed by jonathan159 (2), MaSch (6)
hungarian - 1 fixed, 20 changed by oklmernok (21)
macedonian - 90 fixed by sashozs (90)
serbian - 560 fixed by AtzaMan (560)
slovak - 1 fixed by James (1)
spanish - 1 fixed by eusebio (1)
r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r9111:983de9c5a848 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r8113:7815c26d7612 r7935:d51ba3fb01a8 r8434:4d5d2dc41ce0 r8142:8414f11ec81b r8434:4d5d2dc41ce0 r7935:d51ba3fb01a8 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r7935:d51ba3fb01a8 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r8434:4d5d2dc41ce0 r7935:d51ba3fb01a8 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r10255:0578669dfff6 r8477:5efae99a3878 r10208:ef8fcc3dc4ca r8477:5efae99a3878 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r8434:4d5d2dc41ce0 r10207:a1fc2f2a33db r8434:4d5d2dc41ce0 r8434:4d5d2dc41ce0 r8477:5efae99a3878 r8434:4d5d2dc41ce0 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r7935:d51ba3fb01a8 r8792:db826506a415 | /* $Id$ */
/** @file random_func.cpp Implementation of the pseudo random generator. */
#include "../stdafx.h"
#include "random_func.hpp"
#include "bitmath_func.hpp"
Randomizer _random, _interactive_random;
uint32 Randomizer::Next()
{
const uint32 s = this->state[0];
const uint32 t = this->state[1];
this->state[0] = s + ROR(t ^ 0x1234567F, 7) + 1;
return this->state[1] = ROR(s, 3) - 1;
}
uint32 Randomizer::Next(uint16 max)
{
return GB(this->Next(), 0, 16) * max >> 16;
}
void Randomizer::SetSeed(uint32 seed)
{
this->state[0] = seed;
this->state[1] = seed;
}
void SetRandomSeed(uint32 seed)
{
_random.SetSeed(seed);
_interactive_random.SetSeed(seed * 0x1234567);
}
#ifdef RANDOM_DEBUG
#include "../network/network_internal.h"
#include "../variables.h" /* _frame_counter */
#include "../company_func.h"
uint32 DoRandom(int line, const char *file)
{
if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server)) {
printf("Random [%d/%d] %s:%d\n",_frame_counter, (byte)_current_company, file, line);
}
return _random.Next();
}
uint DoRandomRange(uint max, int line, const char *file)
{
return GB(DoRandom(line, file), 0, 16) * max >> 16;
}
#endif /* RANDOM_DEBUG */
|