summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-03-15 00:03:26 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-03-15 00:03:26 +0000
commit7a54839fa261a3a61b245e8e22bb49da03a80676 (patch)
tree560bb5314a18454d449b8e0995f2346a73e6cd84
parentc6915bd4a4fc4702094e5e6070b62651bb97bfdb (diff)
downloadmana-client-7a54839fa261a3a61b245e8e22bb49da03a80676.tar.gz
mana-client-7a54839fa261a3a61b245e8e22bb49da03a80676.tar.bz2
mana-client-7a54839fa261a3a61b245e8e22bb49da03a80676.tar.xz
mana-client-7a54839fa261a3a61b245e8e22bb49da03a80676.zip
Fixed a crash caused by the new blocking system.
-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)
{