aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2011-05-17 12:10:05 +0200
committerMax Horn2011-05-17 12:23:41 +0200
commitd1652922340abbc852ab1c52125cf1a4c559a231 (patch)
tree3f64b9a4f2ead3eac9957a13667deca92ae9b909
parentfc9b8d2a71cee8ad27aa8e390b378c0e46307bd2 (diff)
downloadscummvm-rg350-d1652922340abbc852ab1c52125cf1a4c559a231.tar.gz
scummvm-rg350-d1652922340abbc852ab1c52125cf1a4c559a231.tar.bz2
scummvm-rg350-d1652922340abbc852ab1c52125cf1a4c559a231.zip
COMMON: Remove unused RandomSource destructor, clarify comments, cleanup
-rw-r--r--common/random.cpp9
-rw-r--r--common/random.h8
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