[Scummvm-cvs-logs] SF.net SVN: scummvm:[42751] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Jul 25 14:59:46 CEST 2009


Revision: 42751
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42751&view=rev
Author:   lordhoto
Date:     2009-07-25 12:59:46 +0000 (Sat, 25 Jul 2009)

Log Message:
-----------
Move the event recorder to its own class (EventRecoder inside common/EventRecorder.[h/cpp]).

Modified Paths:
--------------
    scummvm/trunk/backends/events/default/default-events.cpp
    scummvm/trunk/backends/events/default/default-events.h
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/base/main.cpp
    scummvm/trunk/common/events.h
    scummvm/trunk/common/module.mk
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/cine/cine.cpp
    scummvm/trunk/engines/cruise/cruise.cpp
    scummvm/trunk/engines/drascula/drascula.cpp
    scummvm/trunk/engines/gob/gob.cpp
    scummvm/trunk/engines/gob/sound/bgatmosphere.cpp
    scummvm/trunk/engines/groovie/script.cpp
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/sprites.cpp
    scummvm/trunk/engines/lure/hotspots.cpp
    scummvm/trunk/engines/lure/res.cpp
    scummvm/trunk/engines/lure/scripts.cpp
    scummvm/trunk/engines/m4/m4.cpp
    scummvm/trunk/engines/made/made.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/queen/display.cpp
    scummvm/trunk/engines/queen/music.cpp
    scummvm/trunk/engines/queen/queen.cpp
    scummvm/trunk/engines/saga/saga.cpp
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/sky/logic.cpp
    scummvm/trunk/engines/sword1/logic.cpp
    scummvm/trunk/engines/sword1/sound.cpp
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/tinsel/tinsel.cpp
    scummvm/trunk/engines/touche/touche.cpp

Added Paths:
-----------
    scummvm/trunk/common/EventRecorder.cpp
    scummvm/trunk/common/EventRecorder.h

Modified: scummvm/trunk/backends/events/default/default-events.cpp
===================================================================
--- scummvm/trunk/backends/events/default/default-events.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/backends/events/default/default-events.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -35,63 +35,6 @@
 #include "engines/engine.h"
 #include "gui/message.h"
 
-#define RECORD_SIGNATURE 0x54455354
-#define RECORD_VERSION 1
-
-void readRecord(Common::InSaveFile *inFile, uint32 &diff, Common::Event &event) {
-	diff = inFile->readUint32LE();
-
-	event.type = (Common::EventType)inFile->readUint32LE();
-
-	switch(event.type) {
-	case Common::EVENT_KEYDOWN:
-	case Common::EVENT_KEYUP:
-		event.kbd.keycode = (Common::KeyCode)inFile->readSint32LE();
-		event.kbd.ascii = inFile->readUint16LE();
-		event.kbd.flags = inFile->readByte();
-		break;
-	case Common::EVENT_MOUSEMOVE:
-	case Common::EVENT_LBUTTONDOWN:
-	case Common::EVENT_LBUTTONUP:
-	case Common::EVENT_RBUTTONDOWN:
-	case Common::EVENT_RBUTTONUP:
-	case Common::EVENT_WHEELUP:
-	case Common::EVENT_WHEELDOWN:
-		event.mouse.x = inFile->readSint16LE();
-		event.mouse.y = inFile->readSint16LE();
-		break;
-	default:
-		break;
-	}
-}
-
-void writeRecord(Common::OutSaveFile *outFile, uint32 diff, Common::Event &event) {
-	outFile->writeUint32LE(diff);
-
-	outFile->writeUint32LE((uint32)event.type);
-
-	switch(event.type) {
-	case Common::EVENT_KEYDOWN:
-	case Common::EVENT_KEYUP:
-		outFile->writeSint32LE(event.kbd.keycode);
-		outFile->writeUint16LE(event.kbd.ascii);
-		outFile->writeByte(event.kbd.flags);
-		break;
-	case Common::EVENT_MOUSEMOVE:
-	case Common::EVENT_LBUTTONDOWN:
-	case Common::EVENT_LBUTTONUP:
-	case Common::EVENT_RBUTTONDOWN:
-	case Common::EVENT_RBUTTONUP:
-	case Common::EVENT_WHEELUP:
-	case Common::EVENT_WHEELDOWN:
-		outFile->writeSint16LE(event.mouse.x);
-		outFile->writeSint16LE(event.mouse.y);
-		break;
-	default:
-		break;
-	}
-}
-
 DefaultEventManager::DefaultEventManager(Common::EventSource *boss) :
 	_buttonState(0),
 	_modifierState(0),
@@ -106,101 +49,9 @@
 
 	_dispatcher.registerObserver(this, kEventManPriority, false);
 
-	_recordFile = NULL;
-	_recordTimeFile = NULL;
-	_playbackFile = NULL;
-	_playbackTimeFile = NULL;
-	_timeMutex = g_system->createMutex();
-	_recorderMutex = g_system->createMutex();
-
-	_eventCount = 0;
-	_lastEventCount = 0;
-	_lastMillis = 0;
-
-	Common::String recordModeString = ConfMan.get("record_mode");
-	if (recordModeString.compareToIgnoreCase("record") == 0) {
-		_recordMode = kRecorderRecord;
-	} else {
-		if (recordModeString.compareToIgnoreCase("playback") == 0) {
-			_recordMode = kRecorderPlayback;
-		} else {
-			_recordMode = kPassthrough;
-		}
-	}
-
-	_recordFileName = ConfMan.get("record_file_name");
-	if (_recordFileName.empty()) {
-		_recordFileName = "record.bin";
-	}
-	_recordTempFileName = ConfMan.get("record_temp_file_name");
-	if (_recordTempFileName.empty()) {
-		_recordTempFileName = "record.tmp";
-	}
-	_recordTimeFileName = ConfMan.get("record_time_file_name");
-	if (_recordTimeFileName.empty()) {
-		_recordTimeFileName = "record.time";
-	}
-
 	// Reset key repeat
 	_currentKeyDown.keycode = 0;
 
