aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-08-26 20:26:54 -0700
committerPaul Gilbert2019-08-26 20:27:05 -0700
commit87c3e6d5d37ec5ee8d9f4062058cc7b1ae8e01bb (patch)
treeb4a4fb69bf19a5d68e03a5ac57fbcc64e00b2b46 /engines
parente65001405b79ec5eae56657b0ca5e2258c46872a (diff)
downloadscummvm-rg350-87c3e6d5d37ec5ee8d9f4062058cc7b1ae8e01bb.tar.gz
scummvm-rg350-87c3e6d5d37ec5ee8d9f4062058cc7b1ae8e01bb.tar.bz2
scummvm-rg350-87c3e6d5d37ec5ee8d9f4062058cc7b1ae8e01bb.zip
XEEN: Fix removing Paladin rocks in Dark Side desert
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/map.cpp26
-rw-r--r--engines/xeen/map.h6
-rw-r--r--engines/xeen/patcher.cpp56
3 files changed, 78 insertions, 10 deletions
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index f2a9395b28..bc5d55f1fc 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -730,7 +730,7 @@ void Map::load(int mapId) {
// mazes in each of the four cardinal directions
int ccNum = files._ccNum;
MazeData *mazeDataP = &_mazeData[0];
- bool textLoaded = false;
+ bool mapDataLoaded = false;
for (int idx = 0; idx < 9; ++idx, ++mazeDataP) {
mazeDataP->_mazeId = mapId;
@@ -755,14 +755,14 @@ void Map::load(int mapId) {
_isOutdoors = (mazeDataP->_mazeFlags2 & FLAG_IS_OUTDOORS) != 0;
- // Handle loading text data
- if (!textLoaded) {
- textLoaded = true;
+ Common::String mobName = Common::String::format("maze%c%03d.mob", (mapId >= 100) ? 'x' : '0', mapId);
+
+ if (!mapDataLoaded) {
+ // Called once for the main map being loaded
+ mapDataLoaded = true;
_mazeName = getMazeName(mapId, ccNum);
// Load the monster/object data
- Common::String mobName = Common::String::format("maze%c%03d.mob",
- (mapId >= 100) ? 'x' : '0', mapId);
File mobFile(mobName);
XeenSerializer sMob(&mobFile, nullptr);
_mobData.synchronize(sMob, _monsterData);
@@ -781,6 +781,20 @@ void Map::load(int mapId) {
party._gameFlags[0][56] = true;
}
}
+ } else if (File::exists(mobName)) {
+ // For surrounding maps, set up flags for whether objects are present
+ // Load the monster/object data
+ File mobFile(mobName);
+ XeenSerializer sMob(&mobFile, nullptr);
+ MonsterObjectData mobData(_vm);
+ mobData.synchronize(sMob, _monsterData);
+ mobFile.close();
+
+ mazeDataP->_objectsPresent.resize(mobData._objects.size());
+ for (uint objIndex = 0; objIndex < mobData._objects.size(); ++objIndex) {
+ const Common::Point &pt = mobData._objects[objIndex]._position;
+ mazeDataP->_objectsPresent[objIndex] = ABS(pt.x) != 128 && ABS(pt.y) != 128;
+ }
}
}
diff --git a/engines/xeen/map.h b/engines/xeen/map.h
index cdd33760d7..7e48d51ffe 100644
--- a/engines/xeen/map.h
+++ b/engines/xeen/map.h
@@ -208,6 +208,7 @@ public:
int _tavernTips;
bool _seenTiles[MAP_HEIGHT][MAP_WIDTH];
bool _steppedOnTiles[MAP_HEIGHT][MAP_WIDTH];
+ Common::Array<bool> _objectsPresent;
// Misc fields
int _mazeId;
@@ -509,6 +510,11 @@ public:
MazeData &mazeData() { return _mazeData[0]; }
/**
+ * Returns the data for the primary active map
+ */
+ const MazeData *mazeDataSurrounding() { return _mazeData; }
+
+ /**
* Returns the data for the currently indexed map
*/
MazeData &mazeDataCurrent() { return _mazeData[_mazeDataIndex]; }
diff --git a/engines/xeen/patcher.cpp b/engines/xeen/patcher.cpp
index c8939e95f0..b401549442 100644
--- a/engines/xeen/patcher.cpp
+++ b/engines/xeen/patcher.cpp
@@ -35,6 +35,14 @@ struct ScriptEntry {
const byte *_data;
};
+struct ObjectEntry {
+ int _gameId; ///< Game Id
+ int _removeMazeId; ///< Maze Id of copy to remove
+ int _removeObjNumber; ///< Object number of copy to remove
+ int _refMazeId; ///< Reference object maze id
+ int _refObjNumber; ///< Reference object's number
+};
+
const byte DS_MAP54_LINE8[] = { 8, 10, 10, DIR_EAST, 8, OP_MoveWallObj, 20, 100, 100 };
const byte SW_MAP53_LINE8[] = { 5, 14, 6, DIR_EAST, 8, OP_Exit };
const byte DS_MAP116[] = { 9, 10, 6, 4, 2, OP_TakeOrGive, 0, 0, 103, 127 };
@@ -50,6 +58,21 @@ static const ScriptEntry SCRIPT_PATCHES[] = {
{ GType_DarkSide, 62, DS_MAP62_PIT2 } // Fix fall position for pit
};
+// List of objects that that need to be removed. Most of these are for copies of objects that appear in
+// the distance on the edge of other maps, so they don't simply pop into existance when the map changes.
+// When the main object is removed, the original didn't properly also removie the object copies
+#define REMOVE_OBJECTS_COUNT 6
+static const ObjectEntry REMOVE_OBJECTS[] = {
+ // Floating statue in the distance off SE corner of map
+ { GType_Clouds, 24, 15, 0, 0 },
+ // Desert Paladin stones
+ { GType_DarkSide, 10, 9, 14, 1 },
+ { GType_DarkSide, 11, 5, 10, 0 },
+ { GType_DarkSide, 15, 5, 14, 4 },
+ { GType_DarkSide, 15, 6, 14, 5 },
+ { GType_DarkSide, 10, 10, 14, 5 }
+};
+
/*------------------------------------------------------------------------*/
void Patcher::patch() {
@@ -94,11 +117,36 @@ void Patcher::patchObjects() {
FileManager &files = *g_vm->_files;
Map &map = *g_vm->_map;
Party &party = *g_vm->_party;
+ const MazeData *mapData = map.mazeDataSurrounding();
+
+ int gameId = g_vm->getGameID();
+ if (gameId == GType_WorldOfXeen)
+ gameId = files._ccNum ? GType_DarkSide : GType_Clouds;
+
+ for (int roCtr = 0; roCtr < REMOVE_OBJECTS_COUNT; ++roCtr) {
+ const ObjectEntry &oe = REMOVE_OBJECTS[roCtr];
+ if (oe._gameId != gameId || oe._removeMazeId != party._mazeId)
+ continue;
- if ((g_vm->getGameID() == GType_Clouds || (g_vm->getGameID() == GType_WorldOfXeen && !files._ccNum)) &&
- party._mazeId == 24) {
- // Remove floating statue in the distance off SE corner of Clouds of Xeen map
- map._mobData._objects[15]._position = Common::Point(-128, -128);
+ MazeObject &mazeObj = map._mobData._objects[oe._removeObjNumber];
+
+ // If specified object has a linked reference object, we need to check if it's removed
+ if (oe._refMazeId) {
+ int mazeIndex = -1;
+ while (++mazeIndex < 9) {
+ if (mapData[mazeIndex]._mazeId == oe._refMazeId)
+ break;
+ }
+ if (mazeIndex == 9)
+ error("Could not find specified reference maze in object patcher");
+
+ if (mapData[mazeIndex]._objectsPresent[oe._refObjNumber])
+ // Object linked to is still present, so we don't remove the object yet
+ continue;
+ }
+
+ // Ensure the object is marked as removed
+ mazeObj._position.x = mazeObj._position.y = 128;
}
}