summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-11 16:44:15 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-11 16:44:15 +0300
commit77bb74bd2d944be1a1dc719027dbf37ad088b828 (patch)
tree0feb040a768eff20220835eb359e767dc43f113c /src
parent835dd846af75ea2cfc91f0134156f9c6545dd8ce (diff)
downloadmanaplus-77bb74bd2d944be1a1dc719027dbf37ad088b828.tar.gz
manaplus-77bb74bd2d944be1a1dc719027dbf37ad088b828.tar.bz2
manaplus-77bb74bd2d944be1a1dc719027dbf37ad088b828.tar.xz
manaplus-77bb74bd2d944be1a1dc719027dbf37ad088b828.zip
Move blocktype into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/actorsprite.h5
-rw-r--r--src/being/being.h6
-rw-r--r--src/resources/beinginfo.cpp4
-rw-r--r--src/resources/beinginfo.h6
-rw-r--r--src/resources/db/monsterdb.cpp4
-rw-r--r--src/resources/map/blocktype.h42
-rw-r--r--src/resources/map/map.cpp29
-rw-r--r--src/resources/map/map.h19
-rw-r--r--src/resources/mapreader.cpp13
11 files changed, 86 insertions, 44 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 806c2173f..f9e6b54c7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -704,6 +704,7 @@ SET(SRCS
logger.h
main.cpp
main.h
+ resources/map/blocktype.h
resources/map/location.h
resources/map/map.cpp
resources/map/map.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 605931a0c..38b432c86 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -793,6 +793,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
logger.h \
main.cpp \
main.h \
+ resources/map/blocktype.h \
resources/map/location.h \
resources/map/map.cpp \
resources/map/map.h \
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index bda1ea611..e21cbe5d6 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -24,6 +24,7 @@
#include "localconsts.h"
+#include "resources/map/blocktype.h"
#include "resources/map/map.h"
#include "resources/map/mapconsts.h"
@@ -103,8 +104,8 @@ public:
/**
* Gets the way the object blocks pathfinding for other objects
*/
- virtual Map::BlockType getBlockType() const A_WARN_UNUSED
- { return Map::BLOCKTYPE_NONE; }
+ virtual BlockType::BlockType getBlockType() const A_WARN_UNUSED
+ { return BlockType::NONE; }
/**
* Take control of a particle.
diff --git a/src/being/being.h b/src/being/being.h
index 989036974..a55c5858f 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -25,6 +25,8 @@
#include "resources/beinginfo.h"
+#include "resources/map/blocktype.h"
+
#include "being/gender.h"
#include <map>
@@ -457,10 +459,10 @@ class Being : public ActorSprite, public ConfigListener
/**
* Gets the way the monster blocks pathfinding for other objects
*/
- Map::BlockType getBlockType() const A_WARN_UNUSED
+ BlockType::BlockType getBlockType() const A_WARN_UNUSED
{
if (!mInfo)
- return Map::BLOCKTYPE_NONE;
+ return BlockType::NONE;
return mInfo->getBlockType();
}
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index d7ecb8136..b833078ae 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -25,6 +25,8 @@
#include "configuration.h"
#include "logger.h"
+#include "resources/map/blocktype.h"
+
#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -47,7 +49,7 @@ BeingInfo::BeingInfo() :
mWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER
| Map::BLOCKMASK_MONSTER | Map::BLOCKMASK_AIR
| Map::BLOCKMASK_WATER),
- mBlockType(Map::BLOCKTYPE_CHARACTER),
+ mBlockType(BlockType::CHARACTER),
mColors(nullptr),
mTargetOffsetX(0),
mTargetOffsetY(0),
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 81a1f749d..554b1efaf 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -138,10 +138,10 @@ class BeingInfo final
unsigned char getWalkMask() const A_WARN_UNUSED
{ return mWalkMask; }
- void setBlockType(const Map::BlockType &blockType)
+ void setBlockType(const BlockType::BlockType &blockType)
{ mBlockType = blockType; }
- Map::BlockType getBlockType() const A_WARN_UNUSED
+ BlockType::BlockType getBlockType() const A_WARN_UNUSED
{ return mBlockType; }
void setTargetOffsetX(const int n)
@@ -346,7 +346,7 @@ class BeingInfo final
ItemSoundEvents mSounds;
Attacks mAttacks;
unsigned char mWalkMask;
- Map::BlockType mBlockType;
+ BlockType::BlockType mBlockType;
const std::map <int, ColorDB::ItemColor> *mColors;
int mTargetOffsetX;
int mTargetOffsetY;
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
index 7bdbeb33d..8f11f2411 100644
--- a/src/resources/db/monsterdb.cpp
+++ b/src/resources/db/monsterdb.cpp
@@ -27,6 +27,8 @@
#include "resources/beingcommon.h"
#include "resources/beinginfo.h"
+#include "resources/map/blocktype.h"
+
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -96,7 +98,7 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
currentInfo->setWalkMask(Map::BLOCKMASK_WALL
| Map::BLOCKMASK_CHARACTER | Map::BLOCKMASK_MONSTER);
- currentInfo->setBlockType(Map::BLOCKTYPE_MONSTER);
+ currentInfo->setBlockType(BlockType::MONSTER);
currentInfo->setName(XML::langProperty(
// TRANSLATORS: unknown info name
diff --git a/src/resources/map/blocktype.h b/src/resources/map/blocktype.h
new file mode 100644
index 000000000..7920c242c
--- /dev/null
+++ b/src/resources/map/blocktype.h
@@ -0,0 +1,42 @@
+/*
+ * 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_BLOCKTYPE_H
+#define RESOURCES_MAP_BLOCKTYPE_H
+
+namespace BlockType
+{
+ enum BlockType
+ {
+ NONE = -1,
+ WALL,
+ CHARACTER,
+ MONSTER,
+ AIR,
+ WATER,
+ GROUND,
+ GROUNDTOP,
+ NB_BLOCKTYPES
+ };
+}
+
+#endif // RESOURCES_MAP_BLOCKTYPE_H
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index cd94c6ae6..99b27bce2 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -130,7 +130,7 @@ Map::Map(const int width, const int height,
mCustom(false)
{
const int size = mWidth * mHeight;
- for (int i = 0; i < NB_BLOCKTYPES; i++)
+ for (int i = 0; i < BlockType::NB_BLOCKTYPES; i++)
{
mOccupation[i] = new unsigned[static_cast<size_t>(size)];
memset(mOccupation[i], 0, static_cast<size_t>(size)
@@ -153,7 +153,7 @@ Map::~Map()
CHECKLISTENERS
delete [] mMetaTiles;
- for (int i = 0; i < NB_BLOCKTYPES; i++)
+ for (int i = 0; i < BlockType::NB_BLOCKTYPES; i++)
delete [] mOccupation[i];
if (mWalkLayer)
@@ -622,9 +622,10 @@ const Tileset *Map::getTilesetWithGid(const int gid) const
return nullptr;
}
-void Map::blockTile(const int x, const int y, const BlockType type)
+void Map::blockTile(const int x, const int y,
+ const BlockType::BlockType type)
{
- if (type == BLOCKTYPE_NONE || !contains(x, y))
+ if (type == BlockType::NONE || !contains(x, y))
return;
const int tileNum = x + y * mWidth;
@@ -634,30 +635,30 @@ void Map::blockTile(const int x, const int y, const BlockType type)
{
switch (type)
{
- case BLOCKTYPE_WALL:
+ case BlockType::WALL:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_WALL;
break;
- case BLOCKTYPE_CHARACTER:
+ case BlockType::CHARACTER:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_CHARACTER;
break;
- case BLOCKTYPE_MONSTER:
+ case BlockType::MONSTER:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_MONSTER;
break;
- case BLOCKTYPE_AIR:
+ case BlockType::AIR:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_AIR;
break;
- case BLOCKTYPE_WATER:
+ case BlockType::WATER:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_WATER;
break;
- case BLOCKTYPE_GROUND:
+ case BlockType::GROUND:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUND;
break;
- case BLOCKTYPE_GROUNDTOP:
+ case BlockType::GROUNDTOP:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_GROUNDTOP;
break;
default:
- case BLOCKTYPE_NONE:
- case NB_BLOCKTYPES:
+ case BlockType::NONE:
+ case BlockType::NB_BLOCKTYPES:
// Do nothing.
break;
}
@@ -686,7 +687,7 @@ unsigned char Map::getBlockMask(const int x, const int y) const
void Map::setWalk(const int x, const int y, const bool walkable A_UNUSED)
{
- blockTile(x, y, Map::BLOCKTYPE_GROUNDTOP);
+ blockTile(x, y, BlockType::GROUNDTOP);
}
bool Map::contains(const int x, const int y) const
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
index dac1778c3..0085206a6 100644
--- a/src/resources/map/map.h
+++ b/src/resources/map/map.h
@@ -27,6 +27,7 @@
#include "being/actor.h"
+#include "resources/map/blocktype.h"
#include "resources/map/metatile.h"
#include "resources/map/properties.h"
@@ -66,19 +67,6 @@ typedef AmbientLayerVector::iterator AmbientLayerVectorIter;
class Map final : public Properties, public ConfigListener
{
public:
- enum BlockType
- {
- BLOCKTYPE_NONE = -1,
- BLOCKTYPE_WALL,
- BLOCKTYPE_CHARACTER,
- BLOCKTYPE_MONSTER,
- BLOCKTYPE_AIR,
- BLOCKTYPE_WATER,
- BLOCKTYPE_GROUND,
- BLOCKTYPE_GROUNDTOP,
- NB_BLOCKTYPES
- };
-
enum CollisionTypes
{
COLLISION_EMPTY = 0, // no collision
@@ -175,7 +163,8 @@ class Map final : public Properties, public ConfigListener
/**
* Marks a tile as occupied.
*/
- void blockTile(const int x, const int y, const BlockType type);
+ void blockTile(const int x, const int y,
+ const BlockType::BlockType type);
/**
* Gets walkability for a tile with a blocking bitmask. When called
@@ -399,7 +388,7 @@ class Map final : public Properties, public ConfigListener
/**
* Blockmasks for different entities
*/
- unsigned *mOccupation[NB_BLOCKTYPES];
+ unsigned *mOccupation[BlockType::NB_BLOCKTYPES];
int mWidth;
int mHeight;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index ebdca49ac..54f80fe79 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -27,6 +27,7 @@
#include "logger.h"
#include "main.h"
+#include "resources/map/blocktype.h"
#include "resources/map/map.h"
#include "resources/map/mapconsts.h"
#include "resources/map/tileset.h"
@@ -496,19 +497,19 @@ inline static void setTile(Map *const map, MapLayer *const layer,
switch (gid - set->getFirstGid())
{
case Map::COLLISION_EMPTY:
- map->blockTile(x, y, Map::BLOCKTYPE_GROUND);
+ map->blockTile(x, y, BlockType::GROUND);
break;
case Map::COLLISION_WALL:
- map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ map->blockTile(x, y, BlockType::WALL);
break;
case Map::COLLISION_AIR:
- map->blockTile(x, y, Map::BLOCKTYPE_AIR);
+ map->blockTile(x, y, BlockType::AIR);
break;
case Map::COLLISION_WATER:
- map->blockTile(x, y, Map::BLOCKTYPE_WATER);
+ map->blockTile(x, y, BlockType::WATER);
break;
case Map::COLLISION_GROUNDTOP:
- map->blockTile(x, y, Map::BLOCKTYPE_GROUNDTOP);
+ map->blockTile(x, y, BlockType::GROUNDTOP);
break;
default:
break;
@@ -517,7 +518,7 @@ inline static void setTile(Map *const map, MapLayer *const layer,
else
{
if (gid - set->getFirstGid() != 0)
- map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ map->blockTile(x, y, BlockType::WALL);
}
}
break;