From d1652922340abbc852ab1c52125cf1a4c559a231 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 17 May 2011 12:10:05 +0200 Subject: COMMON: Remove unused RandomSource destructor, clarify comments, cleanup --- common/random.cpp | 9 +++------ common/random.h | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/common/random.cpp b/common/random.cpp index 9ecd5d0892..55fa3cbd30 100644 --- a/common/random.cpp +++ b/common/random.cpp @@ -33,15 +33,12 @@ RandomSource::RandomSource(const String &name) { uint32 seed = g_system->getMillis(); setSeed(seed); - // Register this random source with the event recorder. This might - // reset the seed, so call it *after* the initial seed has been set. + // Register this random source with the event recorder. This may end + // up querying or resetting the current seed, so we must call it + // *after* the initial seed has been set. g_eventRec.registerRandomSource(*this, name); } -RandomSource::~RandomSource() { - // TODO: Unregister with g_eventRec -} - void RandomSource::setSeed(uint32 seed) { _randSeed = seed; } diff --git a/common/random.h b/common/random.h index ea590f4135..90f2ed5cb0 100644 --- a/common/random.h +++ b/common/random.h @@ -45,11 +45,9 @@ public: */ RandomSource(const String &name); - ~RandomSource(); - void setSeed(uint32 seed); - uint32 getSeed() { + uint32 getSeed() const { return _randSeed; } @@ -59,12 +57,14 @@ public: * @return a random number in the interval [0, max] */ uint getRandomNumber(uint max); + /** * Generates a random bit, i.e. either 0 or 1. - * Identical to getRandomNumber(1), but faster, hopefully. + * Identical to getRandomNumber(1), but potentially faster. * @return a random bit, either 0 or 1 */ uint getRandomBit(); + /** * Generates a random unsigned integer in the interval [min, max]. * @param min the lower bound -- cgit v1.2.3