Avoid spinning in multiplayer when the game window is hidden

When the host exits the game, guests switch the game window to be
non-visible, and raise a dialog box stating `Host has left the game!`.
Prior to this change, the guests would then busy loop until the dialog
was dismissed.  With this change, the game will sleep for each idle
event, minimizing CPU use during the period waiting for the player to
acknowledge the dialog box.
This commit is contained in:
Kp 2022-09-11 17:00:45 +00:00
parent 45362ac37b
commit ad46235b67

View file

@ -1616,7 +1616,7 @@ window_event_result newmenu::event_handler(const d_event &event)
case EVENT_KEY_COMMAND:
return newmenu_key_command(event, this);
case EVENT_IDLE:
if (!(Game_mode & GM_MULTI && Game_wind))
if (!(Game_mode & GM_MULTI) || !Game_wind || !Game_wind->is_visible())
timer_delay2(CGameArg.SysMaxFPS);
break;
case EVENT_WINDOW_DRAW: