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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Nov 19 01:38:17 CET 2010


Revision: 54355
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54355&view=rev
Author:   fingolfin
Date:     2010-11-19 00:38:17 +0000 (Fri, 19 Nov 2010)

Log Message:
-----------
COMMON: Cleanup EventRecorder

Modified Paths:
--------------
    scummvm/trunk/common/EventRecorder.cpp
    scummvm/trunk/common/EventRecorder.h
    scummvm/trunk/engines/toon/toon.cpp

Modified: scummvm/trunk/common/EventRecorder.cpp
===================================================================
--- scummvm/trunk/common/EventRecorder.cpp	2010-11-19 00:20:15 UTC (rev 54354)
+++ scummvm/trunk/common/EventRecorder.cpp	2010-11-19 00:38:17 UTC (rev 54355)
@@ -27,6 +27,7 @@
 
 #include "common/config-manager.h"
 #include "common/random.h"
+#include "common/savefile.h"
 
 DECLARE_SINGLETON(Common::EventRecorder);
 
@@ -35,25 +36,25 @@
 #define RECORD_SIGNATURE 0x54455354
 #define RECORD_VERSION 1
 
-void readRecord(Common::InSaveFile *inFile, uint32 &diff, Common::Event &event) {
+void readRecord(SeekableReadStream *inFile, uint32 &diff, Event &event) {
 	diff = inFile->readUint32LE();
 
-	event.type = (Common::EventType)inFile->readUint32LE();
+	event.type = (EventType)inFile->readUint32LE();
 
 	switch (event.type) {
-	case Common::EVENT_KEYDOWN:
-	case Common::EVENT_KEYUP:
-		event.kbd.keycode = (Common::KeyCode)inFile->readSint32LE();
+	case EVENT_KEYDOWN:
+	case EVENT_KEYUP:
+		event.kbd.keycode = (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:
+	case EVENT_MOUSEMOVE:
+	case EVENT_LBUTTONDOWN:
+	case EVENT_LBUTTONUP:
+	case EVENT_RBUTTONDOWN:
+	case EVENT_RBUTTONUP:
+	case EVENT_WHEELUP:
+	case EVENT_WHEELDOWN:
 		event.mouse.x = inFile->readSint16LE();
 		event.mouse.y = inFile->readSint16LE();
 		break;
@@ -62,25 +63,25 @@
 	}
 }
 
-void writeRecord(Common::OutSaveFile *outFile, uint32 diff, const Common::Event &event) {
+void writeRecord(WriteStream *outFile, uint32 diff, const Event &event) {
 	outFile->writeUint32LE(diff);
 
 	outFile->writeUint32LE((uint32)event.type);
 
 	switch (event.type) {
-	case Common::EVENT_KEYDOWN:
-	case Common::EVENT_KEYUP:
+	case EVENT_KEYDOWN:
+	case 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:
+	case EVENT_MOUSEMOVE:
+	case EVENT_LBUTTONDOWN:
+	case EVENT_LBUTTONUP:
+	case EVENT_RBUTTONDOWN:
+	case EVENT_RBUTTONUP:
+	case EVENT_WHEELUP:
+	case EVENT_WHEELDOWN:
 		outFile->writeSint16LE(event.mouse.x);
 		outFile->writeSint16LE(event.mouse.y);
 		break;
@@ -109,7 +110,7 @@
 }
 
 void EventRecorder::init() {
-	Common::String recordModeString = ConfMan.get("record_mode");
+	String recordModeString = ConfMan.get("record_mode");
 	if (recordModeString.compareToIgnoreCase("record") == 0) {
 		_recordMode = kRecorderRecord;
 	} else {
@@ -236,7 +237,7 @@
 
 		for (uint i = 0; i < _recordCount; ++i) {
 			uint32 tempDiff;
-			Common::Event tempEvent;
+			Event tempEvent;
 			readRecord(_playbackFile, tempDiff, tempEvent);
 			writeRecord(_recordFile, tempDiff, tempEvent);
 		}
@@ -252,7 +253,7 @@
 	g_system->deleteMutex(_recorderMutex);
 }
 
-void EventRecorder::registerRandomSource(Common::RandomSource &rnd, const char *name) {
+void EventRecorder::registerRandomSource(RandomSource &rnd, const char *name) {
 	if (_recordMode == kRecorderRecord) {
 		RandomSourceRecord rec;
 		rec.name = name;
@@ -305,11 +306,11 @@
 	g_system->unlockMutex(_timeMutex);
 }
 
-bool EventRecorder::notifyEvent(const Common::Event &ev) {
+bool EventRecorder::notifyEvent(const Event &ev) {
 	if (_recordMode != kRecorderRecord)
 		return false;
 
-	Common::StackLock lock(_recorderMutex);
+	StackLock lock(_recorderMutex);
 	++_eventCount;
 
 	writeRecord(_recordFile, _eventCount - _lastEventCount, ev);
@@ -320,11 +321,11 @@
 	return false;
 }
 
-bool EventRecorder::pollEvent(Common::Event &ev) {
+bool EventRecorder::pollEvent(Event &ev) {
 	if (_recordMode != kRecorderPlayback)
 		return false;
 
-	Common::StackLock lock(_recorderMutex);
+	StackLock lock(_recorderMutex);
 	++_eventCount;
 
 	if (!_hasPlaybackEvent) {
@@ -338,13 +339,13 @@
 	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:
+			case EVENT_MOUSEMOVE:
+			case EVENT_LBUTTONDOWN:
+			case EVENT_LBUTTONUP:
+			case EVENT_RBUTTONDOWN:
+			case EVENT_RBUTTONUP:
+			case EVENT_WHEELUP:
+			case EVENT_WHEELDOWN:
 				g_system->warpMouse(_playbackEvent.mouse.x, _playbackEvent.mouse.y);
 				break;
 			default:

Modified: scummvm/trunk/common/EventRecorder.h
===================================================================
--- scummvm/trunk/common/EventRecorder.h	2010-11-19 00:20:15 UTC (rev 54354)
+++ scummvm/trunk/common/EventRecorder.h	2010-11-19 00:38:17 UTC (rev 54355)
@@ -29,7 +29,6 @@
 #include "common/scummsys.h"
 #include "common/events.h"
 #include "common/singleton.h"
-#include "common/savefile.h"
 #include "common/mutex.h"
 #include "common/array.h"
 
@@ -38,6 +37,8 @@
 namespace Common {
 
 class RandomSource;
+class SeekableReadStream;
+class WriteStream;
 
 /**
  * Our generic event recorder.
@@ -45,7 +46,7 @@
  * TODO: Add more documentation.
  */
 class EventRecorder : private EventSource, private EventObserver, public Singleton<EventRecorder> {
-	friend class Common::Singleton<SingletonBaseType>;
+	friend class Singleton<SingletonBaseType>;
 	EventRecorder();
 	~EventRecorder();
 public:
@@ -53,40 +54,40 @@
 	void deinit();
 
 	/** Register random source so it can be serialized in game test purposes */
-	void registerRandomSource(Common::RandomSource &rnd, const char *name);
+	void registerRandomSource(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 notifyEvent(const Event &ev);
+	bool pollEvent(Event &ev);
 	bool allowMapping() const { return false; }
 
 	class RandomSourceRecord {
 	public:
-		Common::String name;
+		String name;
 		uint32 seed;
 	};
-	Common::Array<RandomSourceRecord> _randomSourceRecords;
+	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;
+	WriteStream *_recordFile;
+	WriteStream *_recordTimeFile;
+	MutexRef _timeMutex;
+	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;
+	Event _playbackEvent;
+	SeekableReadStream *_playbackFile;
+	SeekableReadStream *_playbackTimeFile;
 
 	volatile uint32 _eventCount;
 	volatile uint32 _lastEventCount;
@@ -97,9 +98,9 @@
 		kRecorderPlayback = 2
 	};
 	volatile RecordMode _recordMode;
-	Common::String _recordFileName;
-	Common::String _recordTempFileName;
-	Common::String _recordTimeFileName;
+	String _recordFileName;
+	String _recordTempFileName;
+	String _recordTimeFileName;
 };
 
 } // End of namespace Common

Modified: scummvm/trunk/engines/toon/toon.cpp
===================================================================
--- scummvm/trunk/engines/toon/toon.cpp	2010-11-19 00:20:15 UTC (rev 54354)
+++ scummvm/trunk/engines/toon/toon.cpp	2010-11-19 00:38:17 UTC (rev 54355)
@@ -29,6 +29,7 @@
 #include "common/archive.h"
 #include "common/config-manager.h"
 #include "common/EventRecorder.h"
+#include "common/savefile.h"
 #include "engines/util.h"
 #include "graphics/surface.h"
 #include "graphics/thumbnail.h"


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