[Scummvm-cvs-logs] SF.net SVN: scummvm:[54422] scummvm/trunk/engines/hugo

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Mon Nov 22 23:49:25 CET 2010


Revision: 54422
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54422&view=rev
Author:   strangerke
Date:     2010-11-22 22:49:24 +0000 (Mon, 22 Nov 2010)

Log Message:
-----------
HUGO: Rewrite saveObjects() and restoreObjects()

This fixes (at least for me) save and restore. saveEvents() 
and restoreEvents() still have to be rewritten.

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/file.cpp
    scummvm/trunk/engines/hugo/object.cpp

Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp	2010-11-22 19:50:57 UTC (rev 54421)
+++ scummvm/trunk/engines/hugo/file.cpp	2010-11-22 22:49:24 UTC (rev 54422)
@@ -420,7 +420,7 @@
 
 	status_t &gameStatus = _vm->getGameStatus();
 
-	int score = in->readSint16LE();
+	int score = in->readSint16BE();
 	_vm->setScore(score);
 
 	gameStatus.storyModeFl = (in->readByte() == 1);

Modified: scummvm/trunk/engines/hugo/object.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object.cpp	2010-11-22 19:50:57 UTC (rev 54421)
+++ scummvm/trunk/engines/hugo/object.cpp	2010-11-22 22:49:24 UTC (rev 54422)
@@ -47,7 +47,7 @@
 namespace Hugo {
 
 ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0) {
-	_numObj = 0; 
+	_numObj = 0;
 }
 
 ObjectHandler::~ObjectHandler() {
@@ -60,13 +60,13 @@
 	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 @@
 	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::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();
 	}
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list