summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-26 22:38:40 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-26 22:38:40 +0300
commit3d6d504c4bad50f64d4d54213b13439e938aa517 (patch)
tree309ae16c4218f509b68c1032368cccb617bc8dd0 /src/map.cpp
parent52b44e43f282882a83a6c7591c454c1b38ca55d5 (diff)
downloadmanaverse-3d6d504c4bad50f64d4d54213b13439e938aa517.tar.gz
manaverse-3d6d504c4bad50f64d4d54213b13439e938aa517.tar.bz2
manaverse-3d6d504c4bad50f64d4d54213b13439e938aa517.tar.xz
manaverse-3d6d504c4bad50f64d4d54213b13439e938aa517.zip
Bit improve speed in map getwalk.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 773e6ecdc..66c2315ee 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -676,12 +676,14 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
int width = 0;
int x0 = x;
- if (!getWalk(x, y, BLOCKMASK_WALL))
+// if (!getWalk(x, y, BLOCKMASK_WALL))
+ if (mMetaTiles[x + y * mWidth].blockmask & BLOCKMASK_WALL)
{
width = 32;
for (int x2 = x + 1; x < endX; x2 ++)
{
- if (getWalk(x2, y, BLOCKMASK_WALL))
+// if (getWalk(x2, y, BLOCKMASK_WALL))
+ if (!(mMetaTiles[x2 + y * mWidth].blockmask & BLOCKMASK_WALL))
break;
width += 32;
x ++;
@@ -698,12 +700,14 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
}
}
- if (x < endX && !getWalk(x, y, BLOCKMASK_AIR))
+// if (x < endX && !getWalk(x, y, BLOCKMASK_AIR))
+ if (x < endX && mMetaTiles[x + y * mWidth].blockmask & BLOCKMASK_AIR)
{
width = 32;
for (int x2 = x + 1; x < endX; x2 ++)
{
- if (getWalk(x2, y, BLOCKMASK_AIR))
+ if (!(mMetaTiles[x2 + y * mWidth].blockmask & BLOCKMASK_AIR))
+ //if (getWalk(x2, y, BLOCKMASK_AIR))
break;
width += 32;
x ++;
@@ -720,12 +724,14 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
}
}
- if (x < endX && !getWalk(x, y, BLOCKMASK_WATER))
+ if (x < endX && mMetaTiles[x + y * mWidth].blockmask & BLOCKMASK_WATER)
+// if (x < endX && !getWalk(x, y, BLOCKMASK_WATER))
{
width = 32;
for (int x2 = x + 1; x < endX; x2 ++)
{
- if (getWalk(x2, y, BLOCKMASK_WATER))
+ if (!(mMetaTiles[x2 + y * mWidth].blockmask & BLOCKMASK_WATER))
+// if (getWalk(x2, y, BLOCKMASK_WATER))
break;
width += 32;
x ++;
@@ -856,7 +862,7 @@ void Map::blockTile(int x, int y, BlockType type)
bool Map::getWalk(int x, int y, unsigned char walkmask) const
{
// You can't walk outside of the map
- if (!contains(x, y))
+ if (x < 0 || y < 0 || x >= mWidth || y >= mHeight)
return false;
// Check if the tile is walkable