summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-03-16 18:38:28 +0000
committersmatz <smatz@openttd.org>2009-03-16 18:38:28 +0000
commitf62e71ba8e3883d0065252d7a293ed293b92c4f5 (patch)
treea08ddf441df1275be2c37eceac5062de6ca48824
parent384599ef2c7c6811a423fa86bfd83baf5677a8f1 (diff)
downloadopenttd-f62e71ba8e3883d0065252d7a293ed293b92c4f5.tar.xz
(svn r15744) -Fix (r9667): when town generator failed to create requested number of towns, there were too many cities
-rw-r--r--src/town_cmd.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index d84f40597..3ae9dc8ba 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1636,19 +1636,18 @@ bool GenerateTowns(TownLayout layout)
uint num = 0;
uint difficulty = _settings_game.difficulty.number_towns;
uint n = (difficulty == (uint)CUSTOM_TOWN_NUMBER_DIFFICULTY) ? _settings_game.game_creation.custom_town_number : ScaleByMapSize(_num_initial_towns[difficulty] + (Random() & 7));
- uint num_cities = _settings_game.economy.larger_towns == 0 ? 0 : n / _settings_game.economy.larger_towns;
SetGeneratingWorldProgress(GWP_TOWN, n);
do {
+ bool city = (_settings_game.economy.larger_towns != 0 && Chance16(1, _settings_game.economy.larger_towns));
IncreaseGeneratingWorldProgress(GWP_TOWN);
/* try 20 times to create a random-sized town for the first loop. */
- if (CreateRandomTown(20, TS_RANDOM, num_cities > 0, layout) != NULL) num++;
- if (num_cities > 0) num_cities--;
+ if (CreateRandomTown(20, TS_RANDOM, city, layout) != NULL) num++;
} while (--n);
/* give it a last try, but now more aggressive */
- if (num == 0 && CreateRandomTown(10000, TS_RANDOM, false, layout) == NULL) {
+ if (num == 0 && CreateRandomTown(10000, TS_RANDOM, _settings_game.economy.larger_towns != 0, layout) == NULL) {
if (GetNumTowns() == 0) {
if (_game_mode != GM_EDITOR) {
extern StringID _switch_mode_errorstr;