src/genworld.cpp
branchnoai
changeset 10172 f93d3b7df6c8
parent 9859 81621c6ba0e9
child 10249 58810805030e
equal deleted inserted replaced
10171:d4397d599d78 10172:f93d3b7df6c8
   192  */
   192  */
   193 void WaitTillGeneratedWorld()
   193 void WaitTillGeneratedWorld()
   194 {
   194 {
   195 	if (_gw.thread == NULL) return;
   195 	if (_gw.thread == NULL) return;
   196 	_gw.quit_thread = true;
   196 	_gw.quit_thread = true;
   197 	OTTDJoinThread((OTTDThread*)_gw.thread);
   197 	_gw.thread->Join();
   198 	_gw.thread   = NULL;
   198 	_gw.thread   = NULL;
   199 	_gw.threaded = false;
   199 	_gw.threaded = false;
   200 }
   200 }
   201 
   201 
   202 /**
   202 /**
   226 	if (_gw.abortp != NULL) _gw.abortp();
   226 	if (_gw.abortp != NULL) _gw.abortp();
   227 
   227 
   228 	if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
   228 	if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
   229 	/* Show all vital windows again, because we have hidden them */
   229 	/* Show all vital windows again, because we have hidden them */
   230 	if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
   230 	if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
       
   231 
       
   232 	ThreadObject *thread = _gw.thread;
   231 	_gw.active   = false;
   233 	_gw.active   = false;
   232 	_gw.thread   = NULL;
   234 	_gw.thread   = NULL;
   233 	_gw.proc     = NULL;
   235 	_gw.proc     = NULL;
   234 	_gw.abortp   = NULL;
   236 	_gw.abortp   = NULL;
   235 	_gw.threaded = false;
   237 	_gw.threaded = false;
   236 
   238 
   237 	DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
   239 	DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
   238 	MarkWholeScreenDirty();
   240 	MarkWholeScreenDirty();
   239 
   241 
   240 	OTTDExitThread();
   242 	thread->Exit();
   241 }
   243 }
   242 
   244 
   243 /**
   245 /**
   244  * Generate a world.
   246  * Generate a world.
   245  * @param mode The mode of world generation (see GenerateWorldModes).
   247  * @param mode The mode of world generation (see GenerateWorldModes).
   280 
   282 
   281 	/* Create toolbars */
   283 	/* Create toolbars */
   282 	SetupColorsAndInitialWindow();
   284 	SetupColorsAndInitialWindow();
   283 
   285 
   284 	if (_network_dedicated ||
   286 	if (_network_dedicated ||
   285 	    (_gw.thread = OTTDCreateThread(&_GenerateWorld, NULL)) == NULL) {
   287 	    (_gw.thread = ThreadObject::New(&_GenerateWorld, NULL)) == NULL) {
   286 		DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
   288 		DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
   287 		_gw.threaded = false;
   289 		_gw.threaded = false;
   288 		_GenerateWorld(NULL);
   290 		_GenerateWorld(NULL);
   289 		return;
   291 		return;
   290 	}
   292 	}