summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map.cpp2
-rw-r--r--src/map.h13
-rw-r--r--src/monster.h6
-rw-r--r--src/npc.h6
-rw-r--r--src/player.h2
5 files changed, 21 insertions, 8 deletions
diff --git a/src/map.cpp b/src/map.cpp
index f0a5eae0..490e52c1 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -429,7 +429,7 @@ void Map::blockTile(int x, int y, BlockType type)
}
}
-bool Map::getWalk(int x, int y, char walkmask) const
+bool Map::getWalk(int x, int y, unsigned char walkmask) const
{
// You can't walk outside of the map
if (!contains(x, y))
diff --git a/src/map.h b/src/map.h
index 0432dc34..cb0271b3 100644
--- a/src/map.h
+++ b/src/map.h
@@ -152,6 +152,13 @@ class Map : public Properties
NB_BLOCKTYPES
};
+ enum BlockMask
+ {
+ BLOCKMASK_WALL = 0x80, // = bin 1000 0000
+ BLOCKMASK_CHARACTER = 0x01, // = bin 0000 0001
+ BLOCKMASK_MONSTER = 0x02 // = bin 0000 0010
+ };
+
/**
* Constructor, taking map and tile size as parameters.
*/
@@ -217,7 +224,8 @@ class Map : public Properties
* Gets walkability for a tile with a blocking bitmask. When called
* without walkmask, only blocks against colliding tiles.
*/
- bool getWalk(int x, int y, char walkmask = BLOCKMASK_WALL) const;
+ bool getWalk(int x, int y,
+ unsigned char walkmask = BLOCKMASK_WALL) const;
/**
* Returns the width of this map in tiles.
@@ -294,9 +302,6 @@ class Map : public Properties
/**
* Blockmasks for different entities
*/
- static const unsigned char BLOCKMASK_WALL = 0x80; // = bin 1000 0000
- static const unsigned char BLOCKMASK_CHARACTER = 0x01;// = bin 0000 0001
- static const unsigned char BLOCKMASK_MONSTER = 0x02; // = bin 0000 0010
int *mOccupation[NB_BLOCKTYPES];
int mWidth, mHeight;
diff --git a/src/monster.h b/src/monster.h
index bf52ed6d..7b44b5a8 100644
--- a/src/monster.h
+++ b/src/monster.h
@@ -82,7 +82,11 @@ class Monster : public Being
* Gets the way the monster is blocked by other objects
*/
virtual unsigned char getWalkMask() const
- { return 0x83; } // blocked by walls, other monsters and players ( bin 1000 0011)
+ {
+ return Map::BLOCKMASK_WALL
+ | Map::BLOCKMASK_CHARACTER
+ | Map::BLOCKMASK_MONSTER;
+ }
protected:
/**
diff --git a/src/npc.h b/src/npc.h
index 57e6d5a8..fc6f3459 100644
--- a/src/npc.h
+++ b/src/npc.h
@@ -46,7 +46,11 @@ class NPC : public Player
* Gets the way an NPC is blocked by other things on the map
*/
virtual unsigned char getWalkMask() const
- { return 0x83; } // blocked like a monster by walls, monsters and characters ( bin 1000 0011)
+ {
+ return Map::BLOCKMASK_WALL
+ | Map::BLOCKMASK_CHARACTER
+ | Map::BLOCKMASK_MONSTER;
+ }
static bool isTalking;
diff --git a/src/player.h b/src/player.h
index bb44f462..9a5c6c94 100644
--- a/src/player.h
+++ b/src/player.h
@@ -132,7 +132,7 @@ class Player : public Being
* Gets the way the character is blocked by other objects.
*/
virtual unsigned char getWalkMask() const
- { return 0x82; } // blocked by walls and monsters (bin 1000 0010)
+ { return Map::BLOCKMASK_WALL | Map::BLOCKMASK_MONSTER; }
/**
* Called when a option (set with config.addListener()) is changed