summaryrefslogtreecommitdiff
path: root/src/town_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-02-06 21:06:59 +0000
committerrubidium <rubidium@openttd.org>2014-02-06 21:06:59 +0000
commit9f6b8aea49cbafe9d19611dc31c64a92b171d14b (patch)
treecc2980aec66915ac23080b5c13cbf502efa5f8a0 /src/town_cmd.cpp
parentc7629735a3393730d12fba678839baeec31ee72d (diff)
downloadopenttd-9f6b8aea49cbafe9d19611dc31c64a92b171d14b.tar.xz
(svn r26313) -Codechange: use a set for finding unique town names instead of iterating all just created town names (MJP)
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 09ca7cee9..fd380a827 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1901,6 +1901,7 @@ bool GenerateTowns(TownLayout layout)
uint total = (difficulty == (uint)CUSTOM_TOWN_NUMBER_DIFFICULTY) ? _settings_game.game_creation.custom_town_number : ScaleByMapSize(_num_initial_towns[difficulty] + (Random() & 7));
total = min(TownPool::MAX_SIZE, total);
uint32 townnameparts;
+ TownNames town_names;
SetGeneratingWorldProgress(GWP_TOWN, total);
@@ -1919,11 +1920,13 @@ bool GenerateTowns(TownLayout layout)
bool city = (_settings_game.economy.larger_towns != 0 && Chance16(1, _settings_game.economy.larger_towns));
IncreaseGeneratingWorldProgress(GWP_TOWN);
/* Get a unique name for the town. */
- if (!GenerateTownName(&townnameparts)) continue;
+ if (!GenerateTownName(&townnameparts, &town_names)) continue;
/* try 20 times to create a random-sized town for the first loop. */
if (CreateRandomTown(20, townnameparts, TSZ_RANDOM, city, layout) != NULL) current_number++; // If creation was successful, raise a flag.
} while (--total);
+ town_names.clear();
+
if (current_number != 0) return true;
/* If current_number is still zero at this point, it means that not a single town has been created.