diff options
author | rubidium <rubidium@openttd.org> | 2011-01-22 09:53:15 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-01-22 09:53:15 +0000 |
commit | eb299736c1bcb277da1862afe95c11cb897effcf (patch) | |
tree | 3bb6bff78f066da770a367e078c569dbe8ce319a /src/core/random_func.cpp | |
parent | 0cdb1c78cdbfce4d426441c21ef7066f1cfecf6f (diff) | |
download | openttd-eb299736c1bcb277da1862afe95c11cb897effcf.tar.xz |
(svn r21886) -Codechange: move documentation towards the code to make it more likely to be updated [n].
Diffstat (limited to 'src/core/random_func.cpp')
-rw-r--r-- | src/core/random_func.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/random_func.cpp b/src/core/random_func.cpp index 1c5b0fae2..042d137ff 100644 --- a/src/core/random_func.cpp +++ b/src/core/random_func.cpp @@ -15,6 +15,10 @@ Randomizer _random, _interactive_random; +/** + * Generate the next pseudo random number + * @return the random number + */ uint32 Randomizer::Next() { const uint32 s = this->state[0]; @@ -24,17 +28,30 @@ uint32 Randomizer::Next() return this->state[1] = ROR(s, 3) - 1; } +/** + * Generate the next pseudo random number scaled to max + * @param max the maximum value of the returned random number + * @return the random number + */ uint32 Randomizer::Next(uint32 max) { return ((uint64)this->Next() * (uint64)max) >> 32; } +/** + * (Re)set the state of the random number generator. + * @param seed the new state + */ void Randomizer::SetSeed(uint32 seed) { this->state[0] = seed; this->state[1] = seed; } +/** + * (Re)set the state of the random number generators. + * @param seed the new state + */ void SetRandomSeed(uint32 seed) { _random.SetSeed(seed); |