diff options
author | Darkvater <darkvater@openttd.org> | 2005-09-16 00:33:33 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-09-16 00:33:33 +0000 |
commit | 180997534c08d1ffa0d153ee50c3a369b66d0cd6 (patch) | |
tree | a457fd89edc14bd8597031996ddfaca339bfc74f /main_gui.c | |
parent | 141924455193275572e8b43fd6702ff05120656e (diff) | |
download | openttd-180997534c08d1ffa0d153ee50c3a369b66d0cd6.tar.xz |
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Diffstat (limited to 'main_gui.c')
-rw-r--r-- | main_gui.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/main_gui.c b/main_gui.c index 88bceae17..d599bc4b1 100644 --- a/main_gui.c +++ b/main_gui.c @@ -42,7 +42,7 @@ static byte _last_built_railtype; extern void GenerateWorld(int mode, uint size_x, uint size_y); extern void GenerateIndustries(void); -extern void GenerateTowns(void); +extern bool GenerateTowns(void); void HandleOnEditTextCancel(void) { @@ -1505,16 +1505,23 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) _generating_world = true; t = CreateRandomTown(20); _generating_world = false; - if (t != NULL) + + if (t == NULL) { + ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0); + } else ScrollMainWindowToTile(t->xy); + break; } case 6: {/* many random towns */ HandleButtonClick(w, 6); + _generating_world = true; _game_mode = GM_NORMAL; // little hack to avoid towns of the same size - GenerateTowns(); + if (!GenerateTowns()) + ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0); _generating_world = false; + _game_mode = GM_EDITOR; break; } |