aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Boutonné2010-11-22 22:49:24 +0000
committerArnaud Boutonné2010-11-22 22:49:24 +0000
commit7711cc57d6777efa8591ea794912b1400faa250e (patch)
tree816ffcbe76115761dba45d6a331d913d13828fff
parent8bb43361cb02bbbb8964944de3b058bbab8f924d (diff)
downloadscummvm-rg350-7711cc57d6777efa8591ea794912b1400faa250e.tar.gz
scummvm-rg350-7711cc57d6777efa8591ea794912b1400faa250e.tar.bz2
scummvm-rg350-7711cc57d6777efa8591ea794912b1400faa250e.zip
HUGO: Rewrite saveObjects() and restoreObjects()
This fixes (at least for me) save and restore. saveEvents() and restoreEvents() still have to be rewritten. svn-id: r54422
-rw-r--r--engines/hugo/file.cpp2
-rw-r--r--engines/hugo/object.cpp69
2 files changed, 56 insertions, 15 deletions
diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp
index 336d44a1d3..0c2baffcae 100644
--- a/engines/hugo/file.cpp
+++ b/engines/hugo/file.cpp
@@ -420,7 +420,7 @@ void FileManager::restoreGame(int16 slot) {
status_t &gameStatus = _vm->getGameStatus();
- int score = in->readSint16LE();
+ int score = in->readSint16BE();
_vm->setScore(score);
gameStatus.storyModeFl = (in->readByte() == 1);
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index 0eede35dac..15f5e4fe06 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -47,7 +47,7 @@
namespace Hugo {
ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0) {
- _numObj = 0;
+ _numObj = 0;
}
ObjectHandler::~ObjectHandler() {
@@ -60,13 +60,13 @@ void ObjectHandler::saveSeq(object_t *obj) {
debugC(1, kDebugObject, "saveSeq");
bool found = false;
- for (int j = 0; !found && (j < obj->seqNumb); j++) {
- seq_t *q = obj->seqList[j].seqPtr;
- for (int k = 0; !found && (k < obj->seqList[j].imageNbr); k++) {
+ for (int i = 0; !found && (i < obj->seqNumb); i++) {
+ seq_t *q = obj->seqList[i].seqPtr;
+ for (int j = 0; !found && (j < obj->seqList[i].imageNbr); j++) {
if (obj->currImagePtr == q) {
found = true;
- obj->curSeqNum = j;
- obj->curImageNum = k;
+ obj->curSeqNum = i;
+ obj->curImageNum = j;
} else {
q = q->nextSeqPtr;
}
@@ -494,7 +494,31 @@ void ObjectHandler::saveObjects(Common::WriteStream *out) {
for (int i = 0; i < _numObj; i++) {
// Save where curr_seq_p is pointing to
saveSeq(&_objects[i]);
- out->write(&_objects[i], sizeof(object_t));
+
+ out->writeByte(_objects[i].pathType);
+ out->writeSint16BE(_objects[i].vxPath);
+ out->writeSint16BE(_objects[i].vyPath);
+ out->writeByte(_objects[i].cycling);
+ out->writeByte(_objects[i].cycleNumb);
+ out->writeByte(_objects[i].frameTimer);
+ out->writeByte(_objects[i].screenIndex);
+ out->writeSint16BE(_objects[i].x);
+ out->writeSint16BE(_objects[i].y);
+ out->writeSint16BE(_objects[i].oldx);
+ out->writeSint16BE(_objects[i].oldy);
+ out->writeSByte(_objects[i].vx);
+ out->writeSByte(_objects[i].vy);
+ out->writeByte(_objects[i].objValue);
+ out->writeByte((_objects[i].carriedFl) ? 1 : 0);
+ out->writeByte(_objects[i].state);
+ out->writeByte(_objects[i].priority);
+ out->writeSint16BE(_objects[i].viewx);
+ out->writeSint16BE(_objects[i].viewy);
+ out->writeSint16BE(_objects[i].direction);
+ out->writeByte(_objects[i].curSeqNum);
+ out->writeByte(_objects[i].curImageNum);
+ out->writeSByte(_objects[i].oldvx);
+ out->writeSByte(_objects[i].oldvy);
}
}
@@ -503,13 +527,30 @@ void ObjectHandler::saveObjects(Common::WriteStream *out) {
*/
void ObjectHandler::restoreObjects(Common::SeekableReadStream *in) {
for (int i = 0; i < _numObj; i++) {
- object_t *p = &_objects[i];
- seqList_t seqList[MAX_SEQUENCES];
- memcpy(seqList, p->seqList, sizeof(seqList_t));
- uint16 cmdIndex = p->cmdIndex;
- in->read(p, sizeof(object_t));
- p->cmdIndex = cmdIndex;
- memcpy(p->seqList, seqList, sizeof(seqList_t));
+ _objects[i].pathType = (path_t) in->readByte();
+ _objects[i].vxPath = in->readSint16BE();
+ _objects[i].vyPath = in->readSint16BE();
+ _objects[i].cycling = (cycle_t) in->readByte();
+ _objects[i].cycleNumb = in->readByte();
+ _objects[i].frameTimer = in->readByte();
+ _objects[i].screenIndex = in->readByte();
+ _objects[i].x = in->readSint16BE();
+ _objects[i].y = in->readSint16BE();
+ _objects[i].oldx = in->readSint16BE();
+ _objects[i].oldy = in->readSint16BE();
+ _objects[i].vx = in->readSByte();
+ _objects[i].vy = in->readSByte();
+ _objects[i].objValue = in->readByte();
+ _objects[i].carriedFl = (in->readByte() == 1);
+ _objects[i].state = in->readByte();
+ _objects[i].priority = in->readByte();
+ _objects[i].viewx = in->readSint16BE();
+ _objects[i].viewy = in->readSint16BE();
+ _objects[i].direction = in->readSint16BE();
+ _objects[i].curSeqNum = in->readByte();
+ _objects[i].curImageNum = in->readByte();
+ _objects[i].oldvx = in->readSByte();
+ _objects[i].oldvy = in->readSByte();
}
}