diff --git a/src/genworld.cpp b/src/genworld.cpp --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -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(); diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -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); diff --git a/src/openttd.cpp b/src/openttd.cpp --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -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; diff --git a/src/video/dedicated_v.h b/src/video/dedicated_v.h --- a/src/video/dedicated_v.h +++ b/src/video/dedicated_v.h @@ -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. */ diff --git a/src/video/null_v.h b/src/video/null_v.h --- a/src/video/null_v.h +++ b/src/video/null_v.h @@ -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. */ diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -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. */