From 4acccc232a3a80e144277927d7e1e7847e24bd4d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 18 Jun 2022 11:08:13 +0100 Subject: [PATCH] Fix #9925: Industry tile layout validation for layouts of only one tile --- src/newgrf.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 0917cff1a0..90ef10384f 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3377,20 +3377,24 @@ static bool ValidateIndustryLayout(const IndustryTileLayout &layout) const size_t size = layout.size(); if (size == 0) return false; - size_t valid_regular_tiles = 0; - for (size_t i = 0; i < size - 1; i++) { for (size_t j = i + 1; j < size; j++) { if (layout[i].ti.x == layout[j].ti.x && layout[i].ti.y == layout[j].ti.y) { return false; } - if (layout[i].gfx != GFX_WATERTILE_SPECIALCHECK) { - ++valid_regular_tiles; - } } } - return valid_regular_tiles > 0; + + bool have_regular_tile = false; + for (size_t i = 0; i < size; i++) { + if (layout[i].gfx != GFX_WATERTILE_SPECIALCHECK) { + have_regular_tile = true; + break; + } + } + + return have_regular_tile; } /** -- 2.11.4.GIT