From 19fb8ba6f88d2f684546e93388418f3757d80612 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 11 Jul 2010 17:11:14 +0000 Subject: [PATCH] (svn r20125) -Change: [NewGRF] If a tile has a snow-flag in the map array, use that for Terrain Type variables, instead of always only using the tile Z position. Also use the maximum Z of a tile for tiles which usually have levelling foundations (stations, houses, industries, unmovables). --- src/newgrf_commons.cpp | 46 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index f95ad985cb..ec48104612 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -17,8 +17,10 @@ #include "industrytype.h" #include "newgrf.h" #include "newgrf_commons.h" +#include "clear_map.h" #include "station_map.h" #include "tree_map.h" +#include "tunnelbridge_map.h" #include "core/mem_func.hpp" /** Constructor of generic class @@ -284,7 +286,49 @@ uint32 GetTerrainType(TileIndex tile) { switch (_settings_game.game_creation.landscape) { case LT_TROPIC: return GetTropicZone(tile); - case LT_ARCTIC: return GetTileZ(tile) > GetSnowLine() ? 4 : 0; + case LT_ARCTIC: { + bool has_snow; + switch (GetTileType(tile)) { + case MP_CLEAR: + has_snow = IsSnowTile(tile); + break; + + case MP_RAILWAY: { + RailGroundType ground = GetRailGroundType(tile); + has_snow = (ground == RAIL_GROUND_ICE_DESERT); + break; + } + + case MP_ROAD: + has_snow = IsOnSnow(tile); + break; + + case MP_TREES: { + TreeGround ground = GetTreeGround(tile); + has_snow = (ground == TREE_GROUND_SNOW_DESERT || ground == TREE_GROUND_ROUGH_SNOW); + break; + } + + case MP_TUNNELBRIDGE: + has_snow = HasTunnelBridgeSnowOrDesert(tile); + break; + + case MP_STATION: + case MP_HOUSE: + case MP_INDUSTRY: + case MP_UNMOVABLE: + /* These tiles usually have a levelling foundation. So use max Z */ + has_snow = (GetTileMaxZ(tile) > GetSnowLine()); + break; + + case MP_WATER: + has_snow = (GetTileZ(tile) > GetSnowLine()); + break; + + default: NOT_REACHED(); + } + return has_snow ? 4 : 0; + } default: return 0; } }