summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being/being.cpp16
-rw-r--r--src/being/being.h4
-rw-r--r--src/being/localplayer.cpp44
-rw-r--r--src/being/localplayer.h2
-rw-r--r--src/gui/viewport.cpp2
-rw-r--r--src/navigationmanager.cpp12
-rw-r--r--src/resources/beinginfo.cpp6
-rw-r--r--src/resources/beinginfo.h10
-rw-r--r--src/resources/db/monsterdb.cpp5
-rw-r--r--src/resources/map/map.cpp12
-rw-r--r--src/resources/map/map.h4
11 files changed, 58 insertions, 59 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index f45fa4ec8..a47738868 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -387,7 +387,7 @@ void Being::setDestination(const int dstX, const int dstY)
if (!mMap)
return;
- setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
+ setPath(mMap->findPath(mX, mY, dstX, dstY, getBlockWalkMask()));
}
void Being::clearPath()
@@ -1336,7 +1336,7 @@ void Being::nextTile()
if (dir)
setDirection(dir);
- if (!mMap || !mMap->getWalk(pos.x, pos.y, getWalkMask()))
+ if (!mMap || !mMap->getWalk(pos.x, pos.y, getBlockWalkMask()))
{
setAction(BeingAction::STAND, 0);
return;
@@ -1560,25 +1560,25 @@ void Being::petLogic()
}
}
- const unsigned char walkMask = getWalkMask();
- if (!mMap->getWalk(dstX, dstY, walkMask))
+ const unsigned char blockWalkMask = getBlockWalkMask();
+ if (!mMap->getWalk(dstX, dstY, blockWalkMask))
{
if (dstX != dstX0)
{
dstX = dstX0;
- if (!mMap->getWalk(dstX, dstY, walkMask))
+ if (!mMap->getWalk(dstX, dstY, blockWalkMask))
dstY = dstY0;
}
else if (dstY != dstY0)
{
dstY = dstY0;
- if (!mMap->getWalk(dstX, dstY, walkMask))
+ if (!mMap->getWalk(dstX, dstY, blockWalkMask))
dstX = dstX0;
}
}
if (mX != dstX || mY != dstY)
{
- setPath(mMap->findPath(mX, mY, dstX, dstY, walkMask));
+ setPath(mMap->findPath(mX, mY, dstX, dstY, blockWalkMask));
Net::getPetHandler()->move(mOwner, mId, mX, mY, dstX, dstY);
return;
}
@@ -3278,7 +3278,7 @@ void Being::fixPetSpawnPos(int &dstX, int &dstY) const
dstY += offsetY;
if (mMap)
{
- if (!mMap->getWalk(dstX, dstY, getWalkMask()))
+ if (!mMap->getWalk(dstX, dstY, getBlockWalkMask()))
{
dstX = mOwner->getTileX();
dstY = mOwner->getTileY();
diff --git a/src/being/being.h b/src/being/being.h
index 929ebf8d9..c50cdf871 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -412,11 +412,11 @@ class Being notfinal : public ActorSprite,
/**
* Gets the way the object is blocked by other objects.
*/
- virtual unsigned char getWalkMask() const A_WARN_UNUSED
+ virtual unsigned char getBlockWalkMask() const A_WARN_UNUSED
{
if (!mInfo)
return 0;
- return mInfo->getWalkMask();
+ return mInfo->getBlockWalkMask();
}
/**
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 55859ae69..446deec36 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -490,7 +490,7 @@ bool LocalPlayer::pickUp(FloorItem *const item)
const Path debugPath = mMap->findPath(
static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
- item->getTileX(), item->getTileY(), getWalkMask(), 0);
+ item->getTileX(), item->getTileY(), getBlockWalkMask(), 0);
if (!debugPath.empty())
navigateTo(item->getTileX(), item->getTileY());
else
@@ -623,19 +623,19 @@ void LocalPlayer::startWalking(const unsigned char dir)
if (dir & BeingDirection::RIGHT)
dx++;
- const unsigned char walkMask = getWalkMask();
+ const unsigned char blockWalkMask = getBlockWalkMask();
// Prevent skipping corners over colliding tiles
- if (dx && !mMap->getWalk(mX + dx, mY, walkMask))
+ if (dx && !mMap->getWalk(mX + dx, mY, blockWalkMask))
dx = 0;
- if (dy && !mMap->getWalk(mX, mY + dy, walkMask))
+ if (dy && !mMap->getWalk(mX, mY + dy, blockWalkMask))
dy = 0;
// Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, walkMask))
+ if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
dx = 0;
// Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, walkMask))
+ if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
{
setDestination(mX + dx, mY + dy);
}
@@ -1148,7 +1148,7 @@ void LocalPlayer::moveToTarget(int dist)
debugPath = mMap->findPath(static_cast<int>(
playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
- mTarget->getTileX(), mTarget->getTileY(), getWalkMask(), 0);
+ mTarget->getTileX(), mTarget->getTileY(), getBlockWalkMask(), 0);
}
const size_t sz = debugPath.size();
@@ -1599,46 +1599,46 @@ void LocalPlayer::crazyMove8()
int mult = 1;
- const unsigned char walkMask = getWalkMask();
+ const unsigned char blockWalkMask = getBlockWalkMask();
if (mMap->getWalk(mX + movesX[idx][0],
- mY + movesY[idx][0], walkMask))
+ mY + movesY[idx][0], blockWalkMask))
{
while (mMap->getWalk(mX + movesX[idx][0] * mult,
mY + movesY[idx][0] * mult,
- getWalkMask()) && mult <= dist)
+ getBlockWalkMask()) && mult <= dist)
{
mult ++;
}
move(movesX[idx][0] * (mult - 1), movesY[idx][0] * (mult - 1));
}
else if (mMap->getWalk(mX + movesX[idx][1],
- mY + movesY[idx][1], walkMask))
+ mY + movesY[idx][1], blockWalkMask))
{
while (mMap->getWalk(mX + movesX[idx][1] * mult,
mY + movesY[idx][1] * mult,
- getWalkMask()) && mult <= dist)
+ getBlockWalkMask()) && mult <= dist)
{
mult ++;
}
move(movesX[idx][1] * (mult - 1), movesY[idx][1] * (mult - 1));
}
else if (mMap->getWalk(mX + movesX[idx][2],
- mY + movesY[idx][2], walkMask))
+ mY + movesY[idx][2], blockWalkMask))
{
while (mMap->getWalk(mX + movesX[idx][2] * mult,
mY + movesY[idx][2] * mult,
- getWalkMask()) && mult <= dist)
+ getBlockWalkMask()) && mult <= dist)
{
mult ++;
}
move(movesX[idx][2] * (mult - 1), movesY[idx][2] * (mult - 1));
}
else if (mMap->getWalk(mX + movesX[idx][3],
- mY + movesY[idx][3], walkMask))
+ mY + movesY[idx][3], blockWalkMask))
{
while (mMap->getWalk(mX + movesX[idx][3] * mult,
mY + movesY[idx][3] * mult,
- getWalkMask()) && mult <= dist)
+ getBlockWalkMask()) && mult <= dist)
{
mult ++;
}
@@ -2009,7 +2009,7 @@ bool LocalPlayer::isReachable(Being *const being,
const Path debugPath = mMap->findPath(
static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
- being->getTileX(), being->getTileY(), getWalkMask(), maxCost);
+ being->getTileX(), being->getTileY(), getBlockWalkMask(), maxCost);
being->setDistance(static_cast<int>(debugPath.size()));
if (!debugPath.empty())
@@ -2557,7 +2557,7 @@ bool LocalPlayer::navigateTo(const int x, const int y)
mNavigatePath = mMap->findPath(
static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
- x, y, getWalkMask(), 0);
+ x, y, getBlockWalkMask(), 0);
if (mDrawPath)
tmpLayer->addRoad(mNavigatePath);
@@ -2586,7 +2586,7 @@ void LocalPlayer::navigateTo(const Being *const being)
static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
being->getTileX(), being->getTileY(),
- getWalkMask(), 0);
+ getBlockWalkMask(), 0);
if (mDrawPath)
tmpLayer->addRoad(mNavigatePath);
@@ -2751,7 +2751,7 @@ int LocalPlayer::getPathLength(const Being *const being) const
static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
being->getTileX(), being->getTileY(),
- getWalkMask(), 0);
+ getBlockWalkMask(), 0);
return static_cast<int>(debugPath.size());
}
else
@@ -3126,7 +3126,7 @@ void LocalPlayer::fixAttackTarget()
static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
mTarget->getTileX(), mTarget->getTileY(),
- getWalkMask(), 0);
+ getBlockWalkMask(), 0);
if (!debugPath.empty())
{
@@ -3208,7 +3208,7 @@ void LocalPlayer::checkNewName(Being *const being)
}
}
-unsigned char LocalPlayer::getWalkMask() const
+unsigned char LocalPlayer::getBlockWalkMask() const
{
// for now blocking all types of collisions
return BlockMask::WALL | BlockMask::AIR | BlockMask::WATER;
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index c27b04f47..63d122f44 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -366,7 +366,7 @@ class LocalPlayer final : public Being,
void checkNewName(Being *const being);
- unsigned char getWalkMask() const override final A_WARN_UNUSED;
+ unsigned char getBlockWalkMask() const override final A_WARN_UNUSED;
void saveHomes();
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 353a5595f..7ae46dddf 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -316,7 +316,7 @@ void Viewport::drawDebugPath(Graphics *const graphics)
static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
mousePosX / mapTileSize, mousePosY / mapTileSize,
- localPlayer->getWalkMask(),
+ localPlayer->getBlockWalkMask(),
500);
lastMouseDestination = mouseDestination;
}
diff --git a/src/navigationmanager.cpp b/src/navigationmanager.cpp
index 9b164a478..74d0a98df 100644
--- a/src/navigationmanager.cpp
+++ b/src/navigationmanager.cpp
@@ -26,7 +26,7 @@
#include "debug.h"
-static const int walkMask = (BlockMask::WALL | BlockMask::AIR
+static const int blockWalkMask = (BlockMask::WALL | BlockMask::AIR
| BlockMask::WATER);
namespace
@@ -89,7 +89,7 @@ bool NavigationManager::findWalkableTile(int &x1, int &y1,
for (int x = 0; x < width; x ++)
{
const int ptr = x + y2;
- if (!(tiles[ptr].blockmask & walkMask) && !data[ptr])
+ if (!(tiles[ptr].blockmask & blockWalkMask) && !data[ptr])
{
x1 = x;
y1 = y;
@@ -120,7 +120,7 @@ void NavigationManager::fillNum(int x, int y,
ptr = (x - 1) + width * y;
if (!data[ptr])
{
- if (!(tiles[ptr].blockmask & walkMask))
+ if (!(tiles[ptr].blockmask & blockWalkMask))
cells.push_back(Cell(x - 1, y));
else
data[ptr] = -num;
@@ -131,7 +131,7 @@ void NavigationManager::fillNum(int x, int y,
ptr = (x + 1) + width * y;
if (!data[ptr])
{
- if (!(tiles[ptr].blockmask & walkMask))
+ if (!(tiles[ptr].blockmask & blockWalkMask))
cells.push_back(Cell(x + 1, y));
else
data[ptr] = -num;
@@ -142,7 +142,7 @@ void NavigationManager::fillNum(int x, int y,
ptr = x + width * (y - 1);
if (!data[ptr])
{
- if (!(tiles[ptr].blockmask & walkMask))
+ if (!(tiles[ptr].blockmask & blockWalkMask))
cells.push_back(Cell(x, y - 1));
else
data[ptr] = -num;
@@ -153,7 +153,7 @@ void NavigationManager::fillNum(int x, int y,
ptr = x + width * (y + 1);
if (!data[ptr])
{
- if (!(tiles[ptr].blockmask & walkMask))
+ if (!(tiles[ptr].blockmask & blockWalkMask))
cells.push_back(Cell(x, y + 1));
else
data[ptr] = -num;
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index bd4359144..5f1704b88 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -52,9 +52,9 @@ BeingInfo::BeingInfo() :
mHoverCursor(Cursor::CURSOR_POINTER),
mSounds(),
mAttacks(),
- mWalkMask(BlockMask::WALL | BlockMask::CHARACTER
- | BlockMask::MONSTER | BlockMask::AIR
- | BlockMask::WATER),
+ mBlockWalkMask(BlockMask::WALL | BlockMask::CHARACTER
+ | BlockMask::MONSTER | BlockMask::AIR
+ | BlockMask::WATER),
mBlockType(BlockType::CHARACTER),
mColors(nullptr),
mTargetOffsetX(0),
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index efac5cc3a..76955d2dd 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -110,14 +110,14 @@ class BeingInfo final
const Attack *getAttack(const int id) const A_WARN_UNUSED;
- void setWalkMask(const unsigned char mask)
- { mWalkMask = mask; }
+ void setBlockWalkMask(const unsigned char mask)
+ { mBlockWalkMask = mask; }
/**
* Gets the way the being is blocked by other objects
*/
- unsigned char getWalkMask() const A_WARN_UNUSED
- { return mWalkMask; }
+ unsigned char getBlockWalkMask() const A_WARN_UNUSED
+ { return mBlockWalkMask; }
void setBlockType(const BlockType::BlockType &blockType)
{ mBlockType = blockType; }
@@ -326,7 +326,7 @@ class BeingInfo final
Cursor::Cursor mHoverCursor;
ItemSoundEvents mSounds;
Attacks mAttacks;
- unsigned char mWalkMask;
+ unsigned char mBlockWalkMask;
BlockType::BlockType mBlockType;
const std::map <int, ColorDB::ItemColor> *mColors;
int mTargetOffsetX;
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
index a78707571..7897d6198 100644
--- a/src/resources/db/monsterdb.cpp
+++ b/src/resources/db/monsterdb.cpp
@@ -97,10 +97,7 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
if (!currentInfo)
currentInfo = new BeingInfo;
- currentInfo->setWalkMask(BlockMask::WALL
- | BlockMask::CHARACTER | BlockMask::MONSTER);
currentInfo->setBlockType(BlockType::MONSTER);
-
currentInfo->setName(XML::langProperty(
// TRANSLATORS: unknown info name
monsterNode, "name", _("unnamed")));
@@ -127,7 +124,7 @@ void MonsterDB::loadXmlFile(const std::string &fileName)
else if (walkStr == "walkswim" || walkStr == "swimwalk")
block = BlockMask::AIR;
- currentInfo->setWalkMask(static_cast<unsigned char>(
+ currentInfo->setBlockWalkMask(static_cast<unsigned char>(
BlockMask::WALL | block));
if (currentInfo->getMaxHP())
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index f7f4b900f..694c6f934 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -672,14 +672,15 @@ void Map::blockTile(const int x, const int y,
}
}
-bool Map::getWalk(const int x, const int y, const unsigned char walkmask) const
+bool Map::getWalk(const int x, const int y,
+ const unsigned char blockWalkMask) const
{
// You can't walk outside of the map
if (x < 0 || y < 0 || x >= mWidth || y >= mHeight)
return false;
// Check if the tile is walkable
- return !(mMetaTiles[x + y * mWidth].blockmask & walkmask);
+ return !(mMetaTiles[x + y * mWidth].blockmask & blockWalkMask);
}
unsigned char Map::getBlockMask(const int x, const int y) const
@@ -742,7 +743,8 @@ const std::string Map::getFilename() const
Path Map::findPath(const int startX, const int startY,
const int destX, const int destY,
- const unsigned char walkmask, const int maxCost)
+ const unsigned char blockWalkMask,
+ const int maxCost)
{
BLOCK_START("Map::findPath")
// The basic walking cost of a tile.
@@ -760,7 +762,7 @@ Path Map::findPath(const int startX, const int startY,
}
// Return when destination not walkable
- if (!getWalk(destX, destY, walkmask))
+ if (!getWalk(destX, destY, blockWalkMask))
{
BLOCK_END("Map::findPath")
return path;
@@ -830,7 +832,7 @@ Path Map::findPath(const int startX, const int startY,
// unless its the destination tile
// +++ here need check block must depend on player abilities.
if (newTile->whichList == mOnClosedList ||
- ((newTile->blockmask & walkmask)
+ ((newTile->blockmask & blockWalkMask)
&& !(x == destX && y == destY))
|| (newTile->blockmask & BlockMask::WALL))
{
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
index 21976d38a..2026500ad 100644
--- a/src/resources/map/map.h
+++ b/src/resources/map/map.h
@@ -150,7 +150,7 @@ 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
+ const unsigned char blockWalkMask = BlockMask::WALL
| BlockMask::AIR | BlockMask::WATER) const A_WARN_UNUSED;
void setWalk(const int x, const int y, const bool walkable);
@@ -197,7 +197,7 @@ class Map final : public Properties, public ConfigListener
*/
Path findPath(const int startX, const int startY,
const int destX, const int destY,
- const unsigned char walkmask,
+ const unsigned char blockWalkmask,
const int maxCost = 20) A_WARN_UNUSED;
/**