-	// recorder stuff
-	if (_recordMode == kRecorderRecord) {
-		_recordCount = 0;
-		_recordTimeCount = 0;
-		_recordFile = g_system->getSavefileManager()->openForSaving(_recordTempFileName);
-		_recordTimeFile = g_system->getSavefileManager()->openForSaving(_recordTimeFileName);
-		_recordSubtitles = ConfMan.getBool("subtitles");
-	}
-
-	uint32 sign;
-	uint32 version;
-	uint32 randomSourceCount;
-	if (_recordMode == kRecorderPlayback) {
-		_playbackCount = 0;
-		_playbackTimeCount = 0;
-		_playbackFile = g_system->getSavefileManager()->openForLoading(_recordFileName);
-		_playbackTimeFile = g_system->getSavefileManager()->openForLoading(_recordTimeFileName);
-
-		if (!_playbackFile) {
-			warning("Cannot open playback file %s. Playback was switched off", _recordFileName.c_str());
-			_recordMode = kPassthrough;
-		}
-
-		if (!_playbackTimeFile) {
-			warning("Cannot open playback time file %s. Playback was switched off", _recordTimeFileName.c_str());
-			_recordMode = kPassthrough;
-		}
-	}
-
-	if (_recordMode == kRecorderPlayback) {
-		sign = _playbackFile->readUint32LE();
-		if (sign != RECORD_SIGNATURE) {
-			error("Unknown record file signature");
-		}
-		version = _playbackFile->readUint32LE();
-
-		// conf vars
-		ConfMan.setBool("subtitles", _playbackFile->readByte() != 0);
-
-		_recordCount = _playbackFile->readUint32LE();
-		_recordTimeCount = _playbackFile->readUint32LE();
-		randomSourceCount = _playbackFile->readUint32LE();
-		for (uint i = 0; i < randomSourceCount; ++i) {
-			RandomSourceRecord rec;
-			rec.name = "";
-			uint32 sLen = _playbackFile->readUint32LE();
-			for (uint j = 0; j < sLen; ++j) {
-				char c = _playbackFile->readSByte();
-				rec.name += c;
-			}
-			rec.seed = _playbackFile->readUint32LE();
-			_randomSourceRecords.push_back(rec);
-		}
-
-		_hasPlaybackEvent = false;
-	}
-
 #ifdef ENABLE_VKEYBD
 	_vk = new Common::VirtualKeyboard();
 #endif
@@ -216,61 +67,6 @@
 #ifdef ENABLE_VKEYBD
 	delete _vk;
 #endif
-	g_system->lockMutex(_timeMutex);
-	g_system->lockMutex(_recorderMutex);
-	_recordMode = kPassthrough;
-	g_system->unlockMutex(_timeMutex);
-	g_system->unlockMutex(_recorderMutex);
-
-	if (_playbackFile != NULL) {
-		delete _playbackFile;
-	}
-	if (_playbackTimeFile != NULL) {
-		delete _playbackTimeFile;
-	}
-
-	if (_recordFile != NULL) {
-		_recordFile->finalize();
-		delete _recordFile;
-		_recordTimeFile->finalize();
-		delete _recordTimeFile;
-
-		_playbackFile = g_system->getSavefileManager()->openForLoading(_recordTempFileName);
-
-		assert(_playbackFile);
-
-		_recordFile = g_system->getSavefileManager()->openForSaving(_recordFileName);
-		_recordFile->writeUint32LE(RECORD_SIGNATURE);
-		_recordFile->writeUint32LE(RECORD_VERSION);
-
-		// conf vars
-		_recordFile->writeByte(_recordSubtitles ? 1 : 0);
-
-		_recordFile->writeUint32LE(_recordCount);
-		_recordFile->writeUint32LE(_recordTimeCount);
-
-		_recordFile->writeUint32LE(_randomSourceRecords.size());
-		for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
-			_recordFile->writeUint32LE(_randomSourceRecords[i].name.size());
-			_recordFile->writeString(_randomSourceRecords[i].name);
-			_recordFile->writeUint32LE(_randomSourceRecords[i].seed);
-		}
-
-		for (uint i = 0; i < _recordCount; ++i) {
-			uint32 tempDiff;
-			Common::Event tempEvent;
-			readRecord(_playbackFile, tempDiff, tempEvent);
-			writeRecord(_recordFile, tempDiff, tempEvent);
-		}
-
-		_recordFile->finalize();
-		delete _recordFile;
-		delete _playbackFile;
-
-		//TODO: remove recordTempFileName'ed file
-	}
-	g_system->deleteMutex(_timeMutex);
-	g_system->deleteMutex(_recorderMutex);
 }
 
 void DefaultEventManager::init() {
@@ -283,102 +79,6 @@
 #endif
 }
 
-bool DefaultEventManager::playback(Common::Event &event) {
-
-	if (!_hasPlaybackEvent) {
-		if (_recordCount > _playbackCount) {
-			readRecord(_playbackFile, const_cast<uint32&>(_playbackDiff), _playbackEvent);
-			_playbackCount++;
-			_hasPlaybackEvent = true;
-		}
-	}
-
-	if (_hasPlaybackEvent) {
-		if (_playbackDiff <= (_eventCount - _lastEventCount)) {
-			switch(_playbackEvent.type) {
-			case Common::EVENT_MOUSEMOVE:
-			case Common::EVENT_LBUTTONDOWN:
-			case Common::EVENT_LBUTTONUP:
-			case Common::EVENT_RBUTTONDOWN:
-			case Common::EVENT_RBUTTONUP:
-			case Common::EVENT_WHEELUP:
-			case Common::EVENT_WHEELDOWN:
-				g_system->warpMouse(_playbackEvent.mouse.x, _playbackEvent.mouse.y);
-				break;
-			default:
-				break;
-			}
-			event = _playbackEvent;
-			_hasPlaybackEvent = false;
-			_lastEventCount = _eventCount;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-void DefaultEventManager::record(Common::Event &event) {
-	writeRecord(_recordFile, _eventCount - _lastEventCount, event);
-
-	_recordCount++;
-	_lastEventCount = _eventCount;
-}
-
-void DefaultEventManager::registerRandomSource(Common::RandomSource &rnd, const char *name) {
-
-	if (_recordMode == kRecorderRecord) {
-		RandomSourceRecord rec;
-		rec.name = name;
-		rec.seed = rnd.getSeed();
-		_randomSourceRecords.push_back(rec);
-	}
-
-	if (_recordMode == kRecorderPlayback) {
-		for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
-			if (_randomSourceRecords[i].name == name) {
-				rnd.setSeed(_randomSourceRecords[i].seed);
-				_randomSourceRecords.remove_at(i);
-				break;
-			}
-		}
-	}
-}
-
-void DefaultEventManager::processMillis(uint32 &millis) {
-	uint32 d;
-	if (_recordMode == kPassthrough) {
-		return;
-	}
-
-	g_system->lockMutex(_timeMutex);
-	if (_recordMode == kRecorderRecord) {
-		//Simple RLE compression
-		d = millis - _lastMillis;
-		if (d >= 0xff) {
-			_recordTimeFile->writeByte(0xff);
-			_recordTimeFile->writeUint32LE(d);
-		} else {
-			_recordTimeFile->writeByte(d);
-		}
-		_recordTimeCount++;
-	}
-
-	if (_recordMode == kRecorderPlayback) {
-		if (_recordTimeCount > _playbackTimeCount) {
-			d = _playbackTimeFile->readByte();
-			if (d == 0xff) {
-				d = _playbackTimeFile->readUint32LE();
-			}
-			millis = _lastMillis + d;
-			_playbackTimeCount++;
-		}
-	}
-
-	_lastMillis = millis;
-	g_system->unlockMutex(_timeMutex);
-}
-
 bool DefaultEventManager::pollEvent(Common::Event &event) {
 	uint32 time = g_system->getMillis();
 	bool result = false;
@@ -389,25 +89,6 @@
 		result = true;
 	}
 
-	if (_recordMode != kPassthrough)  {
-
-		g_system->lockMutex(_recorderMutex);
-		_eventCount++;
-
-		if (_recordMode == kRecorderPlayback)  {
-			if (event.type != Common::EVENT_QUIT) {
-				result = playback(event);
-			}
-		} else {
-			if (_recordMode == kRecorderRecord) {
-				if (result) {
-					record(event);
-				}
-			}
-		}
-		g_system->unlockMutex(_recorderMutex);
-	}
-
 	if (result) {
 		event.synthetic = false;
 		switch (event.type) {

Modified: scummvm/trunk/backends/events/default/default-events.h
===================================================================
--- scummvm/trunk/backends/events/default/default-events.h	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/backends/events/default/default-events.h	2009-07-25 12:59:46 UTC (rev 42751)
@@ -27,8 +27,6 @@
 #define BACKEND_EVENTS_DEFAULT_H
 
 #include "common/events.h"
-#include "common/savefile.h"
-#include "common/mutex.h"
 #include "common/queue.h"
 
 namespace Common {
@@ -66,44 +64,6 @@
 	bool _shouldRTL;
 	bool _confirmExitDialogActive;
 
-	class RandomSourceRecord {
-	public:
-		Common::String name;
-		uint32 seed;
-	};
-	Common::Array<RandomSourceRecord> _randomSourceRecords;
-
-	bool _recordSubtitles;
-	volatile uint32 _recordCount;
-	volatile uint32 _lastRecordEvent;
-	volatile uint32 _recordTimeCount;
-	Common::OutSaveFile *_recordFile;
-	Common::OutSaveFile *_recordTimeFile;
-	Common::MutexRef _timeMutex;
-	Common::MutexRef _recorderMutex;
-	volatile uint32 _lastMillis;
-
-	volatile uint32 _playbackCount;
-	volatile uint32 _playbackDiff;
-	volatile bool _hasPlaybackEvent;
-	volatile uint32 _playbackTimeCount;
-	Common::Event _playbackEvent;
-	Common::InSaveFile *_playbackFile;
-	Common::InSaveFile *_playbackTimeFile;
-
-	volatile uint32 _eventCount;
-	volatile uint32 _lastEventCount;
-
-	enum RecordMode {
-		kPassthrough = 0,
-		kRecorderRecord = 1,
-		kRecorderPlayback = 2
-	};
-	volatile RecordMode _recordMode;
-	Common::String _recordFileName;
-	Common::String _recordTempFileName;
-	Common::String _recordTimeFileName;
-
 	// for continuous events (keyDown)
 	enum {
 		kKeyRepeatInitialDelay = 400,
@@ -116,9 +76,6 @@
 		int keycode;
 	} _currentKeyDown;
 	uint32 _keyRepeatTime;
-
-	void record(Common::Event &event);
-	bool playback(Common::Event &event);
 public:
 	DefaultEventManager(Common::EventSource *boss);
 	~DefaultEventManager();
@@ -126,8 +83,6 @@
 	virtual void init();
 	virtual bool pollEvent(Common::Event &event);
 	virtual void pushEvent(const Common::Event &event);
-	virtual void registerRandomSource(Common::RandomSource &rnd, const char *name);
-	virtual void processMillis(uint32 &millis);
 
 	virtual Common::Point getMousePos() const { return _mousePos; }
 	virtual int getButtonState() const { return _buttonState; }

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -33,7 +33,7 @@
 #include "common/archive.h"
 #include "common/config-manager.h"
 #include "common/debug.h"
-#include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/util.h"
 
 #ifdef UNIX
@@ -257,7 +257,7 @@
 
 uint32 OSystem_SDL::getMillis() {
 	uint32 millis = SDL_GetTicks();
-	getEventManager()->processMillis(millis);
+	g_eventRec.processMillis(millis);
 	return millis;
 }
 

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/base/main.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -41,6 +41,7 @@
 #include "common/config-manager.h"
 #include "common/debug.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/file.h"
 #include "common/fs.h"
 #include "common/system.h"
@@ -355,6 +356,14 @@
 	// take place after the backend is initiated and the screen has been setup
 	system.getEventManager()->init();
 
+	// Directly after initializing the event manager, we will initialize our
+	// event recorder.
+	//
+	// TODO: This is just to match the current behavior, when we further extend
+	// our event recorder, we might do this at another place. Or even change
+	// the whole API for that ;-).
+	g_eventRec.init();
+
 	// Now as the event manager is created, setup the keymapper
 	setupKeymapper(system);
 

Added: scummvm/trunk/common/EventRecorder.cpp
===================================================================
--- scummvm/trunk/common/EventRecorder.cpp	                        (rev 0)
+++ scummvm/trunk/common/EventRecorder.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -0,0 +1,366 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/EventRecorder.h"
+
+#include "common/config-manager.h"
+
+DECLARE_SINGLETON(Common::EventRecorder);
+
+namespace Common {
+
+#define RECORD_SIGNATURE 0x54455354
+#define RECORD_VERSION 1
+
+void readRecord(Common::InSaveFile *inFile, uint32 &diff, Common::Event &event) {
+	diff = inFile->readUint32LE();
+
+	event.type = (Common::EventType)inFile->readUint32LE();
+
+	switch(event.type) {
+	case Common::EVENT_KEYDOWN:
+	case Common::EVENT_KEYUP:
+		event.kbd.keycode = (Common::KeyCode)inFile->readSint32LE();
+		event.kbd.ascii = inFile->readUint16LE();
+		event.kbd.flags = inFile->readByte();
+		break;
+	case Common::EVENT_MOUSEMOVE:
+	case Common::EVENT_LBUTTONDOWN:
+	case Common::EVENT_LBUTTONUP:
+	case Common::EVENT_RBUTTONDOWN:
+	case Common::EVENT_RBUTTONUP:
+	case Common::EVENT_WHEELUP:
+	case Common::EVENT_WHEELDOWN:
+		event.mouse.x = inFile->readSint16LE();
+		event.mouse.y = inFile->readSint16LE();
+		break;
+	default:
+		break;
+	}
+}
+
+void writeRecord(Common::OutSaveFile *outFile, uint32 diff, const Common::Event &event) {
+	outFile->writeUint32LE(diff);
+
+	outFile->writeUint32LE((uint32)event.type);
+
+	switch(event.type) {
+	case Common::EVENT_KEYDOWN:
+	case Common::EVENT_KEYUP:
+		outFile->writeSint32LE(event.kbd.keycode);
+		outFile->writeUint16LE(event.kbd.ascii);
+		outFile->writeByte(event.kbd.flags);
+		break;
+	case Common::EVENT_MOUSEMOVE:
+	case Common::EVENT_LBUTTONDOWN:
+	case Common::EVENT_LBUTTONUP:
+	case Common::EVENT_RBUTTONDOWN:
+	case Common::EVENT_RBUTTONUP:
+	case Common::EVENT_WHEELUP:
+	case Common::EVENT_WHEELDOWN:
+		outFile->writeSint16LE(event.mouse.x);
+		outFile->writeSint16LE(event.mouse.y);
+		break;
+	default:
+		break;
+	}
+}
+
+EventRecorder::EventRecorder() {
+	_recordFile = NULL;
+	_recordTimeFile = NULL;
+	_playbackFile = NULL;
+	_playbackTimeFile = NULL;
+	_timeMutex = g_system->createMutex();
+	_recorderMutex = g_system->createMutex();
+
+	_eventCount = 0;
+	_lastEventCount = 0;
+	_lastMillis = 0;
+
+}
+
+EventRecorder::~EventRecorder() {
+	deinit();
+}
+
+void EventRecorder::init() {
+	Common::String recordModeString = ConfMan.get("record_mode");
+	if (recordModeString.compareToIgnoreCase("record") == 0) {
+		_recordMode = kRecorderRecord;
+	} else {
+		if (recordModeString.compareToIgnoreCase("playback") == 0) {
+			_recordMode = kRecorderPlayback;
+		} else {
+			_recordMode = kPassthrough;
+		}
+	}
+
+	_recordFileName = ConfMan.get("record_file_name");
+	if (_recordFileName.empty()) {
+		_recordFileName = "record.bin";
+	}
+	_recordTempFileName = ConfMan.get("record_temp_file_name");
+	if (_recordTempFileName.empty()) {
+		_recordTempFileName = "record.tmp";
+	}
+	_recordTimeFileName = ConfMan.get("record_time_file_name");
+	if (_recordTimeFileName.empty()) {
+		_recordTimeFileName = "record.time";
+	}
+
+	// recorder stuff
+	if (_recordMode == kRecorderRecord) {
+		_recordCount = 0;
+		_recordTimeCount = 0;
+		_recordFile = g_system->getSavefileManager()->openForSaving(_recordTempFileName);
+		_recordTimeFile = g_system->getSavefileManager()->openForSaving(_recordTimeFileName);
+		_recordSubtitles = ConfMan.getBool("subtitles");
+	}
+
+	uint32 sign;
+	uint32 version;
+	uint32 randomSourceCount;
+	if (_recordMode == kRecorderPlayback) {
+		_playbackCount = 0;
+		_playbackTimeCount = 0;
+		_playbackFile = g_system->getSavefileManager()->openForLoading(_recordFileName);
+		_playbackTimeFile = g_system->getSavefileManager()->openForLoading(_recordTimeFileName);
+
+		if (!_playbackFile) {
+			warning("Cannot open playback file %s. Playback was switched off", _recordFileName.c_str());
+			_recordMode = kPassthrough;
+		}
+
+		if (!_playbackTimeFile) {
+			warning("Cannot open playback time file %s. Playback was switched off", _recordTimeFileName.c_str());
+			_recordMode = kPassthrough;
+		}
+	}
+
+	if (_recordMode == kRecorderPlayback) {
+		sign = _playbackFile->readUint32LE();
+		if (sign != RECORD_SIGNATURE) {
+			error("Unknown record file signature");
+		}
+		version = _playbackFile->readUint32LE();
+
+		// conf vars
+		ConfMan.setBool("subtitles", _playbackFile->readByte() != 0);
+
+		_recordCount = _playbackFile->readUint32LE();
+		_recordTimeCount = _playbackFile->readUint32LE();
+		randomSourceCount = _playbackFile->readUint32LE();
+		for (uint i = 0; i < randomSourceCount; ++i) {
+			RandomSourceRecord rec;
+			rec.name = "";
+			uint32 sLen = _playbackFile->readUint32LE();
+			for (uint j = 0; j < sLen; ++j) {
+				char c = _playbackFile->readSByte();
+				rec.name += c;
+			}
+			rec.seed = _playbackFile->readUint32LE();
+			_randomSourceRecords.push_back(rec);
+		}
+
+		_hasPlaybackEvent = false;
+	}
+
+	g_system->getEventManager()->getEventDispatcher()->registerSource(this, false);
+	g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 1, false);
+}
+
+void EventRecorder::deinit() {
+	g_system->getEventManager()->getEventDispatcher()->unregisterSource(this);
+	g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this);
+
+	g_system->lockMutex(_timeMutex);
+	g_system->lockMutex(_recorderMutex);
+	_recordMode = kPassthrough;
+	g_system->unlockMutex(_timeMutex);
+	g_system->unlockMutex(_recorderMutex);
+
+	if (_playbackFile != NULL) {
+		delete _playbackFile;
+	}
+	if (_playbackTimeFile != NULL) {
+		delete _playbackTimeFile;
+	}
+
+	if (_recordFile != NULL) {
+		_recordFile->finalize();
+		delete _recordFile;
+		_recordTimeFile->finalize();
+		delete _recordTimeFile;
+
+		_playbackFile = g_system->getSavefileManager()->openForLoading(_recordTempFileName);
+
+		assert(_playbackFile);
+
+		_recordFile = g_system->getSavefileManager()->openForSaving(_recordFileName);
+		_recordFile->writeUint32LE(RECORD_SIGNATURE);
+		_recordFile->writeUint32LE(RECORD_VERSION);
+
+		// conf vars
+		_recordFile->writeByte(_recordSubtitles ? 1 : 0);
+
+		_recordFile->writeUint32LE(_recordCount);
+		_recordFile->writeUint32LE(_recordTimeCount);
+
+		_recordFile->writeUint32LE(_randomSourceRecords.size());
+		for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
+			_recordFile->writeUint32LE(_randomSourceRecords[i].name.size());
+			_recordFile->writeString(_randomSourceRecords[i].name);
+			_recordFile->writeUint32LE(_randomSourceRecords[i].seed);
+		}
+
+		for (uint i = 0; i < _recordCount; ++i) {
+			uint32 tempDiff;
+			Common::Event tempEvent;
+			readRecord(_playbackFile, tempDiff, tempEvent);
+			writeRecord(_recordFile, tempDiff, tempEvent);
+		}
+
+		_recordFile->finalize();
+		delete _recordFile;
+		delete _playbackFile;
+
+		//TODO: remove recordTempFileName'ed file
+	}
+
+	g_system->deleteMutex(_timeMutex);
+	g_system->deleteMutex(_recorderMutex);
+}
+
+void EventRecorder::registerRandomSource(Common::RandomSource &rnd, const char *name) {
+	if (_recordMode == kRecorderRecord) {
+		RandomSourceRecord rec;
+		rec.name = name;
+		rec.seed = rnd.getSeed();
+		_randomSourceRecords.push_back(rec);
+	}
+
+	if (_recordMode == kRecorderPlayback) {
+		for (uint i = 0; i < _randomSourceRecords.size(); ++i) {
+			if (_randomSourceRecords[i].name == name) {
+				rnd.setSeed(_randomSourceRecords[i].seed);
+				_randomSourceRecords.remove_at(i);
+				break;
+			}
+		}
+	}
+}
+
+void EventRecorder::processMillis(uint32 &millis) {
+	uint32 d;
+	if (_recordMode == kPassthrough) {
+		return;
+	}
+
+	g_system->lockMutex(_timeMutex);
+	if (_recordMode == kRecorderRecord) {
+		//Simple RLE compression
+		d = millis - _lastMillis;
+		if (d >= 0xff) {
+			_recordTimeFile->writeByte(0xff);
+			_recordTimeFile->writeUint32LE(d);
+		} else {
+			_recordTimeFile->writeByte(d);
+		}
+		_recordTimeCount++;
+	}
+
+	if (_recordMode == kRecorderPlayback) {
+		if (_recordTimeCount > _playbackTimeCount) {
+			d = _playbackTimeFile->readByte();
+			if (d == 0xff) {
+				d = _playbackTimeFile->readUint32LE();
+			}
+			millis = _lastMillis + d;
+			_playbackTimeCount++;
+		}
+	}
+
+	_lastMillis = millis;
+	g_system->unlockMutex(_timeMutex);
+}
+
+bool EventRecorder::notifyEvent(const Common::Event &ev) {
+	if (_recordMode != kRecorderRecord)
+		return false;
+
+	Common::StackLock lock(_recorderMutex);
+	++_eventCount;
+
+	writeRecord(_recordFile, _eventCount - _lastEventCount, ev);
+
+	_recordCount++;
+	_lastEventCount = _eventCount;
+
+	return false;
+}
+
+bool EventRecorder::pollEvent(Common::Event &ev) {
+	if (_recordMode != kRecorderPlayback)
+		return false;
+
+	Common::StackLock lock(_recorderMutex);
+	++_eventCount;
+
+	if (!_hasPlaybackEvent) {
+		if (_recordCount > _playbackCount) {
+			readRecord(_playbackFile, const_cast<uint32&>(_playbackDiff), _playbackEvent);
+			_playbackCount++;
+			_hasPlaybackEvent = true;
+		}
+	}
+
+	if (_hasPlaybackEvent) {
+		if (_playbackDiff <= (_eventCount - _lastEventCount)) {
+			switch(_playbackEvent.type) {
+			case Common::EVENT_MOUSEMOVE:
+			case Common::EVENT_LBUTTONDOWN:
+			case Common::EVENT_LBUTTONUP:
+			case Common::EVENT_RBUTTONDOWN:
+			case Common::EVENT_RBUTTONUP:
+			case Common::EVENT_WHEELUP:
+			case Common::EVENT_WHEELDOWN:
+				g_system->warpMouse(_playbackEvent.mouse.x, _playbackEvent.mouse.y);
+				break;
+			default:
+				break;
+			}
+			ev = _playbackEvent;
+			_hasPlaybackEvent = false;
+			_lastEventCount = _eventCount;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+} // end of namespace Common
+


Property changes on: scummvm/trunk/common/EventRecorder.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Copied: scummvm/trunk/common/EventRecorder.h (from rev 42748, scummvm/trunk/backends/events/default/default-events.h)
===================================================================
--- scummvm/trunk/common/EventRecorder.h	                        (rev 0)
+++ scummvm/trunk/common/EventRecorder.h	2009-07-25 12:59:46 UTC (rev 42751)
@@ -0,0 +1,106 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef COMMON_EVENTRECORDER_H
+#define COMMON_EVENTRECORDER_H
+
+#include "common/scummsys.h"
+#include "common/events.h"
+#include "common/singleton.h"
+#include "common/savefile.h"
+#include "common/mutex.h"
+#include "common/array.h"
+
+#define g_eventRec (Common::EventRecorder::instance())
+
+namespace Common {
+
+/**
+ * Our generic event recorder.
+ *
+ * TODO: Add more documentation.
+ */
+class EventRecorder : private EventSource, private EventObserver, public Singleton<EventRecorder> {
+	friend class Common::Singleton<SingletonBaseType>;
+	EventRecorder();
+	~EventRecorder();
+public:
+	void init();
+	void deinit();
+
+	/** Register random source so it can be serialized in game test purposes */
+	void registerRandomSource(Common::RandomSource &rnd, const char *name);
+
+	/** TODO: Add documentation, this is only used by the backend */
+	void processMillis(uint32 &millis);
+
+private:
+	bool notifyEvent(const Common::Event &ev);
+	bool pollEvent(Common::Event &ev);
+	bool allowMapping() const { return false; }
+
+	class RandomSourceRecord {
+	public:
+		Common::String name;
+		uint32 seed;
+	};
+	Common::Array<RandomSourceRecord> _randomSourceRecords;
+
+	bool _recordSubtitles;
+	volatile uint32 _recordCount;
+	volatile uint32 _lastRecordEvent;
+	volatile uint32 _recordTimeCount;
+	Common::OutSaveFile *_recordFile;
+	Common::OutSaveFile *_recordTimeFile;
+	Common::MutexRef _timeMutex;
+	Common::MutexRef _recorderMutex;
+	volatile uint32 _lastMillis;
+
+	volatile uint32 _playbackCount;
+	volatile uint32 _playbackDiff;
+	volatile bool _hasPlaybackEvent;
+	volatile uint32 _playbackTimeCount;
+	Common::Event _playbackEvent;
+	Common::InSaveFile *_playbackFile;
+	Common::InSaveFile *_playbackTimeFile;
+
+	volatile uint32 _eventCount;
+	volatile uint32 _lastEventCount;
+
+	enum RecordMode {
+		kPassthrough = 0,
+		kRecorderRecord = 1,
+		kRecorderPlayback = 2
+	};
+	volatile RecordMode _recordMode;
+	Common::String _recordFileName;
+	Common::String _recordTempFileName;
+	Common::String _recordTimeFileName;
+};
+
+} // end of namespace Common
+
+#endif
+

Modified: scummvm/trunk/common/events.h
===================================================================
--- scummvm/trunk/common/events.h	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/common/events.h	2009-07-25 12:59:46 UTC (rev 42751)
@@ -348,11 +348,6 @@
 	 */
 	virtual void pushEvent(const Common::Event &event) = 0;
 
-	/** Register random source so it can be serialized in game test purposes **/
-	virtual void registerRandomSource(Common::RandomSource &rnd, const char *name) = 0;
-
-	virtual void processMillis(uint32 &millis) = 0;
-
 	/** Return the current mouse position */
 	virtual Common::Point getMousePos() const = 0;
 

Modified: scummvm/trunk/common/module.mk
===================================================================
--- scummvm/trunk/common/module.mk	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/common/module.mk	2009-07-25 12:59:46 UTC (rev 42751)
@@ -6,6 +6,7 @@
 	config-manager.o \
 	debug.o \
 	events.o \
+	EventRecorder.o \
 	file.o \
 	fs.o \
 	hashmap.o \

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/agi/agi.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -25,6 +25,7 @@
 
 #include "common/md5.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/file.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
@@ -515,7 +516,7 @@
 	parseFeatures();
 
 	_rnd = new Common::RandomSource();
-	syst->getEventManager()->registerRandomSource(*_rnd, "agi");
+	g_eventRec.registerRandomSource(*_rnd, "agi");
 
 	Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
 	Common::addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/agos/agos.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -27,6 +27,7 @@
 #include "common/file.h"
 #include "common/system.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #include "agos/debugger.h"
 #include "agos/intern.h"
@@ -528,7 +529,7 @@
 	File::addDefaultDirectory(_gameDataDir.getChild("speech"));
 	File::addDefaultDirectory(_gameDataDir.getChild("SPEECH"));
 
-	syst->getEventManager()->registerRandomSource(_rnd, "agos");
+	g_eventRec.registerRandomSource(_rnd, "agos");
 }
 
 Common::Error AGOSEngine::init() {

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/cine/cine.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -24,6 +24,7 @@
  */
 
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/file.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
@@ -64,7 +65,7 @@
 
 	g_cine = this;
 
-	syst->getEventManager()->registerRandomSource(_rnd, "cine");
+	g_eventRec.registerRandomSource(_rnd, "cine");
 }
 
 CineEngine::~CineEngine() {

Modified: scummvm/trunk/engines/cruise/cruise.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/cruise/cruise.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -24,6 +24,7 @@
  */
 
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/file.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
@@ -65,7 +66,7 @@
 	_debugger = new Debugger();
 	_sound = new PCSound(_mixer, this);
 
-	syst->getEventManager()->registerRandomSource(_rnd, "cruise");
+	g_eventRec.registerRandomSource(_rnd, "cruise");
 }
 
 CruiseEngine::~CruiseEngine() {

Modified: scummvm/trunk/engines/drascula/drascula.cpp
===================================================================
--- scummvm/trunk/engines/drascula/drascula.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/drascula/drascula.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -24,6 +24,7 @@
  */
 
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/keyboard.h"
 #include "common/file.h"
 #include "common/savefile.h"
@@ -92,7 +93,7 @@
 	*textName = 0;
 
 	_rnd = new Common::RandomSource();
-	syst->getEventManager()->registerRandomSource(*_rnd, "drascula");
+	g_eventRec.registerRandomSource(*_rnd, "drascula");
 
 	int cd_num = ConfMan.getInt("cdrom");
 	if (cd_num >= 0)

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/gob/gob.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -25,6 +25,7 @@
 
 #include "common/endian.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #include "base/plugins.h"
 #include "common/config-manager.h"
@@ -129,7 +130,7 @@
 	Common::addDebugChannel(kDebugHotspots, "Hotspots", "Hotspots debug level");
 	Common::addDebugChannel(kDebugDemo, "Demo", "Demo script debug level");
 
-	syst->getEventManager()->registerRandomSource(_rnd, "gob");
+	g_eventRec.registerRandomSource(_rnd, "gob");
 }
 
 GobEngine::~GobEngine() {

Modified: scummvm/trunk/engines/gob/sound/bgatmosphere.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound/bgatmosphere.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/gob/sound/bgatmosphere.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -25,6 +25,7 @@
 
 #include "common/system.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #include "gob/sound/bgatmosphere.h"
 #include "gob/sound/sounddesc.h"
@@ -39,7 +40,7 @@
 	_shaded = false;
 	_shadable = true;
 
-	g_system->getEventManager()->registerRandomSource(_rnd, "gobBA");
+	g_eventRec.registerRandomSource(_rnd, "gobBA");
 }
 
 BackgroundAtmosphere::~BackgroundAtmosphere() {

Modified: scummvm/trunk/engines/groovie/script.cpp
===================================================================
--- scummvm/trunk/engines/groovie/script.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/groovie/script.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -33,6 +33,7 @@
 #include "common/config-manager.h"
 #include "common/endian.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #define NUM_OPCODES 90
 
@@ -73,7 +74,7 @@
 	}
 
 	// Initialize the random source
-	_vm->_system->getEventManager()->registerRandomSource(_random, "GroovieScripts");
+	g_eventRec.registerRandomSource(_random, "GroovieScripts");
 
 	// Prepare the variables
 	_bitflags = 0;

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -24,6 +24,7 @@
  */
 
 #include "common/config-manager.h"
+#include "common/EventRecorder.h"
 
 #include "sound/mididrv.h"
 #include "sound/mixer.h"
@@ -81,7 +82,7 @@
 	Common::addDebugChannel(kDebugLevelMovie, "Movie", "Movie debug level");
 	Common::addDebugChannel(kDebugLevelTimer, "Timer", "Timer debug level");
 
-	_eventMan->registerRandomSource(_rnd, "kyra");
+	g_eventRec.registerRandomSource(_rnd, "kyra");
 }
 
 ::GUI::Debugger *KyraEngine_v1::getDebugger() {

Modified: scummvm/trunk/engines/kyra/sprites.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sprites.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/kyra/sprites.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -28,6 +28,8 @@
 #include "common/stream.h"
 #include "common/util.h"
 #include "common/system.h"
+#include "common/EventRecorder.h"
+
 #include "kyra/screen.h"
 #include "kyra/kyra_lok.h"
 #include "kyra/sprites.h"
@@ -47,7 +49,7 @@
 	_spriteDefStart = 0;
 	memset(_drawLayerTable, 0, sizeof(_drawLayerTable));
 	_sceneAnimatorBeaconFlag = 0;
-	_vm->getEventManager()->registerRandomSource(_rnd, "kyraSprites");
+	g_eventRec.registerRandomSource(_rnd, "kyraSprites");
 }
 
 Sprites::~Sprites() {

Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/lure/hotspots.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -38,6 +38,7 @@
 #include "lure/sound.h"
 #include "lure/lure.h"
 #include "common/endian.h"
+#include "common/EventRecorder.h"
 
 namespace Lure {
 
@@ -600,7 +601,7 @@
 	Common::RandomSource rnd;
 	int16 xp, yp;
 
-	g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+	g_eventRec.registerRandomSource(rnd, "lureHotspots");
 
 	if (currentActions().isEmpty())
 		currentActions().addFront(START_WALKING, roomNumber());
@@ -3147,7 +3148,7 @@
 	Common::RandomSource rnd;
 	RandomActionType actionType;
 	uint16 scheduleId;
-	g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+	g_eventRec.registerRandomSource(rnd, "lureHotspots");
 
 	int actionIndex = rnd.getRandomNumber(set->numActions() - 1);
 	set->getEntry(actionIndex, actionType, scheduleId);
@@ -3337,7 +3338,7 @@
 	ValueTableData &fields = Resources::getReference().fieldList();
 	Common::RandomSource rnd;
 
-	g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+	g_eventRec.registerRandomSource(rnd, "lureHotspots");
 
 	h.handleTalkDialog();
 	if (h.frameCtr() > 0) {
@@ -3380,7 +3381,7 @@
 	if (h.executeScript()) {
 		// Script is done - set new script to one of two alternates randomly
 		Common::RandomSource rnd;
-		g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+		g_eventRec.registerRandomSource(rnd, "lureHotspots");
 
 		h.setHotspotScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
 		h.setFrameCtr(20 + rnd.getRandomNumber(63));
@@ -3680,7 +3681,7 @@
 	Common::RandomSource rnd;
 	static bool ewanXOffset = false;
 
-	g_system->getEventManager()->registerRandomSource(rnd, "lureHotspots");
+	g_eventRec.registerRandomSource(rnd, "lureHotspots");
 
 	h.handleTalkDialog();
 	if (h.delayCtr() > 0) {

Modified: scummvm/trunk/engines/lure/res.cpp
===================================================================
--- scummvm/trunk/engines/lure/res.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/lure/res.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -30,6 +30,7 @@
 #include "lure/lure.h"
 #include "common/endian.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 namespace Lure {
 
@@ -42,7 +43,7 @@
 }
 
 Resources::Resources() {
-	g_system->getEventManager()->registerRandomSource(_rnd, "lureResources");
+	g_eventRec.registerRandomSource(_rnd, "lureResources");
 	int_resources = this;
 	reloadData();
 

Modified: scummvm/trunk/engines/lure/scripts.cpp
===================================================================
--- scummvm/trunk/engines/lure/scripts.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/lure/scripts.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -34,6 +34,7 @@
 #include "lure/sound.h"
 #include "common/stack.h"
 #include "common/endian.h"
+#include "common/EventRecorder.h"
 
 namespace Lure {
 
@@ -739,7 +740,7 @@
 
 void Script::randomToGeneral(uint16 maxVal, uint16 minVal, uint16 v3) {
 	Common::RandomSource rnd;
-	g_system->getEventManager()->registerRandomSource(rnd, "lureScripts");
+	g_eventRec.registerRandomSource(rnd, "lureScripts");
 	uint16 v = minVal + rnd.getRandomNumber(maxVal - minVal);
 	Resources::getReference().fieldList().setField(GENERAL, v);
 }

Modified: scummvm/trunk/engines/m4/m4.cpp
===================================================================
--- scummvm/trunk/engines/m4/m4.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/m4/m4.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -53,6 +53,7 @@
 
 #include "common/file.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/endian.h"
 #include "common/system.h"
 #include "common/config-manager.h"
@@ -192,7 +193,7 @@
 	_animation = new Animation(this);
 	//_callbacks = new Callbacks(this);
 	_random = new Common::RandomSource();
-	g_system->getEventManager()->registerRandomSource(*_random, "m4");
+	g_eventRec.registerRandomSource(*_random, "m4");
 
 	if (isM4())
 		return goM4();

Modified: scummvm/trunk/engines/made/made.cpp
===================================================================
--- scummvm/trunk/engines/made/made.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/made/made.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -24,6 +24,7 @@
  */
 
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/keyboard.h"
 #include "common/file.h"
 #include "common/savefile.h"
@@ -74,7 +75,7 @@
 			_gameId = g->id;
 
 	_rnd = new Common::RandomSource();
-	syst->getEventManager()->registerRandomSource(*_rnd, "made");
+	g_eventRec.registerRandomSource(*_rnd, "made");
 
 	int cd_num = ConfMan.getInt("cdrom");
 	if (cd_num >= 0)

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -25,6 +25,7 @@
 
 #include "common/config-manager.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/file.h"
 #include "common/util.h"
 #include "common/system.h"
@@ -70,7 +71,7 @@
 	Common::addDebugChannel(kDebugMenu, "menu", "Menu debug level");
 	Common::addDebugChannel(kDebugInventory, "inventory", "Inventory debug level");
 
-	syst->getEventManager()->registerRandomSource(_rnd, "parallaction");
+	g_eventRec.registerRandomSource(_rnd, "parallaction");
 }
 
 

Modified: scummvm/trunk/engines/queen/display.cpp
===================================================================
--- scummvm/trunk/engines/queen/display.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/queen/display.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -25,6 +25,7 @@
 
 
 #include "common/system.h"
+#include "common/EventRecorder.h"
 #include "common/events.h"
 
 #include "graphics/cursorman.h"
@@ -74,7 +75,7 @@
 	memset(&_dynalum, 0, sizeof(_dynalum));
 
 	setupInkColors();
-	system->getEventManager()->registerRandomSource(_rnd, "queenDisplay");
+	g_eventRec.registerRandomSource(_rnd, "queenDisplay");
 }
 
 Display::~Display() {

Modified: scummvm/trunk/engines/queen/music.cpp
===================================================================
--- scummvm/trunk/engines/queen/music.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/queen/music.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -25,6 +25,7 @@
 
 #include "common/config-manager.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #include "queen/music.h"
 #include "queen/queen.h"
@@ -84,7 +85,7 @@
 	_parser->setMidiDriver(this);
 	_parser->setTimerRate(_driver->getBaseTempo());
 
-	vm->getEventManager()->registerRandomSource(_rnd, "queenMusic");
+	g_eventRec.registerRandomSource(_rnd, "queenMusic");
 }
 
 MidiMusic::~MidiMusic() {

Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/queen/queen.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -31,6 +31,7 @@
 #include "common/savefile.h"
 #include "common/system.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #include "queen/queen.h"
 #include "queen/bankman.h"
@@ -193,7 +194,7 @@
 
 QueenEngine::QueenEngine(OSystem *syst)
 	: Engine(syst), _debugger(0) {
-	syst->getEventManager()->registerRandomSource(randomizer, "queen");
+	g_eventRec.registerRandomSource(randomizer, "queen");
 }
 
 QueenEngine::~QueenEngine() {

Modified: scummvm/trunk/engines/saga/saga.cpp
===================================================================
--- scummvm/trunk/engines/saga/saga.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/saga/saga.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -29,6 +29,7 @@
 #include "common/config-manager.h"
 #include "common/system.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #include "sound/mixer.h"
 
@@ -114,7 +115,7 @@
 	Common::File::addDefaultDirectory(_gameDataDir.getChild("video"));
 
 	_displayClip.left = _displayClip.top = 0;
-	syst->getEventManager()->registerRandomSource(_rnd, "saga");
+	g_eventRec.registerRandomSource(_rnd, "saga");
 }
 
 SagaEngine::~SagaEngine() {

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -26,6 +26,7 @@
 #include "common/config-manager.h"
 #include "common/md5.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/system.h"
 
 #include "gui/message.h"
@@ -539,7 +540,7 @@
 	for (int i = 0; i < ARRAYSIZE(debugChannels); ++i)
 		Common::addDebugChannel(debugChannels[i].flag,  debugChannels[i].channel, debugChannels[i].desc);
 
-	syst->getEventManager()->registerRandomSource(_rnd, "scumm");
+	g_eventRec.registerRandomSource(_rnd, "scumm");
 }
 
 

Modified: scummvm/trunk/engines/sky/logic.cpp
===================================================================
--- scummvm/trunk/engines/sky/logic.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/sky/logic.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -27,6 +27,7 @@
 #include "common/endian.h"
 #include "common/rect.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/system.h"
 
 #include "sky/autoroute.h"
@@ -73,7 +74,7 @@
 }
 
 Logic::Logic(SkyCompact *skyCompact, Screen *skyScreen, Disk *skyDisk, Text *skyText, MusicBase *skyMusic, Mouse *skyMouse, Sound *skySound) {
-	g_system->getEventManager()->registerRandomSource(_rnd, "sky");
+	g_eventRec.registerRandomSource(_rnd, "sky");
 
 	_skyCompact = skyCompact;
 	_skyScreen = skyScreen;

Modified: scummvm/trunk/engines/sword1/logic.cpp
===================================================================
--- scummvm/trunk/engines/sword1/logic.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/sword1/logic.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -28,6 +28,7 @@
 #include "common/util.h"
 #include "common/system.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 
 #include "sword1/logic.h"
 #include "sword1/text.h"
@@ -55,7 +56,7 @@
 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_system->getEventManager()->registerRandomSource(_rnd, "sword1");
+	g_eventRec.registerRandomSource(_rnd, "sword1");
 
 	_vm = vm;
 	_objMan = pObjMan;

Modified: scummvm/trunk/engines/sword1/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sound.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/sword1/sound.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -28,6 +28,7 @@
 
 #include "common/util.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/system.h"
 
 #include "sword1/sound.h"
@@ -47,7 +48,7 @@
 #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");
+	g_eventRec.registerRandomSource(_rnd, "sword1sound");
 	strcpy(_filePath, searchPath);
 	_mixer = mixer;
 	_resMan = pResMan;

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -33,6 +33,7 @@
 #include "common/file.h"
 #include "common/fs.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/savefile.h"
 #include "common/system.h"
 
@@ -305,7 +306,7 @@
 
 	_gmmLoadSlot = -1; // Used to manage GMM Loading
 
-	syst->getEventManager()->registerRandomSource(_rnd, "sword2");
+	g_eventRec.registerRandomSource(_rnd, "sword2");
 }
 
 Sword2Engine::~Sword2Engine() {

Modified: scummvm/trunk/engines/tinsel/tinsel.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/tinsel.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/tinsel/tinsel.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -26,6 +26,7 @@
 #include "common/endian.h"
 #include "common/error.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/keyboard.h"
 #include "common/file.h"
 #include "common/savefile.h"
@@ -934,7 +935,7 @@
 		_screenSurface.create(320, 200, 1);
 	}
 
-	g_system->getEventManager()->registerRandomSource(_random, "tinsel");
+	g_eventRec.registerRandomSource(_random, "tinsel");
 
 	_console = new Console();
 

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2009-07-25 12:53:00 UTC (rev 42750)
+++ scummvm/trunk/engines/touche/touche.cpp	2009-07-25 12:59:46 UTC (rev 42751)
@@ -26,6 +26,7 @@
 
 #include "common/config-manager.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/system.h"
 
 #include "graphics/cursorman.h"
@@ -73,7 +74,7 @@
 	Common::addDebugChannel(kDebugOpcodes,  "Opcodes",  "Opcodes debug level");
 	Common::addDebugChannel(kDebugMenu,     "Menu",     "Menu debug level");
 
-	_eventMan->registerRandomSource(_rnd, "touche");
+	g_eventRec.registerRandomSource(_rnd, "touche");
 }
 
 ToucheEngine::~ToucheEngine() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list