summaryrefslogtreecommitdiff
path: root/src/newgrf_commons.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-06-05 01:49:08 +0000
committerbelugas <belugas@openttd.org>2007-06-05 01:49:08 +0000
commit46d4d0d989b843d7dacfa4b1ac5e6562aa17b624 (patch)
treebdd74617d99055e49ce1e28cd9c135ef2da73080 /src/newgrf_commons.cpp
parent1026c865fd939f8c0b2a4a058646195cb210af5d (diff)
downloadopenttd-46d4d0d989b843d7dacfa4b1ac5e6562aa17b624.tar.xz
(svn r10040) -Codechange: Make the function GetTerrainType public, as other functions require it
Diffstat (limited to 'src/newgrf_commons.cpp')
-rw-r--r--src/newgrf_commons.cpp17
1 files changed, 17 insertions, 0 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;
+ }
+}
+