From 89182e4b155820e3c09469a3cfd38c5f5600bd60 Mon Sep 17 00:00:00 2001 From: Su Date: Tue, 4 Jun 2024 14:08:00 +0100 Subject: [PATCH] Codefix: early continue, avoid sideeffects Co-authored-by: Peter Nelson --- src/tree_cmd.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index eeea0c50b3..b3a94011a6 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -98,12 +98,9 @@ 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)) { - if (++planted_tile_count >= FOREST_THRESHOLD) - { - return true; - } - } + if (!IsTileType(t, MP_TREES)) continue; + ++planted_tile_count; + if (planted_tile_count >= FOREST_THRESHOLD) return true; } return false;