Changeset - r17999:efe4e10ba6ab
[Not reviewed]
master
0 6 0
rubidium - 13 years ago 2011-08-24 12:11:10
rubidium@openttd.org
(svn r22818) -Fix [FS#4742] (r22796, rlongago): don't spawn threads for world generation and NewGRF scanning when using the dedicated or null video driver regardless of the used blitter
6 files changed with 20 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/genworld.cpp
Show inline comments
 
@@ -24,7 +24,7 @@
 
#include "engine_func.h"
 
#include "newgrf_storage.h"
 
#include "water.h"
 
#include "blitter/factory.hpp"
 
#include "video/video_driver.hpp"
 
#include "tilehighlight_func.h"
 
#include "saveload/saveload.h"
 
#include "void_map.h"
 
@@ -310,8 +310,7 @@ void GenerateWorld(GenWorldMode mode, ui
 
		_gw.thread = NULL;
 
	}
 

	
 
	if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0 ||
 
			!ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread)) {
 
	if (!_video_driver->HasGUI() || !ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread)) {
 
		DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
 
		_gw.threaded = false;
 
		_modal_progress_work_mutex->EndCritical();
src/newgrf_config.cpp
Show inline comments
 
@@ -19,8 +19,7 @@
 
#include "window_func.h"
 
#include "progress.h"
 
#include "thread/thread.h"
 
#include "blitter/factory.hpp"
 
#include "network/network.h"
 
#include "video/video_driver.hpp"
 

	
 
#include "fileio_func.h"
 
#include "fios.h"
 
@@ -696,7 +695,7 @@ void DoScanNewGRFFiles(void *callback)
 
 */
 
void ScanNewGRFFiles(NewGRFScanCallback *callback)
 
{
 
	if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0 || _network_dedicated || !ThreadObject::New(&DoScanNewGRFFiles, callback, NULL)) {
 
	if (!_video_driver->HasGUI() || !ThreadObject::New(&DoScanNewGRFFiles, callback, NULL)) {
 
		_modal_progress_work_mutex->EndCritical();
 
		_modal_progress_paint_mutex->EndCritical();
 
		DoScanNewGRFFiles(callback);
src/openttd.cpp
Show inline comments
 
@@ -766,7 +766,7 @@ static void MakeNewGameDone()
 
	SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
 

	
 
	/* In a dedicated server, the server does not play */
 
	if (_network_dedicated || BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0) {
 
	if (!_video_driver->HasGUI()) {
 
		SetLocalCompany(COMPANY_SPECTATOR);
 
		IConsoleCmdExec("exec scripts/game_start.scr 0");
 
		return;
src/video/dedicated_v.h
Show inline comments
 
@@ -29,6 +29,7 @@ public:
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	/* virtual */ const char *GetName() const { return "dedicated"; }
 
	/* virtual */ bool HasGUI() const { return false; }
 
};
 

	
 
/** Factory for the dedicated server video driver. */
src/video/null_v.h
Show inline comments
 
@@ -32,6 +32,7 @@ public:
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	/* virtual */ const char *GetName() const { return "null"; }
 
	/* virtual */ bool HasGUI() const { return false; }
 
};
 

	
 
/** Factory the null video driver. */
src/video/video_driver.hpp
Show inline comments
 
@@ -46,6 +46,19 @@ public:
 
	 * @return True if the change succeeded.
 
	 */
 
	virtual bool ToggleFullscreen(bool fullscreen) = 0;
 

	
 
	/**
 
	 * Whether the driver has a graphical user interface with the end user.
 
	 * Or in other words, whether we should spawn a thread for world generation
 
	 * and NewGRF scanning so the graphical updates can keep coming. Otherwise
 
	 * progress has to be shown on the console, which uses by definition another
 
	 * thread/process for display purposes.
 
	 * @return True for all drivers except null and dedicated.
 
	 */
 
	virtual bool HasGUI() const
 
	{
 
		return true;
 
	}
 
};
 

	
 
/** Base of the factory for the video drivers. */
0 comments (0 inline, 0 general)