From a75532dd477a727af2ca4fabd2638711f2884400 Mon Sep 17 00:00:00 2001 From: Susan Date: Tue, 4 Jun 2024 13:11:30 +0100 Subject: [PATCH] Codechange: exit early if past forest threshold --- src/tree_cmd.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index aaf211cef8..eeea0c50b3 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -99,11 +99,14 @@ static bool IsNearbyForest(TileIndex tile) /* Count the trees around the clear tile to determine if it's near a forest */ for (TileIndex t : TileArea(tile).Expand(FOREST_SEARCH_RADIUS)) { if (IsTileType(t, MP_TREES)) { - planted_tile_count++; + if (++planted_tile_count >= FOREST_THRESHOLD) + { + return true; + } } } - return (planted_tile_count >= FOREST_THRESHOLD); + return false; } /**