summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-12 14:28:55 +0000
committerrubidium <rubidium@openttd.org>2009-03-12 14:28:55 +0000
commitd063bfe6c92d4e67ae267db2ffa8d4fd04971841 (patch)
tree5c8ccde7502fe0c730c61ed29a1e1728d6ae1b6d /src
parentab9788b290f17b9c203853d86632601d4e60698e (diff)
downloadopenttd-d063bfe6c92d4e67ae267db2ffa8d4fd04971841.tar.xz
(svn r15688) -Codechange: unifiy cleaning up the map generation (normal and abort)
Diffstat (limited to 'src')
-rw-r--r--src/genworld.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 1d6880208..f8a865397 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -83,6 +83,26 @@ bool IsGenerateWorldThreaded()
}
/**
+ * Clean up the 'mess' of generation. That is show windows again, reset
+ * thread variables and delete the progress window.
+ */
+static void CleanupGeneration()
+{
+ _generating_world = false;
+
+ if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
+ /* Show all vital windows again, because we have hidden them */
+ if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
+ _gw.active = false;
+ _gw.proc = NULL;
+ _gw.abortp = NULL;
+ _gw.threaded = false;
+
+ DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
+ MarkWholeScreenDirty();
+}
+
+/**
* The internal, real, generate function.
*/
static void _GenerateWorld(void *arg)
@@ -158,15 +178,7 @@ static void _GenerateWorld(void *arg)
if (_gw.proc != NULL) _gw.proc();
IncreaseGeneratingWorldProgress(GWP_GAME_START);
- if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
- /* Show all vital windows again, because we have hidden them */
- if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
- _gw.active = false;
- _gw.proc = NULL;
- _gw.threaded = false;
-
- DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
- MarkWholeScreenDirty();
+ CleanupGeneration();
if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game");
DEBUG(desync, 1, "new_map: %i\n", _settings_game.game_creation.generation_seed);
@@ -241,17 +253,7 @@ void HandleGeneratingWorldAbortion()
if (_gw.abortp != NULL) _gw.abortp();
- if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
- /* Show all vital windows again, because we have hidden them */
- if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
-
- _gw.active = false;
- _gw.proc = NULL;
- _gw.abortp = NULL;
- _gw.threaded = false;
-
- DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
- MarkWholeScreenDirty();
+ CleanupGeneration();
_gw.thread->Exit();
}