diff options
author | yexo <yexo@openttd.org> | 2009-09-02 12:48:23 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-09-02 12:48:23 +0000 |
commit | 05433adb6d09f0514b983e631e3a8b334c6f1957 (patch) | |
tree | acbd48819284e5e8ae28097ff515f0e027acc559 /src/ai/api/ai_tile.cpp | |
parent | b7f7dd77bf565d719a2d2ada087f15978a79b48f (diff) | |
download | openttd-05433adb6d09f0514b983e631e3a8b334c6f1957.tar.xz |
(svn r17378) -Fix [NoAI]: Several AITile::* functions didn't check whether their parameters were valid
Diffstat (limited to 'src/ai/api/ai_tile.cpp')
-rw-r--r-- | src/ai/api/ai_tile.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ai/api/ai_tile.cpp b/src/ai/api/ai_tile.cpp index c0d1b59e0..35eed526b 100644 --- a/src/ai/api/ai_tile.cpp +++ b/src/ai/api/ai_tile.cpp @@ -95,31 +95,43 @@ /* static */ bool AITile::HasTreeOnTile(TileIndex tile) { + if (!::IsValidTile(tile)) return false; + return ::IsTileType(tile, MP_TREES); } /* static */ bool AITile::IsFarmTile(TileIndex tile) { + if (!::IsValidTile(tile)) return false; + return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_FIELDS)); } /* static */ bool AITile::IsRockTile(TileIndex tile) { + if (!::IsValidTile(tile)) return false; + return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_ROCKS)); } /* static */ bool AITile::IsRoughTile(TileIndex tile) { + if (!::IsValidTile(tile)) return false; + return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_ROUGH)); } /* static */ bool AITile::IsSnowTile(TileIndex tile) { + if (!::IsValidTile(tile)) return false; + return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_SNOW)); } /* static */ bool AITile::IsDesertTile(TileIndex tile) { + if (!::IsValidTile(tile)) return false; + return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_DESERT)); } |