(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

pull/155/head
rubidium 13 years ago
parent 61f4090aac
commit 9aa6000b15

@ -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();

@ -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);

@ -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;

@ -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. */

@ -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. */

@ -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. */

Loading…
Cancel
Save