From 6a048bc168423b585c6f33e95e6a2822843801ef Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 1 Aug 2023 19:06:41 +0100 Subject: [PATCH] Fix #11164: Duplicate town names when using the many random towns function --- src/town_cmd.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index ca8ac9f8c7..50b38fea37 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2256,6 +2256,11 @@ bool GenerateTowns(TownLayout layout) SetGeneratingWorldProgress(GWP_TOWN, total); + /* Pre-populate the town names list with the names of any towns already on the map */ + for (const Town *town : Town::Iterate()) { + town_names.insert(town->GetCachedName()); + } + /* First attempt will be made at creating the suggested number of towns. * Note that this is really a suggested value, not a required one. * We would not like the system to lock up just because the user wanted 100 cities on a 64*64 map, would we? */