@@ -138,13 +138,16 @@ static void _GenerateWorld(void *arg)
} else {
GenerateLandscape(_gw.mode);
GenerateClearTile();
/* only generate towns, tree and industries in newgame mode. */
if (_game_mode != GM_EDITOR) {
GenerateTowns(_settings_game.economy.town_layout);
if (!GenerateTowns(_settings_game.economy.town_layout)) {
HandleGeneratingWorldAbortion();
return;
}
GenerateIndustries();
GenerateUnmovables();
GenerateTrees();
@@ -252,13 +255,16 @@ void HandleGeneratingWorldAbortion()
_switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU;
if (_gw.abortp != NULL) _gw.abortp();
CleanupGeneration();
_gw.thread->Exit();
if (_gw.thread != NULL) _gw.thread->Exit();
extern void SwitchToMode(SwitchMode new_mode);
SwitchToMode(_switch_mode);
/**
* Generate a world.
* @param mode The mode of world generation (see GenerateWorldModes).
* @param size_x The X-size of the map.
@@ -1194,12 +1194,13 @@ STR_CONVERT_RAIL_TO_WAYPOINT_TIP
STR_CANT_BUILD_TRAIN_WAYPOINT :{WHITE}Can't build train waypoint here...
STR_CANT_REMOVE_TRAIN_WAYPOINT :{WHITE}Can't remove train waypoint here...
STR_BUILD_AUTORAIL_TIP :{BLACK}Build railway track using the Autorail mode
STR_NO_TOWN_IN_SCENARIO :{WHITE}...there is no town in this scenario
STR_COULD_NOT_CREATE_TOWN :{WHITE}Map generation aborted...{}...no suitable town locations
STR_MANY_RANDOM_TOWNS :{BLACK}Many random towns
STR_RANDOM_TOWNS_TIP :{BLACK}Cover the map with randomly placed towns
STR_MANY_RANDOM_INDUSTRIES :Many random industries
STR_RANDOM_INDUSTRIES_TIP :{BLACK}Cover the map with randomly placed industries
STR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Can't generate industries...
@@ -1645,14 +1645,16 @@ bool GenerateTowns(TownLayout layout)
if (num_cities > 0) num_cities--;
} while (--n);
/* give it a last try, but now more aggressive */
if (num == 0 && CreateRandomTown(10000, TS_RANDOM, false, layout) == NULL) {
if (GetNumTowns() == 0) {
/* XXX - can we handle that more gracefully? */
if (_game_mode != GM_EDITOR) usererror("Could not generate any town");
extern StringID _switch_mode_errorstr;
_switch_mode_errorstr = STR_COULD_NOT_CREATE_TOWN;
return false;
return true;
Status change: