aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-01-05 11:02:35 -0500
committerPaul Gilbert2015-01-05 11:02:35 -0500
commit86cdb68f4da1f43412bbbadca1e2c4a9a80c60d8 (patch)
tree4570f4f15db3a5ad0e31b37b9cd08f1e1e0d1753
parentce96094c9bc54266c9742364e656c97446a6ecaf (diff)
downloadscummvm-rg350-86cdb68f4da1f43412bbbadca1e2c4a9a80c60d8.tar.gz
scummvm-rg350-86cdb68f4da1f43412bbbadca1e2c4a9a80c60d8.tar.bz2
scummvm-rg350-86cdb68f4da1f43412bbbadca1e2c4a9a80c60d8.zip
XEEN: Properly implemented map loading first loading loop
-rw-r--r--engines/xeen/map.cpp56
-rw-r--r--engines/xeen/map.h8
2 files changed, 54 insertions, 10 deletions
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index d797179e15..4a3eda6b11 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -29,6 +29,14 @@
namespace Xeen {
+const int MAP_GRID_PRIOR_INDEX[] = { 0, 0, 0, 0, 1, 2, 3, 4, 0 };
+
+const int MAP_GRID_PRIOR_DIRECTION[] = { 0, 1, 2, 3, 1, 2, 3, 0, 0 };
+
+const int MAP_GRID_PRIOR_INDEX2[] = { 0, 0, 0, 0, 2, 3, 4, 1, 0 };
+
+const int MAP_GRID_PRIOR_DIRECTION2[] = { 0, 1, 2, 3, 0, 1, 2, 3, 0 };
+
MonsterStruct::MonsterStruct() {
_experience = 0;
_hp = 0;
@@ -490,6 +498,19 @@ void SurroundingMazes::synchronize(Common::SeekableReadStream &s) {
_west = s.readUint16LE();
}
+int &SurroundingMazes::operator[](int idx) {
+ switch (idx) {
+ case DIR_NORTH:
+ return _north;
+ case DIR_EAST:
+ return _east;
+ case DIR_SOUTH:
+ return _south;
+ default:
+ return _west;
+ }
+}
+
/*------------------------------------------------------------------------*/
MazeDifficulties::MazeDifficulties() {
@@ -752,29 +773,30 @@ void Map::load(int mapId) {
}
bool isDarkCc = _vm->getGameID() == GType_DarkSide;
- uint16 mapGrid[9];
- uint16 *gridPtr = &mapGrid[0];
+ MazeData *mazeData = &_mazeData[0];
bool textLoaded = false;
// Iterate through loading the given maze as well as the two successive
// mazes in each of the four cardinal directions
- for (int idx = 0; idx < 9; ++idx, ++gridPtr) {
+ for (int idx = 0; idx < 9; ++idx, ++mazeData) {
+ mazeData->_mazeId = mapId;
+
if (mapId != 0) {
// Load in the maze's data file
Common::String datName = Common::String::format("maze%c%03u.dat",
(_vm->_party._mazeId >= 100) ? 'x' : '0', _vm->_party._mazeId);
File datFile(datName);
- _mazeData.synchronize(datFile);
+ mazeData->synchronize(datFile);
datFile.close();
if (isDarkCc && mapId == 50)
- _mazeData.setAllTilesStepped();
+ mazeData->setAllTilesStepped();
if (!isDarkCc && _vm->_party._gameFlags[25] &&
(mapId == 42 || mapId == 43 || mapId == 4)) {
- _mazeData.clearCellBits();
+ mazeData->clearCellBits();
}
- _isOutdoors = (_mazeData._mazeFlags2 & FLAG_IS_OUTDOORS) != 0;
+ _isOutdoors = (mazeData->_mazeFlags2 & FLAG_IS_OUTDOORS) != 0;
// Handle loading text data
if (!textLoaded) {
@@ -815,10 +837,26 @@ void Map::load(int mapId) {
}
}
- // TODO: Move to next surrounding maze
+ // Move to next surrounding maze
+ MazeData *baseMaze = &_mazeData[MAP_GRID_PRIOR_INDEX[idx]];
+ mapId = baseMaze->_surroundingMazes[MAP_GRID_PRIOR_DIRECTION[idx]];
+ if (mapId) {
+ baseMaze = &_mazeData[MAP_GRID_PRIOR_INDEX2[idx]];
+ mapId = baseMaze->_surroundingMazes[MAP_GRID_PRIOR_DIRECTION2[idx]];
+ }
}
- // TODO
+ // TODO: Switch setting flags that don't seem to ever be used
+
+ // Reload object data, since prior loop iterations replaced the data
+ // for the main map with all the surrounding mazes
+ Common::String mobName = Common::String::format("maze%c%03u.mob",
+ (_vm->_party._mazeId >= 100) ? 'x' : '0', _vm->_party._mazeId);
+ File mobFile(mobName);
+ _mobData.synchronize(mobFile, _isOutdoors, _monsterData);
+ mobFile.close();
+
+ // TODO: Loop loading moer data
}
} // End of namespace Xeen
diff --git a/engines/xeen/map.h b/engines/xeen/map.h
index 4482173642..e52e978106 100644
--- a/engines/xeen/map.h
+++ b/engines/xeen/map.h
@@ -126,6 +126,8 @@ public:
SurroundingMazes();
void synchronize(Common::SeekableReadStream &s);
+
+ int &operator[](int idx);
};
class MazeDifficulties {
@@ -155,6 +157,7 @@ enum MazeFlags2 { FLAG_IS_OUTDOORS = 0x8000, FLAG_IS_DARK = 0x4000 };
class MazeData {
public:
+ // Resource fields
int _wallData[MAP_HEIGHT][MAP_WIDTH];
int _cellFlag[MAP_HEIGHT][MAP_WIDTH];
int _mazeNumber;
@@ -171,6 +174,9 @@ public:
int _tavernTips;
bool _seenTiles[MAP_HEIGHT][MAP_WIDTH];
bool _steppedOnTiles[MAP_HEIGHT][MAP_WIDTH];
+
+ // Misc fields
+ int _mazeId;
public:
MazeData();
@@ -242,7 +248,7 @@ public:
class Map {
private:
XeenEngine *_vm;
- MazeData _mazeData;
+ MazeData _mazeData[9];
Common::String _mazeName;
MonsterObjectData _mobData;
HeadData _headData;