From 47ddb7669a56c32597510d8153a6aa156bb4a397 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 3 Mar 2005 13:31:45 +0000 Subject: Made getWalk return false for coordinates outside of the map, instead of crash. --- src/map.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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::iterator i = beings.begin(); while (i != beings.end() && ret) { Being *being = (*i); -- cgit v1.2.3-70-g09d2