diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-11 16:44:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-11 16:44:15 +0300 |
commit | 77bb74bd2d944be1a1dc719027dbf37ad088b828 (patch) | |
tree | 0feb040a768eff20220835eb359e767dc43f113c /src/resources/map | |
parent | 835dd846af75ea2cfc91f0134156f9c6545dd8ce (diff) | |
download | manaverse-77bb74bd2d944be1a1dc719027dbf37ad088b828.tar.gz manaverse-77bb74bd2d944be1a1dc719027dbf37ad088b828.tar.bz2 manaverse-77bb74bd2d944be1a1dc719027dbf37ad088b828.tar.xz manaverse-77bb74bd2d944be1a1dc719027dbf37ad088b828.zip |
Move blocktype into separate file.
Diffstat (limited to 'src/resources/map')
-rw-r--r-- | src/resources/map/blocktype.h | 42 | ||||
-rw-r--r-- | src/resources/map/map.cpp | 29 | ||||
-rw-r--r-- | src/resources/map/map.h | 19 |
3 files changed, 61 insertions, 29 deletions
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; |