[Scummvm-cvs-logs] SF.net SVN: scummvm:[39443] scummvm/trunk/engines/cruise

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Mon Mar 16 10:17:50 CET 2009


Revision: 39443
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39443&view=rev
Author:   dreammaster
Date:     2009-03-16 09:17:49 +0000 (Mon, 16 Mar 2009)

Log Message:
-----------
Converted the Cruise engine to use the new Common::Serializer class

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/saveload.cpp
    scummvm/trunk/engines/cruise/saveload.h

Modified: scummvm/trunk/engines/cruise/saveload.cpp
===================================================================
--- scummvm/trunk/engines/cruise/saveload.cpp	2009-03-16 09:16:56 UTC (rev 39442)
+++ scummvm/trunk/engines/cruise/saveload.cpp	2009-03-16 09:17:49 UTC (rev 39443)
@@ -25,6 +25,7 @@
 
 #include "cruise/cruise_main.h"
 
+#include "common/serializer.h"
 #include "common/savefile.h"
 #include "common/system.h"
 
@@ -39,12 +40,12 @@
 
 overlayRestoreTemporary ovlRestoreData[90];
 
-static void syncPalette(Serializer &s, uint8 *p) {
+static void syncPalette(Common::Serializer &s, uint8 *p) {
 	// This is different from the original, where palette entries are 2 bytes each
 	s.syncBytes(p, NBCOLORS * 3);
 }
 
-static void syncBasicInfo(Serializer &s) {
+static void syncBasicInfo(Common::Serializer &s) {
 	s.syncAsSint16LE(songLoaded);
 	s.syncAsSint16LE(songPlayed);
 	s.syncAsSint16LE(songLoop);
@@ -107,7 +108,7 @@
 	s.syncAsSint16LE(entrerMenuJoueur);
 }
 
-static void syncBackgroundTable(Serializer &s) {
+static void syncBackgroundTable(Common::Serializer &s) {
 	// restore backgroundTable
 	for (int i = 0; i < 8; i++) {
 		s.syncString(backgroundTable[i].name, 9);
@@ -115,14 +116,14 @@
 	}
 }
 
-static void syncPalScreen(Serializer &s) {
+static void syncPalScreen(Common::Serializer &s) {
 	for (int i = 0; i < NBSCREENS; ++i) {
 		for (int j = 0; j < NBCOLORS; ++j)
 			s.syncAsUint16LE(palScreen[i][j]);
 	}
 }
 
-static void syncSoundList(Serializer &s) {
+static void syncSoundList(Common::Serializer &s) {
 	for (int i = 0; i < 4; ++i) {
 		SoundEntry &se = soundList[i];
 		s.syncAsSint16LE(se.frameNum);
@@ -131,7 +132,7 @@
 	}
 }
 
-static void syncFilesDatabase(Serializer &s) {
+static void syncFilesDatabase(Common::Serializer &s) {
 	uint8 dummyVal = 0;
 
 	for (int i = 0; i < NUM_FILE_ENTRIES; i++) {
@@ -173,7 +174,7 @@
 	}
 }
 
-static void syncPreloadData(Serializer &s) {
+static void syncPreloadData(Common::Serializer &s) {
 	uint8 dummyByte = 0;
 	uint32 dummyLong = 0;
 
@@ -191,7 +192,7 @@
 	}
 }
 
-static void syncOverlays1(Serializer &s) {
+static void syncOverlays1(Common::Serializer &s) {
 	uint8 dummyByte = 0;
 	uint32 dummyLong = 0;
 
@@ -211,7 +212,7 @@
 	}
 }
 
-static void syncOverlays2(Serializer &s) {
+static void syncOverlays2(Common::Serializer &s) {
 
 	for (int i = 1; i < numOfLoadedOverlay; i++) {
 
@@ -274,7 +275,7 @@
 	}
 }
 
-void syncScript(Serializer &s, scriptInstanceStruct *entry) {
+void syncScript(Common::Serializer &s, scriptInstanceStruct *entry) {
 	int numScripts = 0;
 	uint32 dummyLong = 0;
 	uint16 dummyWord = 0;
@@ -328,7 +329,7 @@
 	}
 }
 
-static void syncCell(Serializer &s) {
+static void syncCell(Common::Serializer &s) {
 	int chunkCount = 0;
 	cellStruct *t, *p;
 	uint16 dummyWord = 0;
@@ -389,7 +390,7 @@
 	}
 }
 
-static void syncIncrust(Serializer &s) {
+static void syncIncrust(Common::Serializer &s) {
 	int numEntries = 0;
 	backgroundIncrustStruct *pl, *pl1;
 	uint8 dummyByte = 0;
@@ -471,7 +472,7 @@
 	}
 }
 
-static void syncActors(Serializer &s) {
+static void syncActors(Common::Serializer &s) {
 	int numEntries = 0;
 	actorStruct *ptr;
 	uint16 dummyLong = 0;
@@ -522,7 +523,7 @@
 	}
 }
 
-static void syncSongs(Serializer &s) {
+static void syncSongs(Common::Serializer &s) {
 	int size = 0;
 
 	if (songLoaded) {
@@ -538,7 +539,7 @@
 	}
 }
 
-static void syncCT(Serializer &s) {
+static void syncCT(Common::Serializer &s) {
 	int v = (polyStruct) ? 1 : 0;
 	s.syncAsSint32LE(v);
 
@@ -573,7 +574,7 @@
 	}
 }
 
-static void DoSync(Serializer &s) {
+static void DoSync(Common::Serializer &s) {
 	syncBasicInfo(s);
 
 	syncPalette(s, newPal);
@@ -759,7 +760,7 @@
 	f->write(saveIdentBuffer, 6);
 
 	if (!f->ioFailed()) {
-		Serializer s(NULL, f);
+		Common::Serializer s(NULL, f);
 
 		DoSync(s);
 
@@ -801,7 +802,7 @@
 
 	initVars();
 
-	Serializer s(f, NULL);
+	Common::Serializer s(f, NULL);
 	DoSync(s);
 
 	delete f;

Modified: scummvm/trunk/engines/cruise/saveload.h
===================================================================
--- scummvm/trunk/engines/cruise/saveload.h	2009-03-16 09:16:56 UTC (rev 39442)
+++ scummvm/trunk/engines/cruise/saveload.h	2009-03-16 09:17:49 UTC (rev 39443)
@@ -27,74 +27,9 @@
 #define CRUISE_SAVELOAD_H
 
 #include "common/scummsys.h"
-#include "common/savefile.h"
 
 namespace Cruise {
 
-/* TODO: This code is copied verbatim from the Tinsel engine, and in turn was derived from
- * the SCUMM engine. As such it should probably be brought into the common codebase
- */
-#define SYNC_AS(SUFFIX,TYPE,SIZE) \
-	template <class T> \
-	void syncAs ## SUFFIX(T &val) { \
-		if (_loadStream) \
-			val = static_cast<T>(_loadStream->read ## SUFFIX()); \
-		else { \
-			TYPE tmp = val; \
-			_saveStream->write ## SUFFIX(tmp); \
-		} \
-		_bytesSynced += SIZE; \
-	}
-
-
-class Serializer {
-public:
-	Serializer(Common::SeekableReadStream *in, Common::OutSaveFile *out)
-		: _loadStream(in), _saveStream(out), _bytesSynced(0) {
-		assert(in || out);
-	}
-
-	bool isSaving() { return (_saveStream != 0); }
-	bool isLoading() { return (_loadStream != 0); }
-
-	uint bytesSynced() const { return _bytesSynced; }
-
-	void syncBytes(byte *buf, uint16 size) {
-		if (_loadStream)
-			_loadStream->read(buf, size);
-		else
-			_saveStream->write(buf, size);
-		_bytesSynced += size;
-	}
-
-	void syncString(char *buf, uint16 size) {
-		syncBytes((byte *)buf, size);
-	}
-
-	SYNC_AS(Byte, byte, 1)
-
-	SYNC_AS(Uint16LE, uint16, 2)
-	SYNC_AS(Uint16BE, uint16, 2)
-	SYNC_AS(Sint16LE, int16, 2)
-	SYNC_AS(Sint16BE, int16, 2)
-
-	SYNC_AS(Uint32LE, uint32, 4)
-	SYNC_AS(Uint32BE, uint32, 4)
-	SYNC_AS(Sint32LE, int32, 4)
-	SYNC_AS(Sint32BE, int32, 4)
-
-protected:
-	Common::SeekableReadStream *_loadStream;
-	Common::OutSaveFile *_saveStream;
-
-	uint _bytesSynced;
-};
-
-#undef SYNC_AS
-
-
-
-
 int saveSavegameData(int saveGameIdx);
 int loadSavegameData(int saveGameIdx);
 


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