diff options
Diffstat (limited to 'src/video')
-rw-r--r-- | src/video/dedicated_v.cpp | 14 | ||||
-rw-r--r-- | src/video/video_driver.cpp | 19 | ||||
-rw-r--r-- | src/video/video_driver.hpp | 2 |
3 files changed, 24 insertions, 11 deletions
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index ea1c14cff..e905a9d2c 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -251,19 +251,16 @@ void VideoDriver_Dedicated::MainLoop() /* If SwitchMode is SM_LOAD_GAME, it means that the user used the '-g' options */ if (_switch_mode != SM_LOAD_GAME) { StartNewGameWithoutGUI(GENERATE_NEW_SEED); - SwitchToMode(_switch_mode); - _switch_mode = SM_NONE; } else { - _switch_mode = SM_NONE; /* First we need to test if the savegame can be loaded, else we will end up playing the * intro game... */ - if (!SafeLoad(_file_to_saveload.name, _file_to_saveload.file_op, _file_to_saveload.detail_ftype, GM_NORMAL, BASE_DIR)) { + if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.file_op, _file_to_saveload.detail_ftype, BASE_DIR) == SL_ERROR) { /* Loading failed, pop out.. */ DEBUG(net, 0, "Loading requested map failed, aborting"); - _networking = false; + return; } else { /* We can load this game, so go ahead */ - SwitchToMode(SM_LOAD_GAME); + _switch_mode = SM_LOAD_GAME; } } @@ -271,11 +268,6 @@ void VideoDriver_Dedicated::MainLoop() /* Done loading, start game! */ - if (!_networking) { - DEBUG(net, 0, "Dedicated server could not be started, aborting"); - return; - } - while (!_exit_game) { if (!_dedicated_forks) DedicatedHandleKeyInput(); diff --git a/src/video/video_driver.cpp b/src/video/video_driver.cpp index 1b7fc6a4b..bee67e1ea 100644 --- a/src/video/video_driver.cpp +++ b/src/video/video_driver.cpp @@ -56,6 +56,25 @@ void VideoDriver::GameThread() } } +/** + * Pause the game-loop for a bit, releasing the game-state lock. This allows, + * if the draw-tick requested this, the drawing to happen. + */ +void VideoDriver::GameLoopPause() +{ + /* If we are not called from the game-thread, ignore this request. */ + if (std::this_thread::get_id() != this->game_thread.get_id()) return; + + this->game_state_mutex.unlock(); + + { + /* See GameThread() for more details on this lock. */ + std::lock_guard<std::mutex> lock(this->game_thread_wait_mutex); + } + + this->game_state_mutex.lock(); +} + /* static */ void VideoDriver::GameThreadThunk(VideoDriver *drv) { drv->GameThread(); diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index 8c2b9d437..7a859565a 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -179,6 +179,8 @@ public: this->change_blitter = new_blitter; } + void GameLoopPause(); + /** * Get the currently active instance of the video driver. */ |