Changeset - r24837:5dde15d396bd
[Not reviewed]
master
0 5 0
Patric Stout - 3 years ago 2021-02-18 12:33:27
truebrain@openttd.org
Fix: during switching of game-mode, drawing could show closed windows that shouldn't be closed yet

The higher your refresh-rate, the more likely this is. Mostly you
notice this when creating a new game or when abandoning a game.

This is a bit of a hack to keep the old behaviour, as before this
patch the game was already freezing your mouse while it was changing
game-mode, and it does this too after this patch. Just now it
freezes too a few frames earlier, to prevent not drawing windows
people still expect to see.
5 files changed with 11 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/video/allegro_v.cpp
Show inline comments
 
@@ -495,7 +495,8 @@ void VideoDriver_Allegro::MainLoop()
 
			GameLoop();
 
		}
 

	
 
		if (cur_ticks >= next_draw_tick) {
 
		/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
 
		if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
 
			next_draw_tick += this->GetDrawInterval();
 
			/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
 
			if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -36,6 +36,7 @@
 
#include "../../gfx_func.h"
 
#include "../../thread.h"
 
#include "../../core/random_func.hpp"
 
#include "../../progress.h"
 
#include "../../settings_type.h"
 
#include "../../window_func.h"
 
#include "../../window_gui.h"
 
@@ -685,7 +686,8 @@ void VideoDriver_Cocoa::GameLoop()
 
				::GameLoop();
 
			}
 

	
 
			if (cur_ticks >= next_draw_tick) {
 
			/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
 
			if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
 
				next_draw_tick += this->GetDrawInterval();
 
				/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
 
				if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
src/video/sdl2_v.cpp
Show inline comments
 
@@ -792,7 +792,8 @@ void VideoDriver_SDL::LoopOnce()
 
		if (_draw_mutex != nullptr) draw_lock.lock();
 
	}
 

	
 
	if (cur_ticks >= next_draw_tick) {
 
	/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
 
	if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
 
		next_draw_tick += this->GetDrawInterval();
 
		/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
 
		if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
src/video/sdl_v.cpp
Show inline comments
 
@@ -745,7 +745,8 @@ void VideoDriver_SDL::MainLoop()
 
			if (_draw_mutex != nullptr) draw_lock.lock();
 
		}
 

	
 
		if (cur_ticks >= next_draw_tick) {
 
		/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
 
		if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
 
			next_draw_tick += this->GetDrawInterval();
 
			/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
 
			if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
src/video/win32_v.cpp
Show inline comments
 
@@ -1225,7 +1225,8 @@ void VideoDriver_Win32::MainLoop()
 
			if (_draw_threaded) draw_lock.lock();
 
		}
 

	
 
		if (cur_ticks >= next_draw_tick) {
 
		/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
 
		if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
 
			next_draw_tick += this->GetDrawInterval();
 
			/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
 
			if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
0 comments (0 inline, 0 general)