More updates for the save/load system in IHNM

svn-id: r27540
This commit is contained in:
Filippos Karapetis 2007-06-19 01:37:48 +00:00
parent f6e2c67cbb
commit 153f325004
3 changed files with 20 additions and 12 deletions

View File

@ -535,6 +535,7 @@ public:
int actorIdToIndex(uint16 id) { return (id == ID_PROTAG ) ? 0 : objectIdToIndex(id); }
uint16 actorIndexToId(int index) { return (index == 0 ) ? ID_PROTAG : objectIndexToId(kGameObjectActor, index); }
ActorData *getActor(uint16 actorId);
ActorData *getFirstActor() { return _actors[0]; }
// clarification: Obj - means game object, such Hat, Spoon etc, Object - means Actor,Obj,HitZone,StepZone

View File

@ -192,9 +192,9 @@ void SagaEngine::save(const char *fileName, const char *saveName) {
// Surrounding scene
out->writeSint32LE(_scene->getOutsetSceneNumber());
if (getGameType() != GType_ITE) {
out->writeSint16LE(_scene->currentTrack());
out->writeSint32LE(_scene->currentChapterNumber());
// Protagonist
out->writeSint16LE(_scene->currentProtag());
out->writeSint32LE(_scene->currentProtag());
}
// Inset scene
@ -266,8 +266,10 @@ void SagaEngine::load(const char *fileName) {
sceneNumber = in->readSint32LE();
// Protagonist
if (getGameType() != GType_ITE) {
_scene->setTrack(in->readSint16LE());
_scene->setProtag(in->readSint16LE());
_scene->setChapterNumber(in->readSint32LE());
_scene->setProtag(in->readSint32LE());
if (_scene->currentChapterNumber())
_scene->changeScene(-2, 0, kTransitionFade, _scene->currentChapterNumber());
}
// Inset scene
@ -299,7 +301,16 @@ void SagaEngine::load(const char *fileName) {
// Protagonist swapping
if (getGameType() != GType_ITE) {
// TODO
if (_scene->currentProtag() != 0 && _scene->currentChapterNumber() != 6) {
ActorData *actor1 = _actor->getFirstActor();
ActorData *actor2 = _actor->getActor(_scene->currentProtag());
SWAP(actor1->_location, actor2->_location);
actor2->_flags &= ~kProtagonist;
actor1->_flags |= kProtagonist;
_actor->_protagonist = _actor->_centerActor = actor1;
_scene->setProtag(actor1->_id);
}
}
_scene->clearSceneQueue();

View File

@ -310,11 +310,8 @@ class Scene {
#endif
return _sceneLUT[sceneNumber];
}
int16 currentProtag() const { return _currentProtag; }
int16 currentTrack() const { return _currentTrack; }
void setProtag(int16 pr) { _currentProtag = pr; }
void setTrack(int16 tr) { _currentTrack = tr; }
int currentProtag() const { return _currentProtag; }
void setProtag(int pr) { _currentProtag = pr; }
int currentSceneNumber() const { return _sceneNumber; }
int currentChapterNumber() const { return _chapterNumber; }
void setChapterNumber(int ch) { _chapterNumber = ch; }
@ -352,8 +349,7 @@ class Scene {
int _sceneCount;
SceneQueueList _sceneQueue;
bool _sceneLoaded;
int16 _currentProtag;
int16 _currentTrack;
int _currentProtag;
int _sceneNumber;
int _chapterNumber;
int _outsetSceneNumber;