summaryrefslogtreecommitdiff
path: root/src/landscape.cpp
diff options
context:
space:
mode:
authorzuu <zuu@openttd.org>2013-10-12 22:07:58 +0000
committerzuu <zuu@openttd.org>2013-10-12 22:07:58 +0000
commitdfb566331390a87f01d048f57ed6d51b2f329d65 (patch)
tree76bcf6959e2acb63051f9f74a80b8154b95bc824 /src/landscape.cpp
parentb35b8aa5bb38f9e47ca04ccd9302dd82546de0cd (diff)
downloadopenttd-dfb566331390a87f01d048f57ed6d51b2f329d65.tar.xz
(svn r25849) -Codechange: Introduce IsTileFlat to not compute full slope information for situations when we only want to know if a tile is flat or not (cirdan, LordAro)
Diffstat (limited to 'src/landscape.cpp')
-rw-r--r--src/landscape.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 2e3e3d52e..d69275dd3 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -937,8 +937,7 @@ static void CreateDesertOrRainForest()
static bool FindSpring(TileIndex tile, void *user_data)
{
int referenceHeight;
- Slope s = GetTileSlope(tile, &referenceHeight);
- if (s != SLOPE_FLAT || IsWaterTile(tile)) return false;
+ if (!IsTileFlat(tile, &referenceHeight) || IsWaterTile(tile)) return false;
/* In the tropics rivers start in the rainforest. */
if (_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) != TROPICZONE_RAINFOREST) return false;
@@ -974,7 +973,7 @@ static bool FindSpring(TileIndex tile, void *user_data)
static bool MakeLake(TileIndex tile, void *user_data)
{
uint height = *(uint*)user_data;
- if (!IsValidTile(tile) || TileHeight(tile) != height || GetTileSlope(tile) != SLOPE_FLAT) return false;
+ if (!IsValidTile(tile) || TileHeight(tile) != height || !IsTileFlat(tile)) return false;
if (_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) == TROPICZONE_DESERT) return false;
for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
@@ -1123,7 +1122,7 @@ static bool FlowRiver(bool *marks, TileIndex spring, TileIndex begin)
queue.pop_front();
uint height2 = TileHeight(end);
- if (GetTileSlope(end) == SLOPE_FLAT && (height2 < height || (height2 == height && IsWaterTile(end)))) {
+ if (IsTileFlat(end) && (height2 < height || (height2 == height && IsWaterTile(end)))) {
found = true;
break;
}
@@ -1150,7 +1149,7 @@ static bool FlowRiver(bool *marks, TileIndex spring, TileIndex begin)
if (IsValidTile(lakeCenter) &&
/* A river, or lake, can only be built on flat slopes. */
- GetTileSlope(lakeCenter) == SLOPE_FLAT &&
+ IsTileFlat(lakeCenter) &&
/* We want the lake to be built at the height of the river. */
TileHeight(begin) == TileHeight(lakeCenter) &&
/* We don't want the lake at the entry of the valley. */