[Scummvm-git-logs] scummvm master -> 66e531c92bca67f5330a454b8859f4bf1d6cb5b2

dreammaster dreammaster at scummvm.org
Wed Dec 27 07:12:21 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
66e531c92b XEEN: Fix saving monster data to exactly match original


Commit: 66e531c92bca67f5330a454b8859f4bf1d6cb5b2
    https://github.com/scummvm/scummvm/commit/66e531c92bca67f5330a454b8859f4bf1d6cb5b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-12-27T01:12:04-05:00

Commit Message:
XEEN: Fix saving monster data to exactly match original

Changed paths:
    engines/xeen/debugger.cpp
    engines/xeen/map.cpp
    engines/xeen/map.h


diff --git a/engines/xeen/debugger.cpp b/engines/xeen/debugger.cpp
index 5128aa6..68d2c0c 100644
--- a/engines/xeen/debugger.cpp
+++ b/engines/xeen/debugger.cpp
@@ -151,7 +151,7 @@ bool Debugger::cmdMap(int argc, const char **argv) {
 		return true;
 	} else {
 		int mapId = strToInt(argv[1]);
-		bool side = argc < 3 ? g_vm->_files->_isDarkCc : strToInt(argv[2]) != 0;
+		bool side = argc < 3 ? files._isDarkCc : strToInt(argv[2]) != 0;
 		int x = argc < 4 ? 8 : strToInt(argv[3]);
 		int y = argc < 5 ? 8 : strToInt(argv[4]);
 
@@ -174,7 +174,7 @@ bool Debugger::cmdPos(int argc, const char **argv) {
 		party._mazePosition.x = strToInt(argv[1]);
 		party._mazePosition.y = strToInt(argv[2]);
 		party._stepped = true;
-		return true;
+		return false;
 	}
 }
 
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index cf7ef82..27b746e 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -659,6 +659,12 @@ bool MobStruct::synchronize(XeenSerializer &s) {
 	return _id != 0xff || _pos.x != -1 || _pos.y != -1;
 }
 
+void MobStruct::endOfList() {
+	_pos.x = _pos.y = -1;
+	_id = 0xff;
+	_direction = (Direction)-1;
+}
+
 /*------------------------------------------------------------------------*/
 
 MazeObject::MazeObject() {
@@ -754,8 +760,7 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
 			mobStruct._direction = _objects[i]._direction;
 			mobStruct.synchronize(s);
 		}
-		mobStruct._pos.x = mobStruct._pos.y = -1;
-		mobStruct._id = 0xff;
+		mobStruct.endOfList();
 		mobStruct.synchronize(s);
 
 		// Save monsters
@@ -765,13 +770,13 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
 			mobStruct._direction = DIR_NORTH;
 			mobStruct.synchronize(s);
 		}
-		mobStruct._pos.x = mobStruct._pos.y = -1;
-		mobStruct._id = 0xff;
+		mobStruct.endOfList();
 		mobStruct.synchronize(s);
 
 		// Save wall items
 		if (_wallItems.size() == 0) {
 			MobStruct nullStruct;
+			nullStruct._pos.x = nullStruct._pos.y = 0x80;
 			nullStruct.synchronize(s);
 		} else {
 			for (uint i = 0; i < _wallItems.size(); ++i) {
@@ -781,8 +786,7 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
 				mobStruct.synchronize(s);
 			}
 		}
-		mobStruct._pos.x = mobStruct._pos.y = -1;
-		mobStruct._id = 0xff;
+		mobStruct.endOfList();
 		mobStruct.synchronize(s);
 
 	} else {
@@ -1421,16 +1425,6 @@ void Map::saveEvents() {
 	fEvents.finalize();
 }
 
-void Map::saveMonsters() {
-	int mapId = _mazeData[0]._mazeId;
-	Common::String filename = Common::String::format("maze%c%03d.mob",
-		(mapId >= 100) ? 'x' : '0', mapId);
-	OutFile fMob(filename);
-	XeenSerializer sMob(nullptr, &fMob);
-	_mobData.synchronize(sMob, _monsterData);
-	fMob.finalize();
-}
-
 void Map::saveMap() {
 	FileManager &files = *g_vm->_files;
 	Party &party = *g_vm->_party;
@@ -1446,13 +1440,12 @@ void Map::saveMap() {
 	datFile.finalize();
 
 	if (!files._isDarkCc && mapId == 15) {
-		MazeMonster &mon0 = _mobData._monsters[0];
-		MazeMonster &mon1 = _mobData._monsters[1];
-		MazeMonster &mon2 = _mobData._monsters[2];
-		if ((mon0._position.x > 31 || mon0._position.y > 31) ||
-				(mon1._position.x > 31 || mon1._position.y > 31) ||
-				(mon2._position.x > 31 || mon2._position.y > 31)) {
-			party._gameFlags[0][56] = true;
+		for (uint idx = 0; idx < MIN(_mobData._monsters.size(), (uint)3); ++idx) {
+			MazeMonster &mon = _mobData._monsters[idx];
+			if (mon._position.x > 31 || mon._position.y > 31) {
+				party._gameFlags[0][56] = true;
+				break;
+			}
 		}
 	}
 
@@ -1472,6 +1465,16 @@ void Map::saveMap() {
 	}
 }
 
+void Map::saveMonsters() {
+	int mapId = _mazeData[0]._mazeId;
+	Common::String filename = Common::String::format("maze%c%03d.mob",
+		(mapId >= 100) ? 'x' : '0', mapId);
+	OutFile fMob(filename);
+	XeenSerializer sMob(nullptr, &fMob);
+	_mobData.synchronize(sMob, _monsterData);
+	fMob.finalize();
+}
+
 void Map::saveMaze() {
 	int mazeNum = _mazeData[0]._mazeNumber;
 	if (!mazeNum || (mazeNum == 85 && !_vm->_files->_isDarkCc))
diff --git a/engines/xeen/map.h b/engines/xeen/map.h
index 6734f3f..fe62685 100644
--- a/engines/xeen/map.h
+++ b/engines/xeen/map.h
@@ -233,7 +233,15 @@ public:
 public:
 	MobStruct();
 
+	/**
+	 * Synchronizes the data for the item
+	 */
 	bool synchronize(XeenSerializer &s);
+
+	/**
+	 * Sets up the entry as an end of list marker
+	 */
+	void endOfList();
 };
 
 struct MazeObject {





More information about the Scummvm-git-logs mailing list