[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.382,1.383 actor.h,1.86,1.87 imuse.cpp,2.148,2.149 saveload.cpp,1.243,1.244 saveload.h,1.67,1.68
Max Horn
fingolfin at users.sourceforge.net
Fri Oct 21 16:02:45 CEST 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19491
Modified Files:
actor.cpp actor.h imuse.cpp saveload.cpp saveload.h
Log Message:
Started to make the save/load system slightly more object oriented
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.382
retrieving revision 1.383
diff -u -d -r1.382 -r1.383
--- actor.cpp 21 Oct 2005 12:06:03 -0000 1.382
+++ actor.cpp 21 Oct 2005 23:01:13 -0000 1.383
@@ -2134,7 +2134,7 @@
#endif
-const SaveLoadEntry *Actor::getSaveLoadEntries() {
+void Actor::saveLoadWithSerializer(Serializer *ser) {
static const SaveLoadEntry actorEntries[] = {
MKLINE(Actor, _pos.x, sleInt16, VER(8)),
MKLINE(Actor, _pos.y, sleInt16, VER(8)),
@@ -2234,7 +2234,14 @@
MKEND()
};
- return actorEntries;
+ if (ser->isLoading()) {
+ // Not all actor data is saved; so when loading, we first reset
+ // the actor, to ensure completely reproducible behaviour (else,
+ // some not saved value in the actor class can cause odd things)
+ initActor(-1);
+ }
+
+ ser->saveLoadEntries(this, actorEntries);
}
} // End of namespace Scumm
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- actor.h 21 Oct 2005 12:06:03 -0000 1.86
+++ actor.h 21 Oct 2005 23:01:13 -0000 1.87
@@ -25,6 +25,7 @@
#define ACTOR_H
#include "common/scummsys.h"
+#include "scumm/saveload.h"
#include "scumm/scumm.h"
@@ -81,9 +82,7 @@
byte box;
};
-struct SaveLoadEntry;
-
-class Actor {
+class Actor : public Serializable {
public:
static byte kInvalidBox;
@@ -277,8 +276,8 @@
void setTalkCondition(int slot);
bool isTalkConditionSet(int slot) const;
- // Used by the save/load syste:
- static const SaveLoadEntry *getSaveLoadEntries();
+ // Used by the save/load system:
+ void saveLoadWithSerializer(Serializer *ser);
protected:
bool isInClass(int cls);
Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 2.148
retrieving revision 2.149
diff -u -d -r2.148 -r2.149
--- imuse.cpp 18 Oct 2005 01:30:20 -0000 2.148
+++ imuse.cpp 21 Oct 2005 23:01:13 -0000 2.149
@@ -1603,7 +1603,7 @@
for (i = 0; i < 8; ++i)
ser->saveLoadEntries(0, volumeFaderEntries);
- if (!ser->isSaving()) {
+ if (ser->isLoading()) {
// Load all sounds that we need
fix_players_after_load(scumm);
fix_parts_after_load();
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -d -r1.243 -r1.244
--- saveload.cpp 19 Oct 2005 12:15:36 -0000 1.243
+++ saveload.cpp 21 Oct 2005 23:01:13 -0000 1.244
@@ -625,7 +625,6 @@
MKEND()
};
- const SaveLoadEntry *actorEntries = Actor::getSaveLoadEntries();
const SaveLoadEntry *soundEntries = _sound->getSaveLoadEntries();
const SaveLoadEntry verbEntries[] = {
@@ -951,14 +950,8 @@
//
// Save/load actors
//
- if (s->isLoading()) {
- // Not all actor data is saved; so when loading, we first reset
- // all actors, to ensure completely reproducible behaviour (else,
- // some not saved value in the actor class can cause odd things)
- for (i = 0; i < _numActors; i++)
- _actors[i].initActor(-1);
- }
- s->saveLoadArrayOf(_actors, _numActors, sizeof(_actors[0]), actorEntries);
+ for (i = 0; i < _numActors; i++)
+ _actors[i].saveLoadWithSerializer(s);
//
Index: saveload.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- saveload.h 21 Oct 2005 12:06:03 -0000 1.67
+++ saveload.h 21 Oct 2005 23:01:13 -0000 1.68
@@ -133,6 +133,8 @@
_savegameVersion(savegameVersion)
{ }
+ // FIXME: Try to get rid of the _save_ref / _load_ref / _ref_me HACK !!!
+ // This is used by imuse...
SerializerSaveReference *_save_ref;
SerializerLoadReference *_load_ref;
void *_ref_me;
@@ -168,6 +170,14 @@
void loadEntries(void *d, const SaveLoadEntry *sle);
};
+
+// Mixin class / interface. Maybe call it ISerializable or SerializableMixin ?
+class Serializable {
+public:
+ virtual ~Serializable() {}
+ virtual void saveLoadWithSerializer(Serializer *ser) = 0;
+};
+
} // End of namespace Scumm
#endif
More information about the Scummvm-git-logs
mailing list