aboutsummaryrefslogtreecommitdiff
path: root/common/random.h
diff options
context:
space:
mode:
authorMatthew Hoops2011-05-31 14:16:29 -0400
committerMatthew Hoops2011-05-31 14:16:29 -0400
commitaa49b38c5a8032586cb94fc4ca07149eecabe64a (patch)
treeea5c7617f8c482c8cf4141b728b3ccff5a7f84c7 /common/random.h
parentd3ea9ab2a9334747eb445c1b45aa30cb17ffdf1b (diff)
parentc86a6c466fabe31fbf36363aa8d0ac8ea6001b9f (diff)
downloadscummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.gz
scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.bz2
scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.zip
Merge remote branch 'upstream/master' into t7g-ios
Conflicts: engines/groovie/script.cpp
Diffstat (limited to 'common/random.h')
-rw-r--r--common/random.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/common/random.h b/common/random.h
index 8fc5c4cf7d..90f2ed5cb0 100644
--- a/common/random.h
+++ b/common/random.h
@@ -17,9 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
*/
#ifndef COMMON_RANDOM_H
@@ -29,6 +26,8 @@
namespace Common {
+class String;
+
/**
* Simple random number generator. Although it is definitely not suitable for
* cryptographic purposes, it serves our purposes just fine.
@@ -38,10 +37,17 @@ private:
uint32 _randSeed;
public:
- RandomSource();
+ /**
+ * Construct a new randomness source with the specific name.
+ * The name used name must be globally unique, and is used to
+ * register the randomness source with the active event recorder,
+ * if any.
+ */
+ RandomSource(const String &name);
+
void setSeed(uint32 seed);
- uint32 getSeed() {
+ uint32 getSeed() const {
return _randSeed;
}
@@ -51,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