summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-08 21:07:03 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-08 21:07:03 +0300
commit451e5fbbf6a3ee7077caf31a45a37945c3a9ecf7 (patch)
tree74e7be67e1791ab5a398171f79fbef09b2d89b5a
parent461bfb657a0300f27e3ffed55a78ce9249b54759 (diff)
downloadplus-s20160809.tar.gz
plus-s20160809.tar.bz2
plus-s20160809.tar.xz
plus-s20160809.zip
Remove default value from block mask in Map::getWalk.s20160809
-rw-r--r--src/gui/viewport.cpp74
-rw-r--r--src/resources/map/map.h3
2 files changed, 67 insertions, 10 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index e476e4b38..672708394 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -623,8 +623,15 @@ void Viewport::getMouseTile(const int x, const int y,
const int tileViewY = mPixelViewY / th;
for (int f = tileViewY; f < tileViewY + heightTiles; f ++)
{
- if (!mMap->getWalk(destX, f))
+ if (!mMap->getWalk(destX,
+ f,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
+ {
continue;
+ }
const int offset = mMap->getHeightOffset(
destX, f) * th2;
@@ -697,7 +704,12 @@ void Viewport::walkByMouse(const MouseEvent &event)
else if (y < 0)
dy = -1;
- if (mMap->getWalk(playerX + dx, playerY + dy))
+ if (mMap->getWalk(playerX + dx,
+ playerY + dy,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
{
localPlayer->navigateTo(playerX + dx, playerY + dy);
}
@@ -708,17 +720,35 @@ void Viewport::walkByMouse(const MouseEvent &event)
// try avoid diagonal collision
if (x2 > y2)
{
- if (mMap->getWalk(playerX + dx, playerY))
+ if (mMap->getWalk(playerX + dx,
+ playerY,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
+ {
dy = 0;
+ }
else
+ {
dx = 0;
+ }
}
else
{
- if (mMap->getWalk(playerX, playerY + dy))
+ if (mMap->getWalk(playerX,
+ playerY + dy,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
+ {
dx = 0;
+ }
else
+ {
dy = 0;
+ }
}
}
else
@@ -726,17 +756,45 @@ void Viewport::walkByMouse(const MouseEvent &event)
// try avoid vertical or horisontal collision
if (!dx)
{
- if (mMap->getWalk(playerX + 1, playerY + dy))
+ if (mMap->getWalk(playerX + 1,
+ playerY + dy,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
+ {
dx = 1;
- if (mMap->getWalk(playerX - 1, playerY + dy))
+ }
+ if (mMap->getWalk(playerX - 1,
+ playerY + dy,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
+ {
dx = -1;
+ }
}
if (!dy)
{
- if (mMap->getWalk(playerX + dx, playerY + 1))
+ if (mMap->getWalk(playerX + dx,
+ playerY + 1,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
+ {
dy = 1;
- if (mMap->getWalk(playerX + dx, playerY - 1))
+ }
+ if (mMap->getWalk(playerX + dx,
+ playerY - 1,
+ BlockMask::WALL |
+ BlockMask::AIR |
+ BlockMask::WATER |
+ BlockMask::PLAYERWALL))
+ {
dy = -1;
+ }
}
}
localPlayer->navigateTo(playerX + dx, playerY + dy);
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
index 8f7b6dbab..d6c957df9 100644
--- a/src/resources/map/map.h
+++ b/src/resources/map/map.h
@@ -164,8 +164,7 @@ class Map final : public Properties,
* without walkmask, only blocks against colliding tiles.
*/
bool getWalk(const int x, const int y,
- const unsigned char blockWalkMask = BlockMask::WALL
- | BlockMask::AIR | BlockMask::WATER) const
+ const unsigned char blockWalkMask) const
restrict2 A_WARN_UNUSED;
void setWalk(const int x, const int y) restrict2;