diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-26 00:04:45 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-26 00:04:45 +0000 |
commit | 8b0e30d3798cd5bdce2c3a34a3c384e90dceac99 (patch) | |
tree | 3fdca13a0cc138ed65b72de8cd3747cc79916818 /src/map.cpp | |
parent | a31ba215a3043ebd62d415a7d855a531239fb630 (diff) | |
download | mana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.tar.gz mana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.tar.bz2 mana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.tar.xz mana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.zip |
Changed keyboard control to integrate better with mouse walk, changed location
of packet.list and chatlog.txt and removed name from player chat "balloon".
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/map.cpp b/src/map.cpp index df9aafc5..a658d8c6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -222,27 +222,32 @@ void Map::setWalk(int x, int y, bool walkable) bool Map::getWalk(int x, int y) { - // You can't walk outside of the map - if (x < 0 || y < 0 || x >= width || y >= height) { - return false; - } - - // Check if the tile is walkable - bool ret = metaTiles[x + y * width].walkable; - // If walkable, check for colliding into a being - if (ret) { + if (!tileCollides(x, y)) { std::list<Being*>::iterator i = beings.begin(); - while (i != beings.end() && ret) { + while (i != beings.end()) { Being *being = (*i); if (being->x == x && being->y == y) { return false; } i++; } + return true; + } + else { + return false; + } +} + +bool Map::tileCollides(int x, int y) +{ + // You can't walk outside of the map + if (x < 0 || y < 0 || x >= width || y >= height) { + return true; } - return ret; + // Check if the tile is walkable + return !metaTiles[x + y * width].walkable; } void Map::setTile(int x, int y, int layer, Image *img) @@ -405,7 +410,7 @@ std::list<PATH_NODE> Map::findPath( } } - // Two new values to indicate wether a tile is on the open or closed list, + // Two new values to indicate whether a tile is on the open or closed list, // this way we don't have to clear all the values between each pathfinding. onClosedList += 2; onOpenList += 2; |