diff options
author | Andrew Kurushin | 2005-04-28 17:19:43 +0000 |
---|---|---|
committer | Andrew Kurushin | 2005-04-28 17:19:43 +0000 |
commit | 3b1f8da4beedf60b41f5226f314bffc221965c20 (patch) | |
tree | 895f83d6223f88a186c7ae69eaa833c9844f7d62 /saga | |
parent | 589b65945ac2b257a88c15808f5c35fe4a74aff6 (diff) | |
download | scummvm-rg350-3b1f8da4beedf60b41f5226f314bffc221965c20.tar.gz scummvm-rg350-3b1f8da4beedf60b41f5226f314bffc221965c20.tar.bz2 scummvm-rg350-3b1f8da4beedf60b41f5226f314bffc221965c20.zip |
save load preparetion
svn-id: r17852
Diffstat (limited to 'saga')
-rw-r--r-- | saga/actor.cpp | 45 | ||||
-rw-r--r-- | saga/actor.h | 26 | ||||
-rw-r--r-- | saga/saveload.cpp | 21 |
3 files changed, 65 insertions, 27 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index d879c70ed4..1990e1ef5f 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -2292,6 +2292,51 @@ void Actor::drawPathTest() { #endif } +void Actor::saveState(File& out) { + uint16 i; + + out.writeSint32LE(_centerActor == NULL ? -1 : _centerActor->index); + out.writeSint32LE(_protagonist == NULL ? -1 : _protagonist->index); + out.writeSint16LE(getProtagState()); + + for (i = 0; i < _actorsCount; i++) { + ActorData *a = _actors[i]; + a->saveState(out); + } + + //TODO: save _activeSpeech + + for (i = 0; i < _objsCount; i++) { + ObjectData *o = _objs[i]; + o->saveState(out); + } +} + +void Actor::loadState(File& in) { + int32 i; + + i = in.readSint32LE(); + _centerActor = (i < 0) ? NULL : _actors[i]; + + i = in.readSint32LE(); + _protagonist = (i < 0) ? NULL : _actors[i]; + + setProtagState(in.readSint16LE()); + + //TODO: load _activeSpeech + + for (i = 0; i < _actorsCount; i++) { + ActorData *a = _actors[i]; + a->loadState(in); + } + + + for (i = 0; i < _objsCount; i++) { + ObjectData *o = _objs[i]; + o->loadState(in); + } +} + // Console wrappers - must be safe to run void Actor::cmdActorWalkTo(int argc, const char **argv) { diff --git a/saga/actor.h b/saga/actor.h index 243c426c88..93a36d7ad3 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -428,9 +428,6 @@ class Actor { friend class IsoMap; friend class SagaEngine; public: - ActorData *_centerActor; - ActorData *_protagonist; - StringsTable _actorsStrings; Actor(SagaEngine *vm); ~Actor(); @@ -496,6 +493,9 @@ public: return _activeSpeech.stringsCount > 0; } + void saveState(File& out); + void loadState(File& in); + void setProtagState(int state); int getProtagState() { return _protagState; } @@ -537,22 +537,32 @@ private: void removePathPoints(); bool validFollowerLocation(const Location &location); - int _lastTickMsec; - SagaEngine *_vm; - RSCFILE_CONTEXT *_actorContext; - CommonObjectOrderList _drawOrderList; protected: +//constants int _actorsCount; ActorData **_actors; int _objsCount; ObjectData **_objs; -private: + SagaEngine *_vm; + RSCFILE_CONTEXT *_actorContext; + + StringsTable _actorsStrings; + int _lastTickMsec; + CommonObjectOrderList _drawOrderList; + +//variables +public: + ActorData *_centerActor; + ActorData *_protagonist; + +protected: SpeechData _activeSpeech; int _protagState; +private: //path stuff struct PathNode { Point point; diff --git a/saga/saveload.cpp b/saga/saveload.cpp index a0daf0e93f..37d1933991 100644 --- a/saga/saveload.cpp +++ b/saga/saveload.cpp @@ -46,7 +46,6 @@ void SagaEngine::save() { //TODO: version number out.writeSint16LE(_script->_commonBufferSize); - out.writeSint16LE(_actor->getProtagState()); // Surrounding scene out.writeSint32LE(_scene->getOutsetSceneNumber()); @@ -58,15 +57,7 @@ void SagaEngine::save() { uint16 i; - for (i = 0; i < _actor->_actorsCount; i++) { - ActorData *a = _actor->_actors[i]; - a->saveState(out); - } - - for (i = 0; i < _actor->_objsCount; i++) { - ObjectData *o = _actor->_objs[i]; - o->saveState(out); - } + _actor->saveState(out); for (i = 0; i < _script->_commonBufferSize; i++) out.writeByte(_script->_commonBuffer[i]); @@ -89,7 +80,6 @@ void SagaEngine::load() { return; commonBufferSize = in.readSint16LE(); - _actor->setProtagState(in.readSint16LE()); // Surrounding scene scenenum = in.readSint32LE(); @@ -103,17 +93,10 @@ void SagaEngine::load() { uint16 i; - for (i = 0; i < _actor->_actorsCount; i++) { - ActorData *a = _actor->_actors[i]; - a->loadState(in); - } _interface->clearInventory(); //TODO: interface load-save-state - for (i = 0; i < _actor->_objsCount; i++) { - ObjectData *o = _actor->_objs[i]; - o->loadState(in); - } + _actor->loadState(in); for (i = 0; i < commonBufferSize; i++) _script->_commonBuffer[i] = in.readByte(); |