diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-11 17:00:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-11 17:00:44 +0300 |
commit | 10cf17f8d83d2d925641f722acc004828dba3094 (patch) | |
tree | 46a746d5bfe79e067cd25a3caca476ecbafa0af5 /src | |
parent | 77bb74bd2d944be1a1dc719027dbf37ad088b828 (diff) | |
download | ManaVerse-10cf17f8d83d2d925641f722acc004828dba3094.tar.gz ManaVerse-10cf17f8d83d2d925641f722acc004828dba3094.tar.bz2 ManaVerse-10cf17f8d83d2d925641f722acc004828dba3094.tar.xz ManaVerse-10cf17f8d83d2d925641f722acc004828dba3094.zip |
Move blockmask into separate file.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/being/being.cpp | 22 | ||||
-rw-r--r-- | src/being/localplayer.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/minimap.cpp | 4 | ||||
-rw-r--r-- | src/navigationmanager.cpp | 4 | ||||
-rw-r--r-- | src/resources/beinginfo.cpp | 6 | ||||
-rw-r--r-- | src/resources/db/monsterdb.cpp | 12 | ||||
-rw-r--r-- | src/resources/map/blockmask.h | 40 | ||||
-rw-r--r-- | src/resources/map/map.cpp | 26 | ||||
-rw-r--r-- | src/resources/map/map.h | 16 |
11 files changed, 83 insertions, 51 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9e6b54c7..2aa6f5de7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -704,6 +704,7 @@ SET(SRCS logger.h main.cpp main.h + resources/map/blockmask.h resources/map/blocktype.h resources/map/location.h resources/map/map.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 38b432c86..dd43d57c3 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/blockmask.h \ resources/map/blocktype.h \ resources/map/location.h \ resources/map/map.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 386c07e92..c9af368b2 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1004,11 +1004,11 @@ std::string Being::getSitAction() const if (mMap) { const unsigned char mask = mMap->getBlockMask(mX, mY); - if (mask & Map::BLOCKMASK_GROUNDTOP) + if (mask & BlockMask::GROUNDTOP) return SpriteAction::SITTOP; - else if (mask & Map::BLOCKMASK_AIR) + else if (mask & BlockMask::AIR) return SpriteAction::SITSKY; - else if (mask & Map::BLOCKMASK_WATER) + else if (mask & BlockMask::WATER) return SpriteAction::SITWATER; } return SpriteAction::SIT; @@ -1027,9 +1027,9 @@ std::string Being::getMoveAction() const if (mMap) { const unsigned char mask = mMap->getBlockMask(mX, mY); - if (mask & Map::BLOCKMASK_AIR) + if (mask & BlockMask::AIR) return SpriteAction::FLY; - else if (mask & Map::BLOCKMASK_WATER) + else if (mask & BlockMask::WATER) return SpriteAction::SWIM; } return SpriteAction::MOVE; @@ -1050,9 +1050,9 @@ std::string Being::getWeaponAttackAction(const ItemInfo *const weapon) const if (mMap) { const unsigned char mask = mMap->getBlockMask(mX, mY); - if (mask & Map::BLOCKMASK_AIR) + if (mask & BlockMask::AIR) return weapon->getSkyAttackAction(); - else if (mask & Map::BLOCKMASK_WATER) + else if (mask & BlockMask::WATER) return weapon->getWaterAttackAction(); } return weapon->getAttackAction(); @@ -1073,9 +1073,9 @@ std::string Being::getAttackAction(const Attack *const attack1) const if (mMap) { const unsigned char mask = mMap->getBlockMask(mX, mY); - if (mask & Map::BLOCKMASK_AIR) + if (mask & BlockMask::AIR) return attack1->mSkyAction; - else if (mask & Map::BLOCKMASK_WATER) + else if (mask & BlockMask::WATER) return attack1->mWaterAction; } return attack1->mAction; @@ -1094,9 +1094,9 @@ std::string Being::getAttackAction(const Attack *const attack1) const if (mMap) \ { \ const unsigned char mask = mMap->getBlockMask(mX, mY); \ - if (mask & Map::BLOCKMASK_AIR) \ + if (mask & BlockMask::AIR) \ return SpriteAction::action##SKY; \ - else if (mask & Map::BLOCKMASK_WATER) \ + else if (mask & BlockMask::WATER) \ return SpriteAction::action##WATER; \ } \ return SpriteAction::action; \ diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 94edde0ab..7efaaa907 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -3689,7 +3689,7 @@ void LocalPlayer::resetYellowBar() unsigned char LocalPlayer::getWalkMask() const { // for now blocking all types of collisions - return Map::BLOCKMASK_WALL | Map::BLOCKMASK_AIR | Map::BLOCKMASK_WATER; + return BlockMask::WALL | BlockMask::AIR | BlockMask::WATER; } void LocalPlayer::removeHome() diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 70a2361cd..81d52387b 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -145,8 +145,8 @@ void Minimap::setMap(const Map *const map) return; } const int size = surface->h * surface->w; - const int mask = (Map::BLOCKMASK_WALL | Map::BLOCKMASK_AIR - | Map::BLOCKMASK_WATER); + const int mask = (BlockMask::WALL | BlockMask::AIR + | BlockMask::WATER); for (int ptr = 0; ptr < size; ptr ++) *(data ++) = -!(map->mMetaTiles[ptr].blockmask & mask); diff --git a/src/navigationmanager.cpp b/src/navigationmanager.cpp index 8cbb85667..ba4d5e989 100644 --- a/src/navigationmanager.cpp +++ b/src/navigationmanager.cpp @@ -23,8 +23,8 @@ #include "resources/map/map.h" #include "resources/map/walklayer.h" -static const int walkMask = (Map::BLOCKMASK_WALL | Map::BLOCKMASK_AIR - | Map::BLOCKMASK_WATER); +static const int walkMask = (BlockMask::WALL | BlockMask::AIR + | BlockMask::WATER); namespace { 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); |