aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/tinsel/actors.cpp4
-rw-r--r--engines/tinsel/dialogs.cpp4
-rw-r--r--engines/tinsel/dialogs.h8
-rw-r--r--engines/tinsel/pcode.cpp6
-rw-r--r--engines/tinsel/pcode.h7
-rw-r--r--engines/tinsel/polygons.cpp4
-rw-r--r--engines/tinsel/saveload.cpp36
-rw-r--r--engines/tinsel/serializer.h141
-rw-r--r--engines/tinsel/timers.cpp4
-rw-r--r--engines/tinsel/timers.h8
-rw-r--r--engines/tinsel/tinsel.cpp4
11 files changed, 46 insertions, 180 deletions
diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp
index 279c482376..e9d0c9f79f 100644
--- a/engines/tinsel/actors.cpp
+++ b/engines/tinsel/actors.cpp
@@ -39,7 +39,7 @@
#include "tinsel/polygons.h"
#include "tinsel/rince.h"
#include "tinsel/sched.h"
-#include "tinsel/serializer.h"
+#include "common/serializer.h"
#include "tinsel/sysvar.h"
#include "tinsel/tinsel.h"
#include "tinsel/token.h"
@@ -1417,7 +1417,7 @@ void ActorsLife(int ano, bool bAlive) {
}
-void syncAllActorsAlive(Serializer &s) {
+void syncAllActorsAlive(Common::Serializer &s) {
for (int i = 0; i < MAX_SAVED_ALIVES; i++) {
s.syncAsByte(actorInfo[i].bAlive);
s.syncAsByte(actorInfo[i].tagged);
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 2987e091b3..c9487a62e3 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -50,7 +50,7 @@
#include "tinsel/polygons.h"
#include "tinsel/savescn.h"
#include "tinsel/sched.h"
-#include "tinsel/serializer.h"
+#include "common/serializer.h"
#include "tinsel/sound.h"
#include "tinsel/strres.h"
#include "tinsel/sysvar.h"
@@ -5475,7 +5475,7 @@ void SetObjectFilm(int object, SCNHANDLE hFilm) {
/**
* (Un)serialize the inventory data for save/restore game.
*/
-void syncInvInfo(Serializer &s) {
+void syncInvInfo(Common::Serializer &s) {
for (int i = 0; i < NUM_INV; i++) {
s.syncAsSint32LE(InvD[i].MinHicons);
s.syncAsSint32LE(InvD[i].MinVicons);
diff --git a/engines/tinsel/dialogs.h b/engines/tinsel/dialogs.h
index 670f695a06..91fb7f3240 100644
--- a/engines/tinsel/dialogs.h
+++ b/engines/tinsel/dialogs.h
@@ -31,9 +31,11 @@
#include "tinsel/dw.h"
#include "tinsel/events.h" // for PLR_EVENT, PLR_EVENT
-namespace Tinsel {
+namespace Common {
+ class Serializer;
+}
-class Serializer;
+namespace Tinsel {
enum {
INV_OPEN = -1, // DW1 only
@@ -146,7 +148,7 @@ bool IsInInventory(int object, int invnum);
void KillInventory(void);
-void syncInvInfo(Serializer &s);
+void syncInvInfo(Common::Serializer &s);
int InvGetLimit(int invno);
void InvSetLimit(int invno, int n);
diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp
index 33550b39e8..a9c6f43d85 100644
--- a/engines/tinsel/pcode.cpp
+++ b/engines/tinsel/pcode.cpp
@@ -31,7 +31,7 @@
#include "tinsel/dialogs.h" // for inventory id's
#include "tinsel/pcode.h" // opcodes etc.
#include "tinsel/scn.h" // FindChunk()
-#include "tinsel/serializer.h"
+#include "common/serializer.h"
#include "tinsel/timers.h"
#include "tinsel/tinlib.h" // Library routines
#include "tinsel/tinsel.h"
@@ -356,7 +356,7 @@ void FreeGlobals(void) {
/**
* (Un)serialize the global data for save/restore game.
*/
-void syncGlobInfo(Serializer &s) {
+void syncGlobInfo(Common::Serializer &s) {
for (int i = 0; i < numGlobals; i++) {
s.syncAsSint32LE(pGlobals[i]);
}
@@ -365,7 +365,7 @@ void syncGlobInfo(Serializer &s) {
/**
* (Un)serialize an interpreter context for save/restore game.
*/
-void INT_CONTEXT::syncWithSerializer(Serializer &s) {
+void INT_CONTEXT::syncWithSerializer(Common::Serializer &s) {
if (s.isLoading()) {
// Null out the pointer fields
pProc = NULL;
diff --git a/engines/tinsel/pcode.h b/engines/tinsel/pcode.h
index 0c75cc0df1..4bdfcf5626 100644
--- a/engines/tinsel/pcode.h
+++ b/engines/tinsel/pcode.h
@@ -30,10 +30,13 @@
#include "tinsel/events.h" // for TINSEL_EVENT
#include "tinsel/sched.h" // for PROCESS
+namespace Common {
+ class Serializer;
+}
+
namespace Tinsel {
// forward declaration
-class Serializer;
struct INV_OBJECT;
enum RESUME_STATE {
@@ -79,7 +82,7 @@ struct INT_CONTEXT {
RESCODE resumeCode;
RESUME_STATE resumeState;
- void syncWithSerializer(Serializer &s);
+ void syncWithSerializer(Common::Serializer &s);
};
typedef INT_CONTEXT *PINT_CONTEXT;
diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp
index cb5b21f0c0..8be174c779 100644
--- a/engines/tinsel/polygons.cpp
+++ b/engines/tinsel/polygons.cpp
@@ -30,7 +30,7 @@
#include "tinsel/polygons.h"
#include "tinsel/rince.h"
#include "tinsel/sched.h"
-#include "tinsel/serializer.h"
+#include "common/serializer.h"
#include "tinsel/tinsel.h"
#include "tinsel/token.h"
@@ -1198,7 +1198,7 @@ void RebootDeadTags(void) {
/**
* (Un)serialize the dead tag and exit data for save/restore game.
*/
-void syncPolyInfo(Serializer &s) {
+void syncPolyInfo(Common::Serializer &s) {
int i;
for (i = 0; i < MAX_SCENES; i++) {
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp
index 13c1fc58f2..b17ee93d4d 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -30,11 +30,11 @@
#include "tinsel/dw.h"
#include "tinsel/rince.h"
#include "tinsel/savescn.h"
-#include "tinsel/serializer.h"
#include "tinsel/timers.h"
#include "tinsel/tinlib.h"
#include "tinsel/tinsel.h"
+#include "common/serializer.h"
#include "common/savefile.h"
namespace Tinsel {
@@ -73,16 +73,16 @@ SRSTATE SRstate = SR_IDLE;
//----------------- EXTERN FUNCTIONS --------------------
// in DOS_DW.C
-extern void syncSCdata(Serializer &s);
+extern void syncSCdata(Common::Serializer &s);
// in DOS_MAIN.C
//char HardDriveLetter(void);
// in PCODE.C
-extern void syncGlobInfo(Serializer &s);
+extern void syncGlobInfo(Common::Serializer &s);
// in POLYGONS.C
-extern void syncPolyInfo(Serializer &s);
+extern void syncPolyInfo(Common::Serializer &s);
//----------------- LOCAL DEFINES --------------------
@@ -120,7 +120,7 @@ static char *SaveSceneSsData = 0; // points to 'SAVED_DATA ssdata[MAX_NEST]'
void setNeedLoad() { NeedLoad = true; }
-static void syncTime(Serializer &s, struct tm &t) {
+static void syncTime(Common::Serializer &s, struct tm &t) {
s.syncAsUint16LE(t.tm_year);
s.syncAsByte(t.tm_mon);
s.syncAsByte(t.tm_mday);
@@ -134,7 +134,7 @@ static void syncTime(Serializer &s, struct tm &t) {
}
}
-static bool syncSaveGameHeader(Serializer &s, SaveGameHeader &hdr) {
+static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) {
s.syncAsUint32LE(hdr.id);
s.syncAsUint32LE(hdr.size);
s.syncAsUint32LE(hdr.ver);
@@ -153,7 +153,7 @@ static bool syncSaveGameHeader(Serializer &s, SaveGameHeader &hdr) {
return true;
}
-static void syncSavedMover(Serializer &s, SAVED_MOVER &sm) {
+static void syncSavedMover(Common::Serializer &s, SAVED_MOVER &sm) {
SCNHANDLE *pList[3] = { (SCNHANDLE *)&sm.walkReels,
(SCNHANDLE *)&sm.standReels, (SCNHANDLE *)&sm.talkReels };
@@ -178,7 +178,7 @@ static void syncSavedMover(Serializer &s, SAVED_MOVER &sm) {
}
}
-static void syncSavedActor(Serializer &s, SAVED_ACTOR &sa) {
+static void syncSavedActor(Common::Serializer &s, SAVED_ACTOR &sa) {
s.syncAsUint16LE(sa.actorID);
s.syncAsUint16LE(sa.zFactor);
s.syncAsUint32LE(sa.bAlive);
@@ -188,33 +188,33 @@ static void syncSavedActor(Serializer &s, SAVED_ACTOR &sa) {
s.syncAsUint16LE(sa.presPlayY);
}
-extern void syncAllActorsAlive(Serializer &s);
+extern void syncAllActorsAlive(Common::Serializer &s);
-static void syncNoScrollB(Serializer &s, NOSCROLLB &ns) {
+static void syncNoScrollB(Common::Serializer &s, NOSCROLLB &ns) {
s.syncAsSint32LE(ns.ln);
s.syncAsSint32LE(ns.c1);
s.syncAsSint32LE(ns.c2);
}
-static void syncZPosition(Serializer &s, Z_POSITIONS &zp) {
+static void syncZPosition(Common::Serializer &s, Z_POSITIONS &zp) {
s.syncAsSint16LE(zp.actor);
s.syncAsSint16LE(zp.column);
s.syncAsSint32LE(zp.z);
}
-static void syncPolyVolatile(Serializer &s, POLY_VOLATILE &p) {
+static void syncPolyVolatile(Common::Serializer &s, POLY_VOLATILE &p) {
s.syncAsByte(p.bDead);
s.syncAsSint16LE(p.xoff);
s.syncAsSint16LE(p.yoff);
}
-static void syncSoundReel(Serializer &s, SOUNDREELS &sr) {
+static void syncSoundReel(Common::Serializer &s, SOUNDREELS &sr) {
s.syncAsUint32LE(sr.hFilm);
s.syncAsSint32LE(sr.column);
s.syncAsSint32LE(sr.actorCol);
}
-static void syncSavedData(Serializer &s, SAVED_DATA &sd) {
+static void syncSavedData(Common::Serializer &s, SAVED_DATA &sd) {
s.syncAsUint32LE(sd.SavedSceneHandle);
s.syncAsUint32LE(sd.SavedBgroundHandle);
for (int i = 0; i < MAX_MOVERS; ++i)
@@ -324,7 +324,7 @@ int getList(Common::SaveFileManager *saveFileMan, const Common::String &target)
}
// Try to load save game header
- Serializer s(f, 0);
+ Common::Serializer s(f, 0);
SaveGameHeader hdr;
bool validHeader = syncSaveGameHeader(s, hdr);
delete f;
@@ -379,7 +379,7 @@ char *ListEntry(int i, letype which) {
return NULL;
}
-static void DoSync(Serializer &s) {
+static void DoSync(Common::Serializer &s) {
int sg = 0;
if (TinselV2) {
@@ -433,7 +433,7 @@ static bool DoRestore() {
return false;
}
- Serializer s(f, 0);
+ Common::Serializer s(f, 0);
SaveGameHeader hdr;
if (!syncSaveGameHeader(s, hdr)) {
delete f; // Invalid header, or savegame too new -> skip it
@@ -474,7 +474,7 @@ static void DoSave(void) {
if (f == NULL)
return;
- Serializer s(0, f);
+ Common::Serializer s(0, f);
// Write out a savegame header
SaveGameHeader hdr;
diff --git a/engines/tinsel/serializer.h b/engines/tinsel/serializer.h
deleted file mode 100644
index cfb528776f..0000000000
--- a/engines/tinsel/serializer.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* 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$
- *
- * Handles timers.
- */
-
-#ifndef TINSEL_SERIALIZER_H
-#define TINSEL_SERIALIZER_H
-
-#include "common/scummsys.h"
-#include "common/savefile.h"
-
-
-namespace Tinsel {
-
-
-#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; \
- }
-
-
-// TODO: Write comment for this
-// TODO: Inspired by the SCUMM engine -- move to common/ code and use in more engines?
-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, uint32 size) {
- if (_loadStream)
- _loadStream->read(buf, size);
- else
- _saveStream->write(buf, size);
- _bytesSynced += size;
- }
-
- void skip(uint32 size) {
- if (_loadStream)
- _loadStream->skip(size);
- else {
- while (size--)
- _saveStream->writeByte(0);
- }
- _bytesSynced += 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
-
-// TODO: Make a subclass "VersionedSerializer", which makes it easy to support
-// multiple versions of a savegame format (again inspired by SCUMM).
-/*
-class VersionedSerializer : public Serializer {
-public:
- // "version" is the version of the savegame we are loading/creating
- VersionedSerializer(Common::SeekableReadStream *in, Common::OutSaveFile *out, int version)
- : Serializer(in, out), _version(version) {
- assert(in || out);
- }
-
- void syncBytes(byte *buf, uint16 size, int minVersion = 0, int maxVersion = INF) {
- if (_version < minVersion || _version > maxVersion)
- return; // Do nothing if too old or too new
- if (_loadStream) {
- _loadStream->read(buf, size);
- } else {
- _saveStream->write(buf, size);
- }
- }
- ...
-
-};
-
-*/
-
-// Mixin class / interface
-// TODO Maybe call it ISerializable or SerializableMixin ?
-// TODO: Taken from SCUMM engine -- move to common/ code?
-class Serializable {
-public:
- virtual ~Serializable() {}
- virtual void saveLoadWithSerializer(Serializer *ser) = 0;
-};
-
-
-} // end of namespace Tinsel
-
-#endif
diff --git a/engines/tinsel/timers.cpp b/engines/tinsel/timers.cpp
index fa74797dd9..a627b05c31 100644
--- a/engines/tinsel/timers.cpp
+++ b/engines/tinsel/timers.cpp
@@ -30,7 +30,7 @@
#include "tinsel/timers.h"
#include "tinsel/dw.h"
-#include "tinsel/serializer.h"
+#include "common/serializer.h"
#include "common/system.h"
@@ -81,7 +81,7 @@ void RebootTimers(void) {
/**
* (Un)serialize the timer data for save/restore game.
*/
-void syncTimerInfo(Serializer &s) {
+void syncTimerInfo(Common::Serializer &s) {
for (int i = 0; i < MAX_TIMERS; i++) {
s.syncAsSint32LE(timers[i].tno);
s.syncAsSint32LE(timers[i].ticks);
diff --git a/engines/tinsel/timers.h b/engines/tinsel/timers.h
index 2260074f1d..a03786ff97 100644
--- a/engines/tinsel/timers.h
+++ b/engines/tinsel/timers.h
@@ -30,9 +30,11 @@
#include "common/scummsys.h"
#include "tinsel/dw.h"
-namespace Tinsel {
+namespace Common {
+ class Serializer;
+}
-class Serializer;
+namespace Tinsel {
#define ONE_SECOND 24
@@ -40,7 +42,7 @@ uint32 DwGetCurrentTime(void);
void RebootTimers(void);
-void syncTimerInfo(Serializer &s);
+void syncTimerInfo(Common::Serializer &s);
void FettleTimers(void);
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 9562d57bc2..8fe0446932 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -30,6 +30,7 @@
#include "common/file.h"
#include "common/savefile.h"
#include "common/config-manager.h"
+#include "common/serializer.h"
#include "common/stream.h"
#include "graphics/cursorman.h"
@@ -60,7 +61,6 @@
#include "tinsel/polygons.h"
#include "tinsel/savescn.h"
#include "tinsel/scn.h"
-#include "tinsel/serializer.h"
#include "tinsel/sound.h"
#include "tinsel/strres.h"
#include "tinsel/sysvar.h"
@@ -614,7 +614,7 @@ void UnSuspendHook(void) {
bCuttingScene = false;
}
-void syncSCdata(Serializer &s) {
+void syncSCdata(Common::Serializer &s) {
s.syncAsUint32LE(HookScene.scene);
s.syncAsSint32LE(HookScene.entry);
s.syncAsSint32LE(HookScene.trans);