aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp1
-rw-r--r--engines/agos/agos.cpp3
-rw-r--r--engines/cine/cine.cpp4
-rw-r--r--engines/cine/cine.h2
-rw-r--r--engines/cine/script.cpp2
-rw-r--r--engines/cine/various.cpp2
-rw-r--r--engines/cruise/cruise.cpp7
-rw-r--r--engines/cruise/cruise.h16
-rw-r--r--engines/cruise/function.cpp3
-rw-r--r--engines/drascula/drascula.cpp1
-rw-r--r--engines/gob/gob.cpp3
-rw-r--r--engines/kyra/kyra.cpp2
-rw-r--r--engines/kyra/sprites.cpp2
-rw-r--r--engines/lure/hotspots.cpp10
-rw-r--r--engines/lure/res.cpp2
-rw-r--r--engines/lure/scripts.cpp1
-rw-r--r--engines/parallaction/objects.cpp3
-rw-r--r--engines/parallaction/parallaction.cpp2
-rw-r--r--engines/parallaction/parallaction.h1
-rw-r--r--engines/queen/display.cpp2
-rw-r--r--engines/queen/music.cpp2
-rw-r--r--engines/queen/queen.cpp2
-rw-r--r--engines/saga/saga.cpp2
-rw-r--r--engines/scumm/scumm.cpp2
-rw-r--r--engines/sky/logic.cpp3
-rw-r--r--engines/sword1/logic.cpp4
-rw-r--r--engines/sword1/sound.cpp2
-rw-r--r--engines/sword2/sword2.cpp1
-rw-r--r--engines/touche/touche.cpp2
29 files changed, 74 insertions, 15 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index da70d82b57..d78a2dc587 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -623,6 +623,7 @@ AgiEngine::AgiEngine(OSystem *syst) : AgiBase(syst) {
_gameId = g->id;
_rnd = new Common::RandomSource();
+ syst->getEventManager()->registerRandomSource(*_rnd, "agi");
Common::addSpecialDebugLevel(kDebugLevelMain, "Main", "Generic debug level");
Common::addSpecialDebugLevel(kDebugLevelResources, "Resources", "Resources debugging");
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index 3b5bb3e50b..09249a2535 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -28,6 +28,7 @@
#include "common/config-manager.h"
#include "common/file.h"
#include "common/system.h"
+#include "common/events.h"
#include "agos/debugger.h"
#include "agos/intern.h"
@@ -519,6 +520,8 @@ AGOSEngine::AGOSEngine(OSystem *syst)
File::addDefaultDirectory(_gameDataPath + "SFX");
File::addDefaultDirectory(_gameDataPath + "speech");
File::addDefaultDirectory(_gameDataPath + "SPEECH");
+
+ syst->getEventManager()->registerRandomSource(_rnd, "agos");
}
int AGOSEngine::init() {
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index 31c092987b..70be3e821d 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -23,7 +23,7 @@
*
*/
-
+#include "common/events.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/config-manager.h"
@@ -62,6 +62,8 @@ CineEngine::CineEngine(OSystem *syst) : Engine(syst) {
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
g_cine = this;
+
+ syst->getEventManager()->registerRandomSource(_rnd, "cine");
}
CineEngine::~CineEngine() {
diff --git a/engines/cine/cine.h b/engines/cine/cine.h
index 209fb926ea..026fb3e54c 100644
--- a/engines/cine/cine.h
+++ b/engines/cine/cine.h
@@ -85,6 +85,8 @@ public:
const CINEGameDescription *_gameDescription;
Common::File _partFileHandle;
+ Common::RandomSource _rnd;
+
private:
void initialize(void);
bool makeLoad(char *saveName);
diff --git a/engines/cine/script.cpp b/engines/cine/script.cpp
index 3b469eda60..813eb0c376 100644
--- a/engines/cine/script.cpp
+++ b/engines/cine/script.cpp
@@ -909,7 +909,7 @@ void o1_loadVar() {
break;
case 5:
debugC(5, kCineDebugScript, "Line: %d: var[%d] = rand mod %d", _currentLine, varIdx, dataIdx);
- _currentScriptElement->localVars[varIdx] = rand() % dataIdx;
+ _currentScriptElement->localVars[varIdx] = g_cine->_rnd.getRandomNumber(dataIdx - 1);
break;
case 8:
debugC(5, kCineDebugScript, "Line: %d: var[%d] = file[%d].packedSize", _currentLine, varIdx, dataIdx);
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index e8b59266db..378437babf 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -2355,7 +2355,7 @@ void drawFailureMessage(byte cmd) {
int16 localY;
int16 localWidth;
- byte msgIdx = cmd * 4 + rand() % 4;
+ byte msgIdx = cmd * 4 + g_cine->_rnd.getRandomNumber(3);
const char *messagePtr = failureMessages[msgIdx];
int len = strlen(messagePtr);
diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp
index 4358ac0e17..2ea94e79eb 100644
--- a/engines/cruise/cruise.cpp
+++ b/engines/cruise/cruise.cpp
@@ -23,7 +23,7 @@
*
*/
-
+#include "common/events.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/config-manager.h"
@@ -64,6 +64,8 @@ CruiseEngine::CruiseEngine(OSystem * syst) : Engine(syst) {
ConfMan.getInt("music_volume"));
g_cruise = this;
+
+ syst->getEventManager()->registerRandomSource(_rnd, "cruise");
}
CruiseEngine::~CruiseEngine() {
@@ -75,8 +77,7 @@ CruiseEngine::~CruiseEngine() {
int CruiseEngine::init() {
// Detect game
if (!initGame()) {
- GUIErrorMessage
- ("No valid games were found in the specified directory.");
+ GUIErrorMessage ("No valid games were found in the specified directory.");
return -1;
}
// Initialize backend
diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h
index 515238d264..d99860d254 100644
--- a/engines/cruise/cruise.h
+++ b/engines/cruise/cruise.h
@@ -43,28 +43,30 @@ struct CRUISEGameDescription;
class CruiseEngine:public Engine {
- protected:
+protected:
int init();
int go();
void shutdown();
bool initGame();
- public:
- CruiseEngine(OSystem * syst);
- virtual ~ CruiseEngine();
+public:
+ CruiseEngine(OSystem * syst);
+ virtual ~ CruiseEngine();
int getGameType() const;
uint32 getFeatures() const;
- Common::Language getLanguage() const;
- Common::Platform getPlatform() const;
+ Common::Language getLanguage() const;
+ Common::Platform getPlatform() const;
bool loadSaveDirectory(void);
void makeSystemMenu(void);
const CRUISEGameDescription *_gameDescription;
- private:
+ Common::RandomSource _rnd;
+
+private:
void initialize(void);
bool makeLoad(char *saveName);
void mainLoop(int bootScriptIdx);
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index 6a6f65a066..2614d30172 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -23,6 +23,7 @@
*
*/
+#include "cruise/cruise.h"
#include "cruise/cruise_main.h"
#include "cruise/cell.h"
#include "common/util.h"
@@ -193,7 +194,7 @@ int16 Op_rand(void) { // TODO: implement
return (0);
}
- return (rand() % var);
+ return (g_cruise->_rnd.getRandomNumber(var - 1));
}
int16 Op_PlayFX(void) { // TODO: implement
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 5f5b2cb525..eb7e33d17e 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -71,6 +71,7 @@ DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) {
_gameId = g->id;
_rnd = new Common::RandomSource();
+ syst->getEventManager()->registerRandomSource(*_rnd, "drascula");
int cd_num = ConfMan.getInt("cdrom");
if (cd_num >= 0)
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index 80eeeb6d3f..13f310aee0 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -25,6 +25,7 @@
#include "common/endian.h"
+#include "common/events.h"
#include "base/plugins.h"
#include "common/config-manager.h"
@@ -98,6 +99,8 @@ GobEngine::GobEngine(OSystem *syst) : Engine(syst) {
Common::addSpecialDebugLevel(kDebugFileIO, "FileIO", "File Input/Output debug level");
Common::addSpecialDebugLevel(kDebugGraphics, "Graphics", "Graphics debug level");
Common::addSpecialDebugLevel(kDebugCollisions, "Collisions", "Collisions debug level");
+
+ syst->getEventManager()->registerRandomSource(_rnd, "gob");
}
GobEngine::~GobEngine() {
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index 6fdeaac2a6..8797038ca6 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -71,6 +71,8 @@ KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags)
Common::addSpecialDebugLevel(kDebugLevelSequence, "Sequence", "Sequence debug level");
Common::addSpecialDebugLevel(kDebugLevelMovie, "Movie", "Movie debug level");
Common::addSpecialDebugLevel(kDebugLevelTimer, "Timer", "Timer debug level");
+
+ system->getEventManager()->registerRandomSource(_rnd, "kyra");
}
int KyraEngine::init() {
diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp
index be1fd2df7e..ad513d80f4 100644
--- a/engines/kyra/sprites.cpp
+++ b/engines/kyra/sprites.cpp
@@ -28,6 +28,7 @@
#include "common/stream.h"
#include "common/util.h"
#include "common/system.h"
+#include "common/events.h"
#include "kyra/screen.h"
#include "kyra/kyra_v1.h"
#include "kyra/sprites.h"
@@ -47,6 +48,7 @@ Sprites::Sprites(KyraEngine_v1 *vm, OSystem *system) {
_spriteDefStart = 0;
memset(_drawLayerTable, 0, sizeof(_drawLayerTable));
_sceneAnimatorBeaconFlag = 0;
+ system->getEventManager()->registerRandomSource(_rnd, "kyraSprites");
}
Sprites::~Sprites() {
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index 93860bbd3e..f3235dd3d9 100644
--- a/engines/lure/hotspots.cpp
+++ b/engines/lure/hotspots.cpp
@@ -588,6 +588,8 @@ void Hotspot::setRandomDest() {
Common::RandomSource rnd;
int16 xp, yp;
+ g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+
if (_currentActions.isEmpty())
_currentActions.addFront(START_WALKING, roomNumber());
else
@@ -2925,6 +2927,8 @@ void HotspotTickHandlers::followerAnimHandler(Hotspot &h) {
Common::RandomSource rnd;
RandomActionType actionType;
uint16 scheduleId;
+ g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+
int actionIndex = rnd.getRandomNumber(set->numActions() - 1);
set->getEntry(actionIndex, actionType, scheduleId);
@@ -3113,6 +3117,8 @@ void HotspotTickHandlers::prisonerAnimHandler(Hotspot &h) {
ValueTableData &fields = Resources::getReference().fieldList();
Common::RandomSource rnd;
+ g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+
h.handleTalkDialog();
if (h.frameCtr() > 0) {
h.setFrameCtr(h.frameCtr() - 1);
@@ -3153,6 +3159,8 @@ void HotspotTickHandlers::morkusAnimHandler(Hotspot &h) {
if (h.executeScript()) {
// Script is done - set new script to one of two alternates randomly
Common::RandomSource rnd;
+ g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+
h.setHotspotScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
h.setFrameCtr(20 + rnd.getRandomNumber(63));
}
@@ -3417,6 +3425,8 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
Common::RandomSource rnd;
static bool ewanXOffset = false;
+ g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+
h.handleTalkDialog();
if (h.delayCtr() > 0) {
h.setDelayCtr(h.delayCtr() - 1);
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp
index b0e99b5be5..983afb7357 100644
--- a/engines/lure/res.cpp
+++ b/engines/lure/res.cpp
@@ -28,6 +28,7 @@
#include "lure/scripts.h"
#include "lure/screen.h"
#include "common/endian.h"
+#include "common/events.h"
namespace Lure {
@@ -40,6 +41,7 @@ Resources &Resources::getReference() {
}
Resources::Resources() {
+ g_system->getEventManager()->registerRandomSource(_rnd, "lureResources");
int_resources = this;
reloadData();
diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp
index bba364bcf2..da1977f00e 100644
--- a/engines/lure/scripts.cpp
+++ b/engines/lure/scripts.cpp
@@ -704,6 +704,7 @@ void Script::addActions(uint16 hotspotId, uint16 actions, uint16 v3) {
void Script::randomToGeneral(uint16 maxVal, uint16 minVal, uint16 v3) {
Common::RandomSource rnd;
+ g_system->getEventManager()->registerRandomSource(rnd, "lureScripts");
uint16 v = minVal + rnd.getRandomNumber(maxVal - minVal);
Resources::getReference().fieldList().setField(GENERAL, v);
}
diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp
index 30ce5b77a9..283802ef45 100644
--- a/engines/parallaction/objects.cpp
+++ b/engines/parallaction/objects.cpp
@@ -23,6 +23,7 @@
*
*/
+#include "parallaction/parallaction.h"
#include "parallaction/objects.h"
#include "parallaction/parser.h"
@@ -287,7 +288,7 @@ int16 ScriptVar::getRValue() {
}
if (_flags & kParaRandom) {
- return (rand() * _value) / 32767;
+ return (_vm->_rnd.getRandomNumber(65536) * _value) / 32767;
}
error("Parameter is not an r-value");
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 22ebd51439..c1b64ad009 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -111,6 +111,8 @@ Parallaction::Parallaction(OSystem *syst) :
Common::addSpecialDebugLevel(kDebugInput, "input", "Input debug level");
Common::addSpecialDebugLevel(kDebugAudio, "audio", "Audio debug level");
Common::addSpecialDebugLevel(kDebugMenu, "menu", "Menu debug level");
+
+ syst->getEventManager()->registerRandomSource(_rnd, "parallaction");
}
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index c0975d4c85..6fc9477214 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -492,6 +492,7 @@ public:
Font *_menuFont;
Font *_dialogueFont;
+ Common::RandomSource _rnd;
protected: // data
diff --git a/engines/queen/display.cpp b/engines/queen/display.cpp
index 11b1bb9da7..50893f84b1 100644
--- a/engines/queen/display.cpp
+++ b/engines/queen/display.cpp
@@ -25,6 +25,7 @@
#include "common/system.h"
+#include "common/events.h"
#include "graphics/cursorman.h"
@@ -73,6 +74,7 @@ Display::Display(QueenEngine *vm, OSystem *system)
memset(&_dynalum, 0, sizeof(_dynalum));
setupInkColors();
+ system->getEventManager()->registerRandomSource(_rnd, "queenDisplay");
}
Display::~Display() {
diff --git a/engines/queen/music.cpp b/engines/queen/music.cpp
index e250a9b79c..e5255c1778 100644
--- a/engines/queen/music.cpp
+++ b/engines/queen/music.cpp
@@ -23,6 +23,7 @@
*
*/
+#include "common/events.h"
#include "queen/music.h"
#include "queen/queen.h"
@@ -48,6 +49,7 @@ MidiMusic::MidiMusic(MidiDriver *driver, QueenEngine *vm)
this->open();
_tune = vm->resource()->isDemo() ? Sound::_tuneDemo : Sound::_tune;
+ vm->_system->getEventManager()->registerRandomSource(_rnd, "queenMusic");
}
MidiMusic::~MidiMusic() {
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index b17b473947..423e1f13a3 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -32,6 +32,7 @@
#include "common/fs.h"
#include "common/savefile.h"
#include "common/system.h"
+#include "common/events.h"
#include "queen/queen.h"
#include "queen/bankman.h"
@@ -110,6 +111,7 @@ namespace Queen {
QueenEngine::QueenEngine(OSystem *syst)
: Engine(syst), _debugger(0) {
+ syst->getEventManager()->registerRandomSource(randomizer, "queen");
}
QueenEngine::~QueenEngine() {
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index c9f4bd4da8..9601eee44c 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -28,6 +28,7 @@
#include "common/file.h"
#include "common/config-manager.h"
#include "common/system.h"
+#include "common/events.h"
#include "sound/mixer.h"
@@ -113,6 +114,7 @@ SagaEngine::SagaEngine(OSystem *syst)
}
_displayClip.left = _displayClip.top = 0;
+ syst->getEventManager()->registerRandomSource(_rnd, "saga");
}
SagaEngine::~SagaEngine() {
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 7bcf3e243b..f0e0fd10b6 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -536,6 +536,8 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
// Add debug levels
for (int i = 0; i < ARRAYSIZE(debugChannels); ++i)
Common::addSpecialDebugLevel(debugChannels[i].flag, debugChannels[i].channel, debugChannels[i].desc);
+
+ syst->getEventManager()->registerRandomSource(_rnd, "scumm");
}
diff --git a/engines/sky/logic.cpp b/engines/sky/logic.cpp
index 6e5c92bfa3..773e64ae97 100644
--- a/engines/sky/logic.cpp
+++ b/engines/sky/logic.cpp
@@ -26,6 +26,7 @@
#include "common/endian.h"
#include "common/rect.h"
+#include "common/events.h"
#include "sky/autoroute.h"
#include "sky/compact.h"
@@ -71,6 +72,8 @@ void Logic::setupLogicTable() {
}
Logic::Logic(SkyCompact *skyCompact, Screen *skyScreen, Disk *skyDisk, Text *skyText, MusicBase *skyMusic, Mouse *skyMouse, Sound *skySound) {
+ g_system->getEventManager()->registerRandomSource(_rnd, "sky");
+
_skyCompact = skyCompact;
_skyScreen = skyScreen;
_skyDisk = skyDisk;
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index c761628128..891c2146b5 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -26,6 +26,8 @@
#include "common/endian.h"
#include "common/util.h"
+#include "common/system.h"
+#include "common/events.h"
#include "sword1/logic.h"
#include "sword1/text.h"
@@ -54,6 +56,8 @@ namespace Sword1 {
uint32 Logic::_scriptVars[NUM_SCRIPT_VARS];
Logic::Logic(ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer) {
+ g_system->getEventManager()->registerRandomSource(_rnd, "sword1");
+
_objMan = pObjMan;
_resMan = resMan;
_screen = pScreen;
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index 44394ee1d9..5108ed338e 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -27,6 +27,7 @@
#include "common/endian.h"
#include "common/util.h"
+#include "common/events.h"
#include "sword1/sound.h"
#include "sword1/resman.h"
@@ -44,6 +45,7 @@ namespace Sword1 {
#define SPEECH_FLAGS (Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_LITTLE_ENDIAN)
Sound::Sound(const char *searchPath, Audio::Mixer *mixer, ResMan *pResMan) {
+ g_system->getEventManager()->registerRandomSource(_rnd, "sword1sound");
strcpy(_filePath, searchPath);
_mixer = mixer;
_resMan = pResMan;
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 372fc79214..e8c3166948 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -209,6 +209,7 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) {
_gameSpeed = 1;
_quit = false;
+ syst->getEventManager()->registerRandomSource(_rnd, "sword2");
}
Sword2Engine::~Sword2Engine() {
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 27ab830ef7..3615a8227f 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -73,6 +73,8 @@ ToucheEngine::ToucheEngine(OSystem *system)
Common::addSpecialDebugLevel(kDebugResource, "Resource", "Resource debug level");
Common::addSpecialDebugLevel(kDebugOpcodes, "Opcodes", "Opcodes debug level");
Common::addSpecialDebugLevel(kDebugUserIntf, "UserIntf", "UserInterface debug level");
+
+ system->getEventManager()->registerRandomSource(_rnd, "touche");
}
ToucheEngine::~ToucheEngine() {