aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinterGrascph2016-05-07 22:48:19 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit8172a07d1ad933b228313f164b7d6a5b1bf3951e (patch)
treecc5e238e0a87c7d95e08f3f45f849decceb7f844
parent68f13e8462bfb6ca85b45273696173acdf112910 (diff)
downloadscummvm-rg350-8172a07d1ad933b228313f164b7d6a5b1bf3951e.tar.gz
scummvm-rg350-8172a07d1ad933b228313f164b7d6a5b1bf3951e.tar.bz2
scummvm-rg350-8172a07d1ad933b228313f164b7d6a5b1bf3951e.zip
DM: Add square query in DungeonMan
-rw-r--r--engines/dm/dungeonman.cpp15
-rw-r--r--engines/dm/dungeonman.h17
2 files changed, 32 insertions, 0 deletions
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 07c52a78dc..87188aebf8 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -285,4 +285,19 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) {
_currMap.height = _maps[mapIndex].height + 1;
_currMap.colCumulativeSquareFirstThingCount
= &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]];
+}
+
+byte DungeonMan::getSquare(uint16 mapX, uint16 mapY) {
+ bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width);
+ bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height);
+
+ if (isInXBounds && isInYBounds)
+ return _currMap.data[mapX][mapY];
+ else
+ return kWallSquareType;
+}
+
+byte DungeonMan::getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) {
+ mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY);
+ return getSquare(posX, posY);
} \ No newline at end of file
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 213a76dad6..c88c08d478 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -26,6 +26,16 @@ enum ThingType {
kThingTypeTotal = 16 // +1 than the last
}; // @ C[00..15]_THING_TYPE_...
+enum SquareType {
+ kWallSquareType = 0,
+ kCorridorSquareType = 1,
+ kPitSquareType = 2,
+ kStairsSquareType = 3,
+ kDoorSquareType = 4,
+ kTeleporterSquareType = 5,
+ kFakeWallSquareType = 6
+}; // @ C[00..06]_ELEMENT_...
+
class DungeonFileHeader {
friend class DungeonMan;
@@ -141,6 +151,10 @@ class DungeonMan {
void operator=(const DungeonMan &rhs); // no implementation on purpose
void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
+ byte getSquare(uint16 mapX, uint16 mapY); // @ F0151_DUNGEON_GetSquare
+ byte getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY); // @ F0152_DUNGEON_GetRelativeSquare
+
+ SquareType getSquareType(uint16 square) { return (SquareType)(square << 5); } // @ M34_SQUARE_TYPE
void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
public:
@@ -149,6 +163,9 @@ public:
// TODO: this does stuff other than load the file!
void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
+ SquareType getRelSquareType(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) {
+ return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY));
+ }// @ F0153_DUNGEON_GetRelativeSquareType
};
}