From d86dbabbc44a637f31c065771400d1ed4a3c6f5c Mon Sep 17 00:00:00 2001 From: alberth Date: Wed, 30 Dec 2009 19:30:49 +0000 Subject: (svn r18670) -Fix [FS#3455]: Update all tiles when snowline height changes in larger steps than one tile. --- src/clear_cmd.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 32f4a7f75..43f820d6b 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -156,30 +156,34 @@ void TileLoopClearHelper(TileIndex tile) } -/* convert into snowy tiles */ +/** Convert to or from snowy tiles. */ static void TileLoopClearAlps(TileIndex tile) { int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT; - if (k < 0) { // well below the snow line + if (k < 0) { + /* Below the snow line, do nothing if no snow. */ if (!IsClearGround(tile, CLEAR_SNOW)) return; - if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3); } else { + /* At or above the snow line, make snow tile if needed. */ if (!IsClearGround(tile, CLEAR_SNOW)) { SetClearGroundDensity(tile, CLEAR_SNOW, 0); - } else { - uint density = min((uint)k / TILE_HEIGHT, 3); - - if (GetClearDensity(tile) < density) { - AddClearDensity(tile, 1); - } else if (GetClearDensity(tile) > density) { - AddClearDensity(tile, -1); - } else { - return; - } + MarkTileDirtyByTile(tile); + return; } } - + /* Update snow density. */ + uint curent_density = GetClearDensity(tile); + uint req_density = (k < 0) ? 0u : min((uint)k / TILE_HEIGHT, 3); + + if (curent_density < req_density) { + AddClearDensity(tile, 1); + } else if (curent_density > req_density) { + AddClearDensity(tile, -1); + } else { + /* Density at the required level. */ + if (k < 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3); + } MarkTileDirtyByTile(tile); } -- cgit v1.2.3-70-g09d2