diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-03 13:31:45 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-03 13:31:45 +0000 |
commit | 47ddb7669a56c32597510d8153a6aa156bb4a397 (patch) | |
tree | c913f97f3b210ffb0913c8201b07d19eb9291c68 /src/map.cpp | |
parent | c6dfe82a271a04a28aa5b693f46a20716f300f43 (diff) | |
download | mana-client-47ddb7669a56c32597510d8153a6aa156bb4a397.tar.gz mana-client-47ddb7669a56c32597510d8153a6aa156bb4a397.tar.bz2 mana-client-47ddb7669a56c32597510d8153a6aa156bb4a397.tar.xz mana-client-47ddb7669a56c32597510d8153a6aa156bb4a397.zip |
Made getWalk return false for coordinates outside of the map, instead of crash.
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/map.cpp b/src/map.cpp index 0f531288..d4fb9dde 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -214,10 +214,16 @@ 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) { - // Check for colliding into a being std::list<Being*>::iterator i = beings.begin(); while (i != beings.end() && ret) { Being *being = (*i); |