aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cge2/cge2.cpp2
-rw-r--r--engines/cge2/cge2.h4
-rw-r--r--engines/cge2/cge2_main.cpp7
3 files changed, 12 insertions, 1 deletions
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp
index 8d7f58fb44..bd93ed22e1 100644
--- a/engines/cge2/cge2.cpp
+++ b/engines/cge2/cge2.cpp
@@ -39,7 +39,7 @@
namespace CGE2 {
CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
- : Engine(syst), _gameDescription(gameDescription) {
+ : Engine(syst), _gameDescription(gameDescription), _randomSource("cge") {
_resman = nullptr;
_vga = nullptr;
_sprite = nullptr;
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index fa161f360a..bbd709094e 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -28,6 +28,7 @@
#ifndef CGE2_H
#define CGE2_H
+#include "common/random.h"
#include "engines/engine.h"
#include "engines/advancedDetector.h"
#include "common/system.h"
@@ -85,6 +86,7 @@ public:
void caveUp(int cav);
void showBak(int ref);
void loadTab();
+ int newRandom(int range);
void setEye(V3D &e);
void setEye(const V2D& e2, int z = -kScrWidth);
@@ -98,6 +100,8 @@ public:
const ADGameDescription *_gameDescription;
+ Common::RandomSource _randomSource;
+
bool _quitFlag;
Dac *_bitmapPalette;
int _mode;
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index 9ee9459cca..6d59cc88a4 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -413,4 +413,11 @@ void CGE2Engine::setEye(const char *s) {
_eye->_z = atoi(token(NULL));
}
+int CGE2Engine::newRandom(int range) {
+ if (!range)
+ return 0;
+
+ return _randomSource.getRandomNumber(range - 1);
+}
+
} // End of namespace CGE2