From abcbabe8c4e5f6098dcd467ae141fb7ae6742c36 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 15 Feb 2025 11:32:49 +0000 Subject: [PATCH] Codechange: Early-continue instead of nested ifs. --- src/tree_cmd.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 3ac2c34db8..e5d5e845fd 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -306,11 +306,11 @@ static void PlaceTreeGroups(uint num_groups) int y = GB(r, 8, 5) - GROVE_RADIUS; TileIndex cur_tile = TileAddWrap(center_tile, x, y); - if (cur_tile != INVALID_TILE && CanPlantTreesOnTile(cur_tile, true)) { - if(IsPointInStarShapedPolygon(x, y, grove)) { - PlaceTree(cur_tile, r); - } - } + if (cur_tile == INVALID_TILE) continue; + if (!CanPlantTreesOnTile(cur_tile, true)) continue; + if (!IsPointInStarShapedPolygon(x, y, grove)) continue; + + PlaceTree(cur_tile, r); } } while (--num_groups);