From 12188e7a5dde4cdd4304b3e738b7905e55f3ad9a Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 14 Apr 2008 19:54:33 +0000 Subject: (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable. --- src/genworld.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/genworld.cpp') diff --git a/src/genworld.cpp b/src/genworld.cpp index 885e5171e..ca6b89d71 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -84,7 +84,7 @@ bool IsGenerateWorldThreaded() /** * The internal, real, generate function. */ -static void *_GenerateWorld(void *arg) +static void * CDECL _GenerateWorld(void *arg) { _generating_world = true; if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait..."); @@ -194,7 +194,7 @@ void WaitTillGeneratedWorld() { if (_gw.thread == NULL) return; _gw.quit_thread = true; - OTTDJoinThread((OTTDThread*)_gw.thread); + _gw.thread->Join(); _gw.thread = NULL; _gw.threaded = false; } @@ -228,6 +228,8 @@ void HandleGeneratingWorldAbortion() 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(); + + ThreadObject *thread = _gw.thread; _gw.active = false; _gw.thread = NULL; _gw.proc = NULL; @@ -237,7 +239,7 @@ void HandleGeneratingWorldAbortion() DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0); MarkWholeScreenDirty(); - OTTDExitThread(); + thread->Exit(); } /** @@ -282,7 +284,7 @@ void GenerateWorld(int mode, uint size_x, uint size_y) SetupColorsAndInitialWindow(); if (_network_dedicated || - (_gw.thread = OTTDCreateThread(&_GenerateWorld, NULL)) == NULL) { + (_gw.thread = ThreadObject::New(&_GenerateWorld, NULL)) == NULL) { DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode"); _gw.threaded = false; _GenerateWorld(NULL); -- cgit v1.2.3-54-g00ecf