aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWinterGrascph2016-05-12 23:19:36 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commitf39b22f32133cd40c20996e75dfcb167c91e2ae2 (patch)
treed79054b1473ce7b005104a1be3d229825bad4fd7 /engines
parent05fbf0b3584c5bef1827ce43951b325a20ac40ac (diff)
downloadscummvm-rg350-f39b22f32133cd40c20996e75dfcb167c91e2ae2.tar.gz
scummvm-rg350-f39b22f32133cd40c20996e75dfcb167c91e2ae2.tar.bz2
scummvm-rg350-f39b22f32133cd40c20996e75dfcb167c91e2ae2.zip
DM: Refactor Thing POD
Diffstat (limited to 'engines')
-rw-r--r--engines/dm/dungeonman.cpp9
-rw-r--r--engines/dm/dungeonman.h50
2 files changed, 30 insertions, 29 deletions
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 87188aebf8..b5c2a3e1fb 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -11,7 +11,6 @@ int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /
void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
-
}
using namespace DM;
@@ -225,12 +224,8 @@ void DungeonMan::loadDungeonFile() {
if (_dunData.squareFirstThings)
delete[] _dunData.squareFirstThings;
_dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount];
- for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i) {
- uint16 tmp = dunDataStream.readUint16BE();
- _dunData.squareFirstThings[i].cell = tmp >> 14;
- _dunData.squareFirstThings[i].type = (tmp >> 10) & 0xF;
- _dunData.squareFirstThings[i].index = tmp & 0x1FF;
- }
+ for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i)
+ _dunData.squareFirstThings[i].set(dunDataStream.readUint16BE());
if (_messages.newGame)
for (uint16 i = 0; i < 300; ++i)
_dunData.squareFirstThings[i] = Thing::specThingNone;
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index e60fb40d43..2afc2aab88 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -52,13 +52,40 @@ class DungeonFileHeader {
uint16 thingCounts[16]; // @ ThingCount[16]
}; // @ DUNGEON_HEADER
+class Map {
+ friend class DungeonMan;
+
+ uint32 rawDunDataOffset;
+ uint8 offsetMapX, offsetMapY;
+
+ uint8 level; // only used in DMII
+ uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
+ // orn short for Ornament
+ uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
+ uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
+ uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
+ uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
+
+ uint8 doorOrnCount;
+ uint8 creatureTypeCount;
+ uint8 difficulty;
+
+ uint8 floorSet, wallSet, doorSet0, doorSet1;
+}; // @ MAP
+
class Thing {
friend class DungeonMan;
static const Thing specThingNone;
- Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {}
Thing() {}
+ Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {}
+
+ void set(uint16 dat) {
+ cell = dat >> 14;
+ type = (dat >> 10) & 0xF;
+ index = dat & 0x1FF;
+ }
uint8 cell;
uint8 type;
@@ -109,27 +136,6 @@ private:
bool restartGameRequest = false; // @ G0523_B_RestartGameRequested
}; // @ AGGREGATE
-class Map {
- friend class DungeonMan;
-
- uint32 rawDunDataOffset;
- uint8 offsetMapX, offsetMapY;
-
- uint8 level; // only used in DMII
- uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
- // orn short for Ornament
- uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
- uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
- uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
- uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
-
- uint8 doorOrnCount;
- uint8 creatureTypeCount;
- uint8 difficulty;
-
- uint8 floorSet, wallSet, doorSet0, doorSet1;
-
-}; // @ MAP