summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/genworld.cpp5
-rw-r--r--src/newgrf_config.cpp5
-rw-r--r--src/openttd.cpp2
-rw-r--r--src/video/dedicated_v.h1
-rw-r--r--src/video/null_v.h1
-rw-r--r--src/video/video_driver.hpp13
6 files changed, 20 insertions, 7 deletions
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 151abc2b9..02d9cab05 100644
--- 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, uint size_x, uint size_y, bool reset_setti
_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
index c8385aca4..693339182 100644
--- 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
index c7fc053f2..9d363f231 100644
--- 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
index c06f050cd..7d449d159 100644
--- 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
index fa0ff054f..9bc26c4ef 100644
--- 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
index 1e647cb1c..76f624cdb 100644
--- 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. */