Started to make the save/load system slightly more object oriented
svn-id: r19224
This commit is contained in:
parent
1185f51388
commit
ffc5e1718f
5 changed files with 26 additions and 17 deletions
|
@ -2134,7 +2134,7 @@ void ScummEngine_v71he::queueAuxEntry(int actorNum, int subIndex) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const SaveLoadEntry *Actor::getSaveLoadEntries() {
|
void Actor::saveLoadWithSerializer(Serializer *ser) {
|
||||||
static const SaveLoadEntry actorEntries[] = {
|
static const SaveLoadEntry actorEntries[] = {
|
||||||
MKLINE(Actor, _pos.x, sleInt16, VER(8)),
|
MKLINE(Actor, _pos.x, sleInt16, VER(8)),
|
||||||
MKLINE(Actor, _pos.y, sleInt16, VER(8)),
|
MKLINE(Actor, _pos.y, sleInt16, VER(8)),
|
||||||
|
@ -2234,7 +2234,14 @@ const SaveLoadEntry *Actor::getSaveLoadEntries() {
|
||||||
MKEND()
|
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
|
} // End of namespace Scumm
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define ACTOR_H
|
#define ACTOR_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
#include "scumm/saveload.h"
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,9 +82,7 @@ struct AdjustBoxResult { /* Result type of AdjustBox functions */
|
||||||
byte box;
|
byte box;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SaveLoadEntry;
|
class Actor : public Serializable {
|
||||||
|
|
||||||
class Actor {
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static byte kInvalidBox;
|
static byte kInvalidBox;
|
||||||
|
@ -277,8 +276,8 @@ public:
|
||||||
void setTalkCondition(int slot);
|
void setTalkCondition(int slot);
|
||||||
bool isTalkConditionSet(int slot) const;
|
bool isTalkConditionSet(int slot) const;
|
||||||
|
|
||||||
// Used by the save/load syste:
|
// Used by the save/load system:
|
||||||
static const SaveLoadEntry *getSaveLoadEntries();
|
void saveLoadWithSerializer(Serializer *ser);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isInClass(int cls);
|
bool isInClass(int cls);
|
||||||
|
|
|
@ -1603,7 +1603,7 @@ int IMuseInternal::save_or_load(Serializer *ser, ScummEngine *scumm) {
|
||||||
for (i = 0; i < 8; ++i)
|
for (i = 0; i < 8; ++i)
|
||||||
ser->saveLoadEntries(0, volumeFaderEntries);
|
ser->saveLoadEntries(0, volumeFaderEntries);
|
||||||
|
|
||||||
if (!ser->isSaving()) {
|
if (ser->isLoading()) {
|
||||||
// Load all sounds that we need
|
// Load all sounds that we need
|
||||||
fix_players_after_load(scumm);
|
fix_players_after_load(scumm);
|
||||||
fix_parts_after_load();
|
fix_parts_after_load();
|
||||||
|
|
|
@ -625,7 +625,6 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
|
||||||
MKEND()
|
MKEND()
|
||||||
};
|
};
|
||||||
|
|
||||||
const SaveLoadEntry *actorEntries = Actor::getSaveLoadEntries();
|
|
||||||
const SaveLoadEntry *soundEntries = _sound->getSaveLoadEntries();
|
const SaveLoadEntry *soundEntries = _sound->getSaveLoadEntries();
|
||||||
|
|
||||||
const SaveLoadEntry verbEntries[] = {
|
const SaveLoadEntry verbEntries[] = {
|
||||||
|
@ -951,14 +950,8 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
|
||||||
//
|
//
|
||||||
// Save/load actors
|
// 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++)
|
for (i = 0; i < _numActors; i++)
|
||||||
_actors[i].initActor(-1);
|
_actors[i].saveLoadWithSerializer(s);
|
||||||
}
|
|
||||||
s->saveLoadArrayOf(_actors, _numActors, sizeof(_actors[0]), actorEntries);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -133,6 +133,8 @@ public:
|
||||||
_savegameVersion(savegameVersion)
|
_savegameVersion(savegameVersion)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
// FIXME: Try to get rid of the _save_ref / _load_ref / _ref_me HACK !!!
|
||||||
|
// This is used by imuse...
|
||||||
SerializerSaveReference *_save_ref;
|
SerializerSaveReference *_save_ref;
|
||||||
SerializerLoadReference *_load_ref;
|
SerializerLoadReference *_load_ref;
|
||||||
void *_ref_me;
|
void *_ref_me;
|
||||||
|
@ -168,6 +170,14 @@ protected:
|
||||||
void loadEntries(void *d, const SaveLoadEntry *sle);
|
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
|
} // End of namespace Scumm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue