summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map.cpp13
1 files changed, 9 insertions, 4 deletions
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)
{