aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/EventRecorder.cpp2
-rw-r--r--common/EventRecorder.h2
-rw-r--r--common/random.cpp17
-rw-r--r--common/random.h16
-rw-r--r--engines/agi/agi.cpp4
-rw-r--r--engines/agos/agos.cpp5
-rw-r--r--engines/cine/cine.cpp8
-rw-r--r--engines/cruise/cruise.cpp6
-rw-r--r--engines/draci/draci.cpp7
-rw-r--r--engines/drascula/drascula.cpp4
-rw-r--r--engines/gob/gob.cpp5
-rw-r--r--engines/gob/sound/bgatmosphere.cpp6
-rw-r--r--engines/groovie/script.cpp8
-rw-r--r--engines/hugo/hugo.cpp4
-rw-r--r--engines/kyra/kyra_v1.cpp5
-rw-r--r--engines/kyra/sprites.cpp4
-rw-r--r--engines/lastexpress/lastexpress.cpp17
-rw-r--r--engines/lure/lure.cpp5
-rw-r--r--engines/lure/scripts.cpp1
-rw-r--r--engines/m4/m4.cpp4
-rw-r--r--engines/made/made.cpp4
-rw-r--r--engines/mohawk/cstime.cpp5
-rw-r--r--engines/mohawk/livingbooks.cpp5
-rw-r--r--engines/mohawk/riven.cpp5
-rw-r--r--engines/parallaction/parallaction.cpp5
-rw-r--r--engines/queen/display.cpp4
-rw-r--r--engines/queen/music.cpp7
-rw-r--r--engines/queen/queen.cpp4
-rw-r--r--engines/saga/saga.cpp4
-rw-r--r--engines/sci/sci.cpp6
-rw-r--r--engines/scumm/scumm.cpp7
-rw-r--r--engines/sky/logic.cpp5
-rw-r--r--engines/sword1/logic.cpp5
-rw-r--r--engines/sword1/logic.h2
-rw-r--r--engines/sword1/sound.cpp5
-rw-r--r--engines/sword2/sword2.cpp5
-rw-r--r--engines/tinsel/tinsel.cpp5
-rw-r--r--engines/toon/toon.cpp6
-rw-r--r--engines/touche/touche.cpp5
39 files changed, 99 insertions, 125 deletions
diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp
index 20dbde11d5..eb22e1ea88 100644
--- a/common/EventRecorder.cpp
+++ b/common/EventRecorder.cpp
@@ -251,7 +251,7 @@ void EventRecorder::deinit() {
g_system->deleteMutex(_recorderMutex);
}
-void EventRecorder::registerRandomSource(RandomSource &rnd, const char *name) {
+void EventRecorder::registerRandomSource(RandomSource &rnd, const String &name) {
if (_recordMode == kRecorderRecord) {
RandomSourceRecord rec;
rec.name = name;
diff --git a/common/EventRecorder.h b/common/EventRecorder.h
index 29bcf8e321..8377d9e8bd 100644
--- a/common/EventRecorder.h
+++ b/common/EventRecorder.h
@@ -51,7 +51,7 @@ public:
void deinit();
/** Register random source so it can be serialized in game test purposes */
- void registerRandomSource(RandomSource &rnd, const char *name);
+ void registerRandomSource(RandomSource &rnd, const String &name);
/** TODO: Add documentation, this is only used by the backend */
void processMillis(uint32 &millis);
diff --git a/common/random.cpp b/common/random.cpp
index 5a00d48357..be69d39d2d 100644
--- a/common/random.cpp
+++ b/common/random.cpp
@@ -21,10 +21,23 @@
#include "common/random.h"
#include "common/system.h"
+#include "common/EventRecorder.h"
namespace Common {
+RandomSource::RandomSource(const String &name) {
+ // Use system time as RNG seed. Normally not a good idea, if you are using
+ // a RNG for security purposes, but good enough for our purposes.
+ assert(g_system);
+ uint32 seed = g_system->getMillis();
+ setSeed(seed);
+
+ // Register this random source with the event recorder. This might
+ // reset the seed, so call it *after* the initial seed has been set.
+ g_eventRec.registerRandomSource(*this, name);
+}
+
RandomSource::RandomSource() {
// Use system time as RNG seed. Normally not a good idea, if you are using
// a RNG for security purposes, but good enough for our purposes.
@@ -33,6 +46,10 @@ RandomSource::RandomSource() {
setSeed(seed);
}
+RandomSource::~RandomSource() {
+ // TODO: Unregister with g_eventRec
+}
+
void RandomSource::setSeed(uint32 seed) {
_randSeed = seed;
}
diff --git a/common/random.h b/common/random.h
index 437675ab0a..308d8a62b9 100644
--- a/common/random.h
+++ b/common/random.h
@@ -26,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.
@@ -35,7 +37,21 @@ private:
uint32 _randSeed;
public:
+ /**
+ * 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);
+
+ // FIXME: This constructor for a nameless randomness source should be removed.
+ // I am only adding this temporarily to ease transition to the new
+ // system which enforces names for randomness sources.
RandomSource();
+
+ ~RandomSource();
+
void setSeed(uint32 seed);
uint32 getSeed() {
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 3efb017c5e..101c149f0a 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -22,7 +22,6 @@
#include "common/md5.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/memstream.h"
#include "common/savefile.h"
@@ -496,8 +495,7 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
parseFeatures();
- _rnd = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_rnd, "agi");
+ _rnd = new Common::RandomSource("agi");
DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index b6dba065ae..7e4c564798 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -21,7 +21,6 @@
*/
#include "common/config-manager.h"
-#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/textconsole.h"
@@ -110,7 +109,7 @@ AGOSEngine_Elvira1::AGOSEngine_Elvira1(OSystem *system)
}
AGOSEngine::AGOSEngine(OSystem *syst)
- : Engine(syst) {
+ : Engine(syst), _rnd("agos") {
_vcPtr = 0;
_vcGetOutOfCode = 0;
@@ -526,8 +525,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
SearchMan.addSubDirectoryMatching(gameDataDir, "movies");
SearchMan.addSubDirectoryMatching(gameDataDir, "sfx");
SearchMan.addSubDirectoryMatching(gameDataDir, "speech");
-
- g_eventRec.registerRandomSource(_rnd, "agos");
}
Common::Error AGOSEngine::init() {
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index 1692662b60..6f34b0f860 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -20,7 +20,6 @@
*
*/
-#include "common/EventRecorder.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
@@ -42,7 +41,10 @@ Sound *g_sound = 0;
CineEngine *g_cine = 0;
-CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc)
+ : Engine(syst),
+ _gameDescription(gameDesc),
+ _rnd("cine") {
// Setup mixer
syncSoundSettings();
@@ -53,8 +55,6 @@ CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Eng
_console = new CineConsole(this);
g_cine = this;
-
- g_eventRec.registerRandomSource(_rnd, "cine");
}
CineEngine::~CineEngine() {
diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp
index 0766ce3fc6..1e0b7b1d7a 100644
--- a/engines/cruise/cruise.cpp
+++ b/engines/cruise/cruise.cpp
@@ -20,7 +20,6 @@
*
*/
-#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/debug-channels.h"
#include "common/textconsole.h"
@@ -41,7 +40,8 @@ namespace Cruise {
CruiseEngine *_vm;
-CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
+CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc)
+ : Engine(syst), _gameDescription(gameDesc), _rnd("cruise") {
DebugMan.addDebugChannel(kCruiseDebugScript, "scripts", "Scripts debug level");
DebugMan.addDebugChannel(kCruiseDebugSound, "sound", "Sound debug level");
@@ -52,8 +52,6 @@ CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc
// Setup mixer
syncSoundSettings();
-
- g_eventRec.registerRandomSource(_rnd, "cruise");
}
extern void listMemory();
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 41950aca4a..cdc91e8d9f 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -27,7 +27,6 @@
#include "common/events.h"
#include "common/file.h"
#include "common/keyboard.h"
-#include "common/EventRecorder.h"
#include "engines/util.h"
@@ -71,7 +70,8 @@ const uint kSoundsFrequency = 13000;
const uint kDubbingFrequency = 22050;
DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc)
- : Engine(syst) {
+ : Engine(syst), _rnd("draci") {
+
// Put your engine in a sane state, but do nothing big yet;
// in particular, do not load data from files; rather, if you
// need to do such things, do them from init().
@@ -92,9 +92,6 @@ DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc)
DebugMan.addDebugChannel(kDraciWalkingDebugLevel, "walking", "Walking debug info");
_console = new DraciConsole(this);
-
- // Don't forget to register your random source
- g_eventRec.registerRandomSource(_rnd, "draci");
}
bool DraciEngine::hasFeature(EngineFeature f) const {
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index f165116219..cac7f93f12 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -21,7 +21,6 @@
*/
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/keyboard.h"
#include "common/file.h"
#include "common/savefile.h"
@@ -97,8 +96,7 @@ DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gam
rightMouseButton = 0;
*textName = 0;
- _rnd = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_rnd, "drascula");
+ _rnd = new Common::RandomSource("drascula");
_console = 0;
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index 7e8f77f703..ea7e329480 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -21,7 +21,6 @@
*/
#include "common/debug-channels.h"
-#include "common/EventRecorder.h"
#include "backends/audiocd/audiocd.h"
#include "base/plugins.h"
@@ -110,7 +109,7 @@ void PauseDialog::handleKeyDown(Common::KeyState state) {
}
-GobEngine::GobEngine(OSystem *syst) : Engine(syst) {
+GobEngine::GobEngine(OSystem *syst) : Engine(syst), _rnd("gob") {
_sound = 0; _mult = 0; _game = 0;
_global = 0; _dataIO = 0; _goblin = 0;
_vidPlayer = 0; _init = 0; _inter = 0;
@@ -145,8 +144,6 @@ GobEngine::GobEngine(OSystem *syst) : Engine(syst) {
DebugMan.addDebugChannel(kDebugVideo, "Video", "IMD/VMD video debug level");
DebugMan.addDebugChannel(kDebugHotspots, "Hotspots", "Hotspots debug level");
DebugMan.addDebugChannel(kDebugDemo, "Demo", "Demo script debug level");
-
- g_eventRec.registerRandomSource(_rnd, "gob");
}
GobEngine::~GobEngine() {
diff --git a/engines/gob/sound/bgatmosphere.cpp b/engines/gob/sound/bgatmosphere.cpp
index e2498242d6..daba72b2d5 100644
--- a/engines/gob/sound/bgatmosphere.cpp
+++ b/engines/gob/sound/bgatmosphere.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "common/EventRecorder.h"
+#include "common/array.h"
#include "gob/sound/bgatmosphere.h"
#include "gob/sound/sounddesc.h"
@@ -28,14 +28,12 @@
namespace Gob {
BackgroundAtmosphere::BackgroundAtmosphere(Audio::Mixer &mixer) :
- SoundMixer(mixer, Audio::Mixer::kMusicSoundType) {
+ SoundMixer(mixer, Audio::Mixer::kMusicSoundType), _rnd("gobBA") {
_playMode = kPlayModeLinear;
_queuePos = -1;
_shaded = false;
_shadable = true;
-
- g_eventRec.registerRandomSource(_rnd, "gobBA");
}
BackgroundAtmosphere::~BackgroundAtmosphere() {
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 080e0253b2..3bd90a042e 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -33,7 +33,7 @@
#include "common/archive.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
-#include "common/EventRecorder.h"
+#include "common/events.h"
#include "common/file.h"
#include "common/macresman.h"
@@ -65,7 +65,8 @@ static void debugScript(int level, bool nl, const char *s, ...) {
Script::Script(GroovieEngine *vm, EngineVersion version) :
_code(NULL), _savedCode(NULL), _stacktop(0), _debugger(NULL), _vm(vm),
- _videoFile(NULL), _videoRef(0), _staufsMove(NULL) {
+ _videoFile(NULL), _videoRef(0), _staufsMove(NULL),
+ _random("GroovieScripts") {
// Initialize the opcode set depending on the engine version
switch (version) {
case kGroovieT7G:
@@ -76,9 +77,6 @@ Script::Script(GroovieEngine *vm, EngineVersion version) :
break;
}
- // Initialize the random source
- g_eventRec.registerRandomSource(_random, "GroovieScripts");
-
// Prepare the variables
_bitflags = 0;
for (int i = 0; i < 0x400; i++) {
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 2485213189..7d35aec972 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -24,7 +24,6 @@
#include "common/random.h"
#include "common/error.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/debug-channels.h"
#include "common/config-manager.h"
#include "common/textconsole.h"
@@ -596,8 +595,7 @@ void HugoEngine::initialize() {
_file->openDatabaseFiles(); // Open database files
calcMaxScore(); // Initialise maxscore
- _rnd = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_rnd, "hugo");
+ _rnd = new Common::RandomSource("hugo");
_rnd->setSeed(42); // Kick random number generator
switch (_gameVariant) {
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 50814359ee..7f4f1ec2c7 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -29,12 +29,11 @@
#include "common/error.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
-#include "common/EventRecorder.h"
namespace Kyra {
KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
- : Engine(system), _flags(flags) {
+ : Engine(system), _flags(flags), _rnd("kyra") {
_res = 0;
_sound = 0;
_text = 0;
@@ -78,8 +77,6 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
DebugMan.addDebugChannel(kDebugLevelSequence, "Sequence", "Sequence debug level");
DebugMan.addDebugChannel(kDebugLevelMovie, "Movie", "Movie debug level");
DebugMan.addDebugChannel(kDebugLevelTimer, "Timer", "Timer debug level");
-
- g_eventRec.registerRandomSource(_rnd, "kyra");
}
::GUI::Debugger *KyraEngine_v1::getDebugger() {
diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp
index bcf1675862..e0d1142905 100644
--- a/engines/kyra/sprites.cpp
+++ b/engines/kyra/sprites.cpp
@@ -25,11 +25,10 @@
#include "kyra/animator_lok.h"
#include "common/system.h"
-#include "common/EventRecorder.h"
namespace Kyra {
-Sprites::Sprites(KyraEngine_LoK *vm, OSystem *system) {
+Sprites::Sprites(KyraEngine_LoK *vm, OSystem *system) : _rnd("kyraSprites") {
_vm = vm;
_res = vm->resource();
_screen = vm->screen();
@@ -40,7 +39,6 @@ Sprites::Sprites(KyraEngine_LoK *vm, OSystem *system) {
_spriteDefStart = 0;
memset(_drawLayerTable, 0, sizeof(_drawLayerTable));
_sceneAnimatorBeaconFlag = 0;
- g_eventRec.registerRandomSource(_rnd, "kyraSprites");
}
Sprites::~Sprites() {
diff --git a/engines/lastexpress/lastexpress.cpp b/engines/lastexpress/lastexpress.cpp
index ad6acff171..d195fcfad3 100644
--- a/engines/lastexpress/lastexpress.cpp
+++ b/engines/lastexpress/lastexpress.cpp
@@ -37,7 +37,6 @@
#include "common/config-manager.h"
#include "common/debug-channels.h"
-#include "common/EventRecorder.h"
#include "engines/util.h"
@@ -49,10 +48,16 @@ const char *g_entityNames[] = { "Player", "Anna", "August", "Mertens", "Coudert"
namespace LastExpress {
LastExpressEngine::LastExpressEngine(OSystem *syst, const ADGameDescription *gd) :
- Engine(syst), _gameDescription(gd), _debugger(NULL), _cursor(NULL),
- _font(NULL), _logic(NULL), _menu(NULL), _frameCounter(0), _lastFrameCount(0),
- _graphicsMan(NULL), _resMan(NULL), _sceneMan(NULL), _soundMan(NULL),
- _eventMouse(NULL), _eventTick(NULL), _eventMouseBackup(NULL), _eventTickBackup(NULL) {
+ Engine(syst), _gameDescription(gd),
+ _debugger(NULL), _cursor(NULL),
+ _font(NULL), _logic(NULL), _menu(NULL),
+ _frameCounter(0), _lastFrameCount(0),
+ _graphicsMan(NULL), _resMan(NULL),
+ _sceneMan(NULL), _soundMan(NULL),
+ _eventMouse(NULL), _eventTick(NULL),
+ _eventMouseBackup(NULL), _eventTickBackup(NULL),
+ _random("lastexpress")
+ {
// Setup mixer
syncSoundSettings();
@@ -71,8 +76,6 @@ LastExpressEngine::LastExpressEngine(OSystem *syst, const ADGameDescription *gd)
DebugMan.addDebugChannel(kLastExpressDebugLogic, "Logic", "Debug logic");
DebugMan.addDebugChannel(kLastExpressDebugScenes, "Scenes", "Debug scenes & hotspots");
DebugMan.addDebugChannel(kLastExpressDebugUnknown, "Unknown", "Debug unknown data");
-
- g_eventRec.registerRandomSource(_random, "lastexpress");
}
LastExpressEngine::~LastExpressEngine() {
diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp
index cec845a4fe..c6be5c48fe 100644
--- a/engines/lure/lure.cpp
+++ b/engines/lure/lure.cpp
@@ -24,7 +24,6 @@
#include "common/debug-channels.h"
#include "common/system.h"
#include "common/savefile.h"
-#include "common/EventRecorder.h"
#include "engines/util.h"
@@ -39,8 +38,8 @@ namespace Lure {
static LureEngine *int_engine = NULL;
-LureEngine::LureEngine(OSystem *system, const LureGameDescription *gameDesc): Engine(system), _gameDescription(gameDesc) {
- g_eventRec.registerRandomSource(_rnd, "lure");
+LureEngine::LureEngine(OSystem *system, const LureGameDescription *gameDesc)
+ : Engine(system), _gameDescription(gameDesc), _rnd("lure") {
DebugMan.addDebugChannel(kLureDebugScripts, "scripts", "Scripts debugging");
DebugMan.addDebugChannel(kLureDebugAnimations, "animations", "Animations debugging");
diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp
index 5a5a311ff0..7cd8be43d2 100644
--- a/engines/lure/scripts.cpp
+++ b/engines/lure/scripts.cpp
@@ -31,7 +31,6 @@
#include "lure/sound.h"
#include "common/stack.h"
#include "common/endian.h"
-#include "common/EventRecorder.h"
namespace Lure {
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 5b1e4e9081..881a523935 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -49,7 +49,6 @@
#include "common/error.h"
#include "common/file.h"
#include "common/fs.h"
-#include "common/EventRecorder.h"
#include "common/system.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
@@ -177,8 +176,7 @@ Common::Error MadsM4Engine::run() {
_script = new ScriptInterpreter(this);
_ws = new WoodScript(this);
//_callbacks = new Callbacks(this);
- _random = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_random, "m4");
+ _random = new Common::RandomSource("m4");
return Common::kNoError;
}
diff --git a/engines/made/made.cpp b/engines/made/made.cpp
index c4e01982ea..a9c4587b4c 100644
--- a/engines/made/made.cpp
+++ b/engines/made/made.cpp
@@ -21,7 +21,6 @@
*/
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/keyboard.h"
#include "common/config-manager.h"
#include "common/stream.h"
@@ -72,8 +71,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng
if (!scumm_stricmp(g->gameid, gameid))
_gameId = g->id;
- _rnd = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_rnd, "made");
+ _rnd = new Common::RandomSource("made");
_console = new MadeConsole(this);
diff --git a/engines/mohawk/cstime.cpp b/engines/mohawk/cstime.cpp
index 0bc480ec24..59bc5ad661 100644
--- a/engines/mohawk/cstime.cpp
+++ b/engines/mohawk/cstime.cpp
@@ -32,15 +32,14 @@
#include "common/config-manager.h"
#include "common/error.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/fs.h"
#include "common/textconsole.h"
+#include "common/system.h"
namespace Mohawk {
MohawkEngine_CSTime::MohawkEngine_CSTime(OSystem *syst, const MohawkGameDescription *gamedesc) : MohawkEngine(syst, gamedesc) {
- _rnd = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_rnd, "cstime");
+ _rnd = new Common::RandomSource("cstime");
// If the user just copied the CD contents, the fonts are in a subdirectory.
const Common::FSNode gameDataDir(ConfMan.get("path"));
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 36d86fb747..a4e7f0349c 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -28,10 +28,10 @@
#include "common/config-manager.h"
#include "common/error.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/fs.h"
#include "common/archive.h"
#include "common/textconsole.h"
+#include "common/system.h"
#include "graphics/palette.h"
@@ -125,8 +125,7 @@ MohawkEngine_LivingBooks::MohawkEngine_LivingBooks(OSystem *syst, const MohawkGa
_alreadyShowedIntro = false;
- _rnd = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_rnd, "livingbooks");
+ _rnd = new Common::RandomSource("livingbooks");
_page = NULL;
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 417a5b5f74..f407e650f6 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -22,9 +22,9 @@
#include "common/config-manager.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/keyboard.h"
#include "common/translation.h"
+#include "common/system.h"
#include "mohawk/cursors.h"
#include "mohawk/graphics.h"
@@ -118,8 +118,7 @@ Common::Error MohawkEngine_Riven::run() {
_optionsDialog = new RivenOptionsDialog(this);
_scriptMan = new RivenScriptManager(this);
- _rnd = new Common::RandomSource();
- g_eventRec.registerRandomSource(*_rnd, "riven");
+ _rnd = new Common::RandomSource("riven");
// Create the cursor manager
if (Common::File::exists("rivendmo.exe"))
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 61709b7a9b..9bbc7d0c57 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -21,7 +21,6 @@
*/
#include "common/debug-channels.h"
-#include "common/EventRecorder.h"
#include "common/system.h"
#include "common/textconsole.h"
@@ -45,7 +44,7 @@ uint32 _globalFlags = 0;
Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _location(getGameType()),
- _dialogueMan(0) {
+ _dialogueMan(0), _rnd("parallaction") {
// Setup mixer
syncSoundSettings();
@@ -60,8 +59,6 @@ Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gam
DebugMan.addDebugChannel(kDebugAudio, "audio", "Audio debug level");
DebugMan.addDebugChannel(kDebugMenu, "menu", "Menu debug level");
DebugMan.addDebugChannel(kDebugInventory, "inventory", "Inventory debug level");
-
- g_eventRec.registerRandomSource(_rnd, "parallaction");
}
Parallaction::~Parallaction() {
diff --git a/engines/queen/display.cpp b/engines/queen/display.cpp
index 56f1026785..83dc1a9f60 100644
--- a/engines/queen/display.cpp
+++ b/engines/queen/display.cpp
@@ -22,7 +22,6 @@
#include "common/system.h"
-#include "common/EventRecorder.h"
#include "common/events.h"
#include "graphics/cursorman.h"
@@ -38,7 +37,7 @@ namespace Queen {
Display::Display(QueenEngine *vm, OSystem *system)
: _fullscreen(true), _horizontalScroll(0), _bdWidth(0), _bdHeight(0),
- _system(system), _vm(vm) {
+ _system(system), _vm(vm), _rnd("queenDisplay") {
initFont();
@@ -73,7 +72,6 @@ Display::Display(QueenEngine *vm, OSystem *system)
memset(&_dynalum, 0, sizeof(_dynalum));
setupInkColors();
- g_eventRec.registerRandomSource(_rnd, "queenDisplay");
}
Display::~Display() {
diff --git a/engines/queen/music.cpp b/engines/queen/music.cpp
index 5d20e48c6c..858692703c 100644
--- a/engines/queen/music.cpp
+++ b/engines/queen/music.cpp
@@ -22,7 +22,6 @@
#include "common/config-manager.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "queen/music.h"
#include "queen/queen.h"
@@ -37,7 +36,9 @@ namespace Queen {
extern MidiDriver *C_Player_CreateAdLibMidiDriver(Audio::Mixer *);
MidiMusic::MidiMusic(QueenEngine *vm)
- : _isPlaying(false), _isLooping(false), _randomLoop(false), _masterVolume(192), _buf(0) {
+ : _isPlaying(false), _isLooping(false),
+ _randomLoop(false), _masterVolume(192),
+ _buf(0), _rnd("queenMusic") {
memset(_channelsTable, 0, sizeof(_channelsTable));
_queuePos = _lastSong = _currentSong = 0;
@@ -89,8 +90,6 @@ MidiMusic::MidiMusic(QueenEngine *vm)
_parser = MidiParser::createParser_SMF();
_parser->setMidiDriver(this);
_parser->setTimerRate(_driver->getBaseTempo());
-
- g_eventRec.registerRandomSource(_rnd, "queenMusic");
}
MidiMusic::~MidiMusic() {
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index 1e34ba22fe..97f757c418 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -28,7 +28,6 @@
#include "common/savefile.h"
#include "common/system.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/textconsole.h"
#include "engines/util.h"
@@ -193,8 +192,7 @@ Common::Error QueenMetaEngine::createInstance(OSystem *syst, Engine **engine) co
namespace Queen {
QueenEngine::QueenEngine(OSystem *syst)
- : Engine(syst), _debugger(0) {
- g_eventRec.registerRandomSource(randomizer, "queen");
+ : Engine(syst), _debugger(0), randomizer("queen") {
}
QueenEngine::~QueenEngine() {
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index f2b70d2609..15bd2aff72 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -25,7 +25,6 @@
#include "common/config-manager.h"
#include "common/system.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "audio/mixer.h"
@@ -56,7 +55,7 @@ namespace Saga {
#define MAX_TIME_DELTA 100
SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc)
- : Engine(syst), _gameDescription(gameDesc) {
+ : Engine(syst), _gameDescription(gameDesc), _rnd("saga") {
_framesEsc = 0;
@@ -133,7 +132,6 @@ SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc)
SearchMan.addSubDirectoryMatching(gameDataDir, "video");
_displayClip.left = _displayClip.top = 0;
- g_eventRec.registerRandomSource(_rnd, "saga");
}
SagaEngine::~SagaEngine() {
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 43cda13be4..cf46d41382 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -23,8 +23,6 @@
#include "common/system.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
-#include "common/EventRecorder.h"
-#include "common/file.h" // for Common::File::exists()
#include "engines/advancedDetector.h"
#include "engines/util.h"
@@ -75,7 +73,7 @@ SciEngine *g_sci = 0;
class GfxDriver;
SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc, SciGameId gameId)
- : Engine(syst), _gameDescription(desc), _gameId(gameId) {
+ : Engine(syst), _gameDescription(desc), _gameId(gameId), _rng("sci") {
assert(g_sci == 0);
g_sci = this;
@@ -183,8 +181,6 @@ SciEngine::~SciEngine() {
extern void showScummVMDialog(const Common::String &message);
Common::Error SciEngine::run() {
- g_eventRec.registerRandomSource(_rng, "sci");
-
// Assign default values to the config manager, in case settings are missing
ConfMan.registerDefault("sci_originalsaveload", "false");
ConfMan.registerDefault("native_fb01", "false");
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 6e958462b2..1b7f16bdca 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -24,7 +24,6 @@
#include "common/debug-channels.h"
#include "common/md5.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/system.h"
#include "common/translation.h"
@@ -111,7 +110,9 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_language(dr.language),
_debugger(0),
_currentScript(0xFF), // Let debug() work on init stage
- _messageDialog(0), _pauseDialog(0), _versionDialog(0) {
+ _messageDialog(0), _pauseDialog(0), _versionDialog(0),
+ _rnd("scumm")
+ {
if (_game.heversion > 0) {
_gdi = new GdiHE(this);
@@ -574,8 +575,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
assert(!_mainMenuDialog);
_mainMenuDialog = new ScummMenuDialog(this);
#endif
-
- g_eventRec.registerRandomSource(_rnd, "scumm");
}
diff --git a/engines/sky/logic.cpp b/engines/sky/logic.cpp
index ab3f114285..de081bb631 100644
--- a/engines/sky/logic.cpp
+++ b/engines/sky/logic.cpp
@@ -22,7 +22,6 @@
#include "common/endian.h"
#include "common/rect.h"
-#include "common/EventRecorder.h"
#include "common/textconsole.h"
#include "sky/autoroute.h"
@@ -68,8 +67,8 @@ void Logic::setupLogicTable() {
_logicTable = logicTable;
}
-Logic::Logic(SkyCompact *skyCompact, Screen *skyScreen, Disk *skyDisk, Text *skyText, MusicBase *skyMusic, Mouse *skyMouse, Sound *skySound) {
- g_eventRec.registerRandomSource(_rnd, "sky");
+Logic::Logic(SkyCompact *skyCompact, Screen *skyScreen, Disk *skyDisk, Text *skyText, MusicBase *skyMusic, Mouse *skyMouse, Sound *skySound)
+ : _rnd("sky") {
_skyCompact = skyCompact;
_skyScreen = skyScreen;
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index b334294b09..00f7112c05 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -22,7 +22,6 @@
#include "common/endian.h"
#include "common/util.h"
-#include "common/EventRecorder.h"
#include "common/textconsole.h"
#include "sword1/logic.h"
@@ -50,8 +49,8 @@ namespace Sword1 {
uint32 Logic::_scriptVars[NUM_SCRIPT_VARS];
-Logic::Logic(SwordEngine *vm, ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer) {
- g_eventRec.registerRandomSource(_rnd, "sword1");
+Logic::Logic(SwordEngine *vm, ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer)
+ : _rnd("sword1") {
_vm = vm;
_objMan = pObjMan;
diff --git a/engines/sword1/logic.h b/engines/sword1/logic.h
index 461355ad1a..13ddbc989b 100644
--- a/engines/sword1/logic.h
+++ b/engines/sword1/logic.h
@@ -30,6 +30,8 @@
#include "common/random.h"
#include "audio/mixer.h"
+class OSystem;
+
namespace Sword1 {
#define NON_ZERO_SCRIPT_VARS 95
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index a5a3634f72..f7ab9ca1de 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -24,7 +24,6 @@
#include "common/endian.h"
#include "common/util.h"
-#include "common/EventRecorder.h"
#include "common/memstream.h"
#include "common/textconsole.h"
@@ -46,8 +45,8 @@ namespace Sword1 {
#define SOUND_SPEECH_ID 1
#define SPEECH_FLAGS (Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN)
-Sound::Sound(const char *searchPath, Audio::Mixer *mixer, ResMan *pResMan) {
- g_eventRec.registerRandomSource(_rnd, "sword1sound");
+Sound::Sound(const char *searchPath, Audio::Mixer *mixer, ResMan *pResMan)
+ : _rnd("sword1sound") {
strcpy(_filePath, searchPath);
_mixer = mixer;
_resMan = pResMan;
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index cb58398c88..47c9b1616e 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -28,7 +28,6 @@
#include "common/file.h"
#include "common/fs.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/textconsole.h"
@@ -252,7 +251,7 @@ Common::Error Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) c
namespace Sword2 {
-Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) {
+Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst), _rnd("sword2") {
// Add default file directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "clusters");
@@ -292,8 +291,6 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) {
_gameSpeed = 1;
_gmmLoadSlot = -1; // Used to manage GMM Loading
-
- g_eventRec.registerRandomSource(_rnd, "sword2");
}
Sword2Engine::~Sword2Engine() {
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 9fc2ecf99e..84a8ea8eb3 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -24,7 +24,6 @@
#include "common/endian.h"
#include "common/error.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/keyboard.h"
#include "common/fs.h"
#include "common/config-manager.h"
@@ -815,7 +814,7 @@ const char *TinselEngine::_textFiles[][3] = {
TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) :
- Engine(syst), _gameDescription(gameDesc) {
+ Engine(syst), _gameDescription(gameDesc), _random("tinsel") {
_vm = this;
_config = new Config(this);
@@ -906,8 +905,6 @@ Common::Error TinselEngine::run() {
_screenSurface.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
}
- g_eventRec.registerRandomSource(_random, "tinsel");
-
_console = new Console();
_scheduler = new Scheduler();
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 471c7c2b8a..d441e59d4f 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -25,7 +25,6 @@
#include "common/debug-channels.h"
#include "common/archive.h"
#include "common/config-manager.h"
-#include "common/EventRecorder.h"
#include "common/savefile.h"
#include "common/memstream.h"
@@ -780,8 +779,6 @@ Common::Error ToonEngine::run() {
if (!loadToonDat())
return Common::kUnknownError;
- g_eventRec.registerRandomSource(_rnd, "toon");
-
initGraphics(TOON_SCREEN_WIDTH, TOON_SCREEN_HEIGHT, true);
init();
@@ -815,7 +812,8 @@ Common::Error ToonEngine::run() {
}
ToonEngine::ToonEngine(OSystem *syst, const ADGameDescription *gameDescription)
- : Engine(syst), _gameDescription(gameDescription), _language(gameDescription->language) {
+ : Engine(syst), _gameDescription(gameDescription),
+ _language(gameDescription->language), _rnd("toon") {
_system = syst;
_tickLength = 16;
_currentPicture = NULL;
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 018e5b07ef..81d6adf581 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -24,7 +24,6 @@
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/events.h"
-#include "common/EventRecorder.h"
#include "common/fs.h"
#include "common/system.h"
#include "common/archive.h"
@@ -45,7 +44,7 @@
namespace Touche {
ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
- : Engine(system), _midiPlayer(0), _language(language) {
+ : Engine(system), _midiPlayer(0), _language(language), _rnd("touche") {
_saveLoadCurrentPage = 0;
_saveLoadCurrentSlot = 0;
_hideInventoryTexts = false;
@@ -84,8 +83,6 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
DebugMan.addDebugChannel(kDebugMenu, "Menu", "Menu debug level");
_console = new ToucheConsole(this);
-
- g_eventRec.registerRandomSource(_rnd, "touche");
}
ToucheEngine::~ToucheEngine() {