From 7207c9330c0869ed8e7ff9c7c482df9919ddbd1b Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 30 May 2022 23:53:04 +0100 Subject: [PATCH] Tile loop: Add snow line check fast path for tiles well above snow line --- src/clear_cmd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index e274a97005..77fcfecf1f 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -204,9 +204,13 @@ static void UpdateFences(TileIndex tile) static void TileLoopClearAlps(TileIndex tile) { int k; - if ((int)TileHeight(tile) < GetSnowLine() - 1) { + int h = (int)TileHeight(tile); + if (h < GetSnowLine() - 1) { /* Fast path to avoid needing to check all 4 corners */ k = -1; + } else if (h >= GetSnowLine() + 4) { + /* Fast path to avoid needing to check all 4 corners */ + k = 3; } else { k = GetTileZ(tile) - GetSnowLine() + 1; }