summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-11 17:00:44 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-11 17:00:44 +0300
commit10cf17f8d83d2d925641f722acc004828dba3094 (patch)
tree46a746d5bfe79e067cd25a3caca476ecbafa0af5 /src/resources
parent77bb74bd2d944be1a1dc719027dbf37ad088b828 (diff)
downloadplus-10cf17f8d83d2d925641f722acc004828dba3094.tar.gz
plus-10cf17f8d83d2d925641f722acc004828dba3094.tar.bz2
plus-10cf17f8d83d2d925641f722acc004828dba3094.tar.xz
plus-10cf17f8d83d2d925641f722acc004828dba3094.zip
Move blockmask into separate file.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/beinginfo.cpp6
-rw-r--r--src/resources/db/monsterdb.cpp12
-rw-r--r--src/resources/map/blockmask.h40
-rw-r--r--src/resources/map/map.cpp26
-rw-r--r--src/resources/map/map.h16
5 files changed, 65 insertions, 35 deletions
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index b833078ae..af60ce53d 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -46,9 +46,9 @@ BeingInfo::BeingInfo() :
mHoverCursor(Cursor::CURSOR_POINTER),
mSounds(),
mAttacks(),
- mWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER
- | Map::BLOCKMASK_MONSTER | Map::BLOCKMASK_AIR
- | Map::BLOCKMASK_WATER),
+ mWalkMask(BlockMask::WALL | BlockMask::CHARACTER
+ | BlockMask::MONSTER | BlockMask::AIR
+ | BlockMask::WATER),
mBlockType(BlockType::CHARACTER),
mColors(nullptr),
mTargetOffsetX(0),
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
index 8f11f2411..0fe02a99f 100644
--- a/src/resources/db/monsterdb.cpp
+++ b/src/resources/db/monsterdb.cpp
@@ -96,8 +96,8 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
if (!currentInfo)
currentInfo = new BeingInfo;
- currentInfo->setWalkMask(Map::BLOCKMASK_WALL
- | Map::BLOCKMASK_CHARACTER | Map::BLOCKMASK_MONSTER);
+ currentInfo->setWalkMask(BlockMask::WALL
+ | BlockMask::CHARACTER | BlockMask::MONSTER);
currentInfo->setBlockType(BlockType::MONSTER);
currentInfo->setName(XML::langProperty(
@@ -118,16 +118,16 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
std::string walkStr = XML::getProperty(
monsterNode, "walkType", "walk");
if (walkStr == "walk")
- block = Map::BLOCKMASK_WATER | Map::BLOCKMASK_AIR;
+ block = BlockMask::WATER | BlockMask::AIR;
else if (walkStr == "fly")
block = 0;
else if (walkStr == "swim")
- block = Map::BLOCKMASK_GROUND | Map::BLOCKMASK_AIR;
+ block = BlockMask::GROUND | BlockMask::AIR;
else if (walkStr == "walkswim" || walkStr == "swimwalk")
- block = Map::BLOCKMASK_AIR;
+ block = BlockMask::AIR;
currentInfo->setWalkMask(static_cast<unsigned char>(
- Map::BLOCKMASK_WALL | block));
+ BlockMask::WALL | block));
if (currentInfo->getMaxHP())
currentInfo->setStaticMaxHP(true);
diff --git a/src/resources/map/blockmask.h b/src/resources/map/blockmask.h
new file mode 100644
index 000000000..3e10fa64e
--- /dev/null
+++ b/src/resources/map/blockmask.h
@@ -0,0 +1,40 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_MAP_BLOCKMASK_H
+#define RESOURCES_MAP_BLOCKMASK_H
+
+namespace BlockMask
+{
+ enum BlockMask
+ {
+ WALL = 0x80, // 1000 0000
+ CHARACTER = 0x01, // 0000 0001
+ MONSTER = 0x02, // 0000 0010
+ AIR = 0x04, // 0000 0100
+ WATER = 0x08, // 0000 1000
+ GROUND = 0x10, // 0001 0000
+ GROUNDTOP = 0x20 // 0010 0000
+ };
+}
+
+#endif // RESOURCES_MAP_BLOCKMASK_H
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 99b27bce2..7f856d786 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -527,10 +527,10 @@ void Map::drawCollision(Graphics *const graphics,
int width = 0;
const int x0 = x;
- fillCollision(BLOCKMASK_WALL, COLLISION_HIGHLIGHT);
- fillCollision(BLOCKMASK_AIR, AIR_COLLISION_HIGHLIGHT);
- fillCollision(BLOCKMASK_WATER, WATER_COLLISION_HIGHLIGHT);
- fillCollision(BLOCKMASK_GROUNDTOP, GROUNDTOP_COLLISION_HIGHLIGHT);
+ fillCollision(BlockMask::WALL, COLLISION_HIGHLIGHT);
+ fillCollision(BlockMask::AIR, AIR_COLLISION_HIGHLIGHT);
+ fillCollision(BlockMask::WATER, WATER_COLLISION_HIGHLIGHT);
+ fillCollision(BlockMask::GROUNDTOP, GROUNDTOP_COLLISION_HIGHLIGHT);
}
}
}
@@ -636,25 +636,25 @@ void Map::blockTile(const int x, const int y,
switch (type)
{
case BlockType::WALL:
- mMetaTiles[tileNum].blockmask |= BLOCKMASK_WALL;
+ mMetaTiles[tileNum].blockmask |= BlockMask::WALL;
break;
case BlockType::CHARACTER:
- mMetaTiles[tileNum].blockmask |= BLOCKMASK_CHARACTER;
+ mMetaTiles[tileNum].blockmask |= BlockMask::CHARACTER;
break;
case BlockType::MONSTER:
- mMetaTiles[tileNum].blockmask |= BLOCKMASK_MONSTER;
+ mMetaTiles[tileNum].blockmask |= BlockMask::MONSTER;
break;
case BlockType::AIR:
- mMetaTiles[tileNum].blockmask |= BLOCKMASK_AIR;
+ mMetaTiles[tileNum].blockmask |= BlockMask::AIR;
break;
case BlockType::WATER:
- mMetaTiles[tileNum].blockmask |= BLOCKMASK_WATER;
+ mMetaTiles[tileNum].blockmask |= BlockMask::WATER;
break;
case BlockType::GROUND:
- mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUND;
+ mMetaTiles[tileNum].blockmask |= BlockMask::GROUND;
break;
case BlockType::GROUNDTOP:
- mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUNDTOP;
+ mMetaTiles[tileNum].blockmask |= BlockMask::GROUNDTOP;
break;
default:
case BlockType::NONE:
@@ -815,7 +815,7 @@ Path Map::findPath(const int startX, const int startY,
if (newTile->whichList == mOnClosedList ||
((newTile->blockmask & walkmask)
&& !(x == destX && y == destY))
- || (newTile->blockmask & BLOCKMASK_WALL))
+ || (newTile->blockmask & BlockMask::WALL))
{
continue;
}
@@ -831,7 +831,7 @@ Path Map::findPath(const int startX, const int startY,
// +++ here need check block must depend
// on player abilities.
- if (((t1->blockmask | t2->blockmask) & BLOCKMASK_WALL))
+ if (((t1->blockmask | t2->blockmask) & BlockMask::WALL))
continue;
}
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
index 0085206a6..db9f09dd0 100644
--- a/src/resources/map/map.h
+++ b/src/resources/map/map.h
@@ -27,6 +27,7 @@
#include "being/actor.h"
+#include "resources/map/blockmask.h"
#include "resources/map/blocktype.h"
#include "resources/map/metatile.h"
#include "resources/map/properties.h"
@@ -77,17 +78,6 @@ class Map final : public Properties, public ConfigListener
COLLISION_MAX = 5 // count index
};
- enum BlockMask
- {
- BLOCKMASK_WALL = 0x80, // 1000 0000
- BLOCKMASK_CHARACTER = 0x01, // 0000 0001
- BLOCKMASK_MONSTER = 0x02, // 0000 0010
- BLOCKMASK_AIR = 0x04, // 0000 0100
- BLOCKMASK_WATER = 0x08, // 0000 1000
- BLOCKMASK_GROUND = 0x10, // 0001 0000
- BLOCKMASK_GROUNDTOP = 0x20 // 0010 0000
- };
-
enum DebugType
{
MAP_NORMAL = 0,
@@ -171,8 +161,8 @@ class Map final : public Properties, public ConfigListener
* without walkmask, only blocks against colliding tiles.
*/
bool getWalk(const int x, const int y,
- const unsigned char walkmask = BLOCKMASK_WALL
- | BLOCKMASK_AIR | BLOCKMASK_WATER) const A_WARN_UNUSED;
+ const unsigned char walkmask = BlockMask::WALL
+ | BlockMask::AIR | BlockMask::WATER) const A_WARN_UNUSED;
void setWalk(const int x, const int y, const bool walkable);