From abdea49d24189b4dd3568ac691a217b9c50763cd Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Tue, 4 Feb 2025 01:13:58 +0100 Subject: [PATCH 1/2] Codechange: Null video driver: End on game exit The Null driver now exits when the game ends. It also gains the ability to run for an unlimited number of ticks (using '-v null:ticks=0'). --- src/video/null_v.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/null_v.cpp b/src/video/null_v.cpp index e3a032d71f..787bb64feb 100644 --- a/src/video/null_v.cpp +++ b/src/video/null_v.cpp @@ -50,7 +50,7 @@ void VideoDriver_Null::MainLoop() { uint i; - for (i = 0; i < this->ticks; i++) { + for (i = 0; i < this->ticks && ! _exit_game; i++) { ::GameLoop(); ::InputLoop(); ::UpdateWindows(); From bac9bf93bcb2bf9d0007a64963d354b5983efb45 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Wed, 5 Feb 2025 06:40:50 +0100 Subject: [PATCH 2/2] Codefix: Null video driver: take the game lock The game loop must run with the game lock held. --- src/video/null_v.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/video/null_v.cpp b/src/video/null_v.cpp index 787bb64feb..0ca0057762 100644 --- a/src/video/null_v.cpp +++ b/src/video/null_v.cpp @@ -51,7 +51,10 @@ void VideoDriver_Null::MainLoop() uint i; for (i = 0; i < this->ticks && ! _exit_game; i++) { - ::GameLoop(); + { + std::lock_guard lock(this->game_state_mutex); + ::GameLoop(); + } ::InputLoop(); ::UpdateWindows(); }