Skip to content

Commit

Permalink
Change: Desert tiles are now half-desert if a neighboured tile is non…
Browse files Browse the repository at this point in the history
…-desert or sea/coast. (patch by frosch123) OpenTTD#4754 (OpenTTD#7015)
  • Loading branch information
andythenorth authored and planetmaker committed Jan 9, 2019
1 parent e934f09 commit ad5a9da
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/clear_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 208,19 @@ static void TileLoopClearAlps(TileIndex tile)
}

/**
* Tests if at least one surrounding tile is desert
* Tests if at least one surrounding tile is non-desert
* @param tile tile to check
* @return does this tile have at least one desert tile around?
* @return does this tile have at least one non-desert tile around?
*/
static inline bool NeighbourIsDesert(TileIndex tile)
static inline bool NeighbourIsNormal(TileIndex tile)
{
return GetTropicZone(tile TileDiffXY( 1, 0)) == TROPICZONE_DESERT ||
GetTropicZone(tile TileDiffXY( -1, 0)) == TROPICZONE_DESERT ||
GetTropicZone(tile TileDiffXY( 0, 1)) == TROPICZONE_DESERT ||
GetTropicZone(tile TileDiffXY( 0, -1)) == TROPICZONE_DESERT;
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir ) {
TileIndex t = tile TileOffsByDiagDir(dir);
if (!IsValidTile(t)) continue;
if (GetTropicZone(t) != TROPICZONE_DESERT) return true;
if (HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_SEA) return true;
}
return false;
}

static void TileLoopClearDesert(TileIndex tile)
Expand All @@ -229,9 232,7 @@ static void TileLoopClearDesert(TileIndex tile)
/* Expected desert level - 0 if it shouldn't be desert */
uint expected = 0;
if (GetTropicZone(tile) == TROPICZONE_DESERT) {
expected = 3;
} else if (NeighbourIsDesert(tile)) {
expected = 1;
expected = NeighbourIsNormal(tile) ? 1 : 3;
}

if (current == expected) return;
Expand Down

0 comments on commit ad5a9da

Please sign in to comment.