From 7a54839fa261a3a61b245e8e22bb49da03a80676 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Sat, 15 Mar 2008 00:03:26 +0000 Subject: Fixed a crash caused by the new blocking system. --- src/map.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index f7b16427..c7d1d3b8 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -339,9 +339,12 @@ Image* Map::getTileWithGid(int gid) const void Map::blockTile(int x, int y, BlockType type) { - if (type == BLOCKTYPE_NONE) return; + if (type == BLOCKTYPE_NONE || x < 0 || y < 0 || x >= mWidth || y >= mHeight) + { + return; + } + int tileNum = x + y * mWidth; - assert (tileNum <= mWidth * mHeight); if ((++mOccupation[type][tileNum]) > 0) { @@ -365,10 +368,12 @@ void Map::blockTile(int x, int y, BlockType type) void Map::freeTile(int x, int y, BlockType type) { - if (type == BLOCKTYPE_NONE) return; + if (type == BLOCKTYPE_NONE || x < 0 || y < 0 || x >= mWidth || y >= mHeight) + { + return; + } int tileNum = x + y * mWidth; - assert (tileNum <= mWidth * mHeight); if ((--mOccupation[type][tileNum]) <= 0) { -- cgit v1.2.3-70-g09d2