aboutsummaryrefslogtreecommitdiff
path: root/common/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/util.cpp')
-rw-r--r--common/util.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/util.cpp b/common/util.cpp
index 82a910f9a8..1f48a6ddd9 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -196,6 +196,12 @@ uint RandomSource::getRandomNumber(uint max) {
return _randSeed % (max + 1);
}
+uint RandomSource::getRandomBit(void) {
+ _randSeed = 0xDEADBF03 * (_randSeed + 1);
+ _randSeed = (_randSeed >> 13) | (_randSeed << 19);
+ return _randSeed & 1;
+}
+
uint RandomSource::getRandomNumberRng(uint min, uint max) {
return getRandomNumber(max - min) + min;
}