From a95fdc8bb5fe2baba77c266c2f40ac15a5880bfa Mon Sep 17 00:00:00 2001 From: belugas Date: Tue, 5 Jun 2007 01:49:08 +0000 Subject: (svn r10040) -Codechange: Make the function GetTerrainType public, as other functions require it --- src/newgrf_commons.cpp | 17 +++++++++++++++++ src/newgrf_commons.h | 2 ++ src/newgrf_house.cpp | 9 --------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index f52c1442a..5291bbac9 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -6,6 +6,8 @@ #include "stdafx.h" #include "openttd.h" +#include "variables.h" +#include "clear_map.h" #include "town.h" #include "industry.h" #include "newgrf.h" @@ -148,3 +150,18 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) entity_overrides[i] = invalid_ID; } } + +/** Function used by houses (and soon industries) to get information + * on type of "terrain" the tile it is queries sits on. + * @param tile TileIndex of the tile been queried + * @return value corresponding to the grf expected format: + * Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline */ +uint32 GetTerrainType(TileIndex tile) +{ + switch (_opt.landscape) { + case LT_TROPIC: return GetTropicZone(tile) == TROPICZONE_DESERT ? 1 : 2; + case LT_ARCTIC: return (GetClearGround(tile) == CLEAR_SNOW) ? 4 : 0; + default: return 0; + } +} + diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 812f514a6..070fb1feb 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -66,4 +66,6 @@ public: extern HouseOverrideManager _house_mngr; +uint32 GetTerrainType(TileIndex tile); + #endif /* NEWGRF_COMMONS_H */ diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 2883f9b2d..b36628c2a 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -169,15 +169,6 @@ static uint32 GetNumHouses(HouseID house_id, const Town *town) return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count; } -static uint32 GetTerrainType(TileIndex tile) -{ - switch (_opt.landscape) { - case LT_TROPIC: return GetTropicZone(tile) == TROPICZONE_DESERT ? 1 : 2; - case LT_ARCTIC: return GetTileZ(tile) >= GetSnowLine() ? 4 : 0; - default: return 0; - } -} - static uint32 GetGRFParameter(HouseID house_id, byte parameter) { const HouseSpec *hs = GetHouseSpecs(house_id); -- cgit v1.2.3-54-g00ecf