aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lure/fights.cpp2
-rw-r--r--engines/lure/fights.h2
-rw-r--r--engines/lure/hotspots.cpp19
-rw-r--r--engines/lure/lure.cpp2
-rw-r--r--engines/lure/lure.h5
-rw-r--r--engines/lure/res.cpp4
-rw-r--r--engines/lure/res.h2
-rw-r--r--engines/lure/scripts.cpp4
-rw-r--r--engines/lure/surface.cpp6
-rw-r--r--engines/lure/surface.h1
10 files changed, 20 insertions, 27 deletions
diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp
index 6ff7339c02..4a67c3df66 100644
--- a/engines/lure/fights.cpp
+++ b/engines/lure/fights.cpp
@@ -40,7 +40,7 @@ const FighterRecord initialFighterList[3] = {
FightsManager *int_fights = NULL;
-FightsManager::FightsManager() {
+FightsManager::FightsManager() : _rnd(LureEngine::getReference().rnd()) {
int_fights = this;
_fightData = NULL;
_mouseFlags = 0;
diff --git a/engines/lure/fights.h b/engines/lure/fights.h
index 4490c7cce7..24d687d550 100644
--- a/engines/lure/fights.h
+++ b/engines/lure/fights.h
@@ -66,7 +66,7 @@ enum KeyStatus {KS_UP, KS_KEYDOWN_1, KS_KEYDOWN_2};
class FightsManager {
private:
MemoryBlock *_fightData;
- Common::RandomSource _rnd;
+ Common::RandomSource &_rnd;
uint8 _mouseFlags;
KeyStatus _keyDown;
FighterRecord _fighterList[3];
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index b5ec00fdf9..b7d7593a6f 100644
--- a/engines/lure/hotspots.cpp
+++ b/engines/lure/hotspots.cpp
@@ -38,7 +38,6 @@
#include "lure/sound.h"
#include "lure/lure.h"
#include "common/endian.h"
-#include "common/EventRecorder.h"
namespace Lure {
@@ -598,11 +597,9 @@ void Hotspot::setRandomDest() {
Resources &res = Resources::getReference();
RoomData *roomData = res.getRoom(roomNumber());
Common::Rect &rect = roomData->walkBounds;
- Common::RandomSource rnd;
+ Common::RandomSource &rnd = LureEngine::getReference().rnd();
int16 xp, yp;
- g_eventRec.registerRandomSource(rnd, "lureHotspots");
-
if (currentActions().isEmpty())
currentActions().addFront(START_WALKING, roomNumber());
else
@@ -3145,10 +3142,9 @@ void HotspotTickHandlers::followerAnimHandler(Hotspot &h) {
return;
}
- Common::RandomSource rnd;
+ Common::RandomSource &rnd = LureEngine::getReference().rnd();
RandomActionType actionType;
uint16 scheduleId;
- g_eventRec.registerRandomSource(rnd, "lureHotspots");
int actionIndex = rnd.getRandomNumber(set->numActions() - 1);
set->getEntry(actionIndex, actionType, scheduleId);
@@ -3336,9 +3332,7 @@ void HotspotTickHandlers::goewinCaptiveAnimHandler(Hotspot &h) {
void HotspotTickHandlers::prisonerAnimHandler(Hotspot &h) {
ValueTableData &fields = Resources::getReference().fieldList();
- Common::RandomSource rnd;
-
- g_eventRec.registerRandomSource(rnd, "lureHotspots");
+ Common::RandomSource &rnd = LureEngine::getReference().rnd();
h.handleTalkDialog();
if (h.frameCtr() > 0) {
@@ -3380,8 +3374,7 @@ void HotspotTickHandlers::morkusAnimHandler(Hotspot &h) {
if (h.executeScript()) {
// Script is done - set new script to one of two alternates randomly
- Common::RandomSource rnd;
- g_eventRec.registerRandomSource(rnd, "lureHotspots");
+ Common::RandomSource &rnd = LureEngine::getReference().rnd();
h.setHotspotScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
h.setFrameCtr(20 + rnd.getRandomNumber(63));
@@ -3678,11 +3671,9 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
Resources &res = Resources::getReference();
Room &room = Room::getReference();
BarEntry &barEntry = res.barmanLists().getDetails(h.roomNumber());
- Common::RandomSource rnd;
+ Common::RandomSource &rnd = LureEngine::getReference().rnd();
static bool ewanXOffset = false;
- g_eventRec.registerRandomSource(rnd, "lureHotspots");
-
h.handleTalkDialog();
if (h.delayCtr() > 0) {
h.setDelayCtr(h.delayCtr() - 1);
diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp
index 32d739ecf1..8640ed2d24 100644
--- a/engines/lure/lure.cpp
+++ b/engines/lure/lure.cpp
@@ -26,6 +26,7 @@
#include "common/config-manager.h"
#include "common/system.h"
#include "common/savefile.h"
+#include "common/EventRecorder.h"
#include "lure/luredefs.h"
#include "lure/surface.h"
@@ -39,6 +40,7 @@ namespace Lure {
static LureEngine *int_engine = NULL;
LureEngine::LureEngine(OSystem *system, const LureGameDescription *gameDesc): Engine(system), _gameDescription(gameDesc) {
+ g_eventRec.registerRandomSource(_rnd, "lure");
Common::addDebugChannel(kLureDebugScripts, "scripts", "Scripts debugging");
Common::addDebugChannel(kLureDebugAnimations, "animations", "Animations debugging");
diff --git a/engines/lure/lure.h b/engines/lure/lure.h
index e8f1a7c1e1..965efbd5c4 100644
--- a/engines/lure/lure.h
+++ b/engines/lure/lure.h
@@ -31,6 +31,7 @@
#include "sound/mixer.h"
#include "common/file.h"
#include "common/savefile.h"
+#include "common/util.h"
#include "lure/disk.h"
#include "lure/res.h"
@@ -43,6 +44,8 @@
namespace Lure {
+#define RandomNumberGen LureEngine::getReference().rnd()
+
struct LureGameDescription;
class LureEngine : public Engine {
@@ -59,6 +62,7 @@ private:
StringData *_strings;
Room *_room;
FightsManager *_fights;
+ Common::RandomSource _rnd;
const char *generateSaveName(int slotNumber);
@@ -86,6 +90,7 @@ public:
Disk &disk() { return *_disk; }
+ Common::RandomSource &rnd() { return _rnd; }
int gameToLoad() { return _gameToLoad; }
bool loadGame(uint8 slotNumber);
bool saveGame(uint8 slotNumber, Common::String &caption);
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp
index e921b93384..c3683fe6a7 100644
--- a/engines/lure/res.cpp
+++ b/engines/lure/res.cpp
@@ -30,7 +30,6 @@
#include "lure/lure.h"
#include "common/endian.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
namespace Lure {
@@ -42,8 +41,7 @@ Resources &Resources::getReference() {
return *int_resources;
}
-Resources::Resources() {
- g_eventRec.registerRandomSource(_rnd, "lureResources");
+Resources::Resources() : _rnd(LureEngine::getReference().rnd()) {
int_resources = this;
reloadData();
diff --git a/engines/lure/res.h b/engines/lure/res.h
index 8e54135868..6b55cb5da1 100644
--- a/engines/lure/res.h
+++ b/engines/lure/res.h
@@ -51,7 +51,7 @@ struct TalkDialogDetails {
class Resources {
private:
- Common::RandomSource _rnd;
+ Common::RandomSource &_rnd;
Palette *_paletteSubset;
MemoryBlock *_cursors;
RoomDataList _roomData;
diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp
index f9d854a73b..9e13a0d871 100644
--- a/engines/lure/scripts.cpp
+++ b/engines/lure/scripts.cpp
@@ -739,9 +739,7 @@ void Script::addActions(uint16 hotspotId, uint16 actions, uint16 v3) {
// Generates a random number and stores it in the general field
void Script::randomToGeneral(uint16 maxVal, uint16 minVal, uint16 v3) {
- Common::RandomSource rnd;
- g_eventRec.registerRandomSource(rnd, "lureScripts");
- uint16 v = minVal + rnd.getRandomNumber(maxVal - minVal);
+ uint16 v = minVal + LureEngine::getReference().rnd().getRandomNumber(maxVal - minVal);
Resources::getReference().fieldList().setField(GENERAL, v);
}
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index 01746f39d5..84930661ad 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -1299,7 +1299,6 @@ CopyProtectionDialog::CopyProtectionDialog() {
bool CopyProtectionDialog::show() {
Screen &screen = Screen::getReference();
Events &events = Events::getReference();
- Common::RandomSource rnd;
LureEngine &engine = LureEngine::getReference();
screen.setPaletteEmpty();
@@ -1403,8 +1402,9 @@ bool CopyProtectionDialog::show() {
void CopyProtectionDialog::chooseCharacters() {
Screen &screen = Screen::getReference();
- int char1 = _rnd.getRandomNumber(19);
- int char2 = _rnd.getRandomNumber(19);
+ Common::RandomSource &rnd = LureEngine::getReference().rnd();
+ int char1 = rnd.getRandomNumber(19);
+ int char2 = rnd.getRandomNumber(19);
HotspotsList::iterator curHotspot = _hotspots.begin();
(curHotspot->get())->setFrameNumber(char1);
diff --git a/engines/lure/surface.h b/engines/lure/surface.h
index 49208fa057..7e66f6aae9 100644
--- a/engines/lure/surface.h
+++ b/engines/lure/surface.h
@@ -140,7 +140,6 @@ public:
class CopyProtectionDialog {
private:
- Common::RandomSource _rnd;
typedef Common::List<Common::SharedPtr<Hotspot> > HotspotsList;
HotspotsList _hotspots;
int _charIndex;