summaryrefslogtreecommitdiff
path: root/landscape.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-01-03 11:11:16 +0000
committertruelight <truelight@openttd.org>2005-01-03 11:11:16 +0000
commit7e89cd8643b7fc717cf4695bbb4fc83488eaa302 (patch)
tree2f5fdfa2b4700b965035d79e4dc04246ba735f89 /landscape.c
parent6c4840fa507257186d457561c6de930db3f20f98 (diff)
downloadopenttd-7e89cd8643b7fc717cf4695bbb4fc83488eaa302.tar.xz
(svn r1332) -Fix: Desert-landscape does no longer crash (protected GetMapExtraBits
from overflowing)
Diffstat (limited to 'landscape.c')
-rw-r--r--landscape.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/landscape.c b/landscape.c
index f10e699ca..67806fad8 100644
--- a/landscape.c
+++ b/landscape.c
@@ -444,7 +444,11 @@ void SetMapExtraBits(uint tile, byte bits)
uint GetMapExtraBits(uint tile)
{
- return (_map_extra_bits[tile >> 2] >> (tile&3)*2)&3;
+ if (GET_TILE_X(tile) < MapSizeX() && GET_TILE_Y(tile) < MapSizeY() &&
+ GET_TILE_X(tile) > 0 && GET_TILE_Y(tile) > 0)
+ return (_map_extra_bits[tile >> 2] >> (tile&3)*2)&3;
+ else
+ return 0;
}
#define TILELOOP_BITS 4