diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2019-01-22 18:31:08 +0000 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2020-12-22 15:17:57 +0100 |
commit | 0c5dc5d41eff0ac0a62dd67882a718bb3c99ec3a (patch) | |
tree | ae5c1cb8322cd28fa627f942fb93d59f5029cfe3 /src/network | |
parent | 9a45a0f535e312cd97db12c3a2ec1068fa381136 (diff) | |
download | openttd-0c5dc5d41eff0ac0a62dd67882a718bb3c99ec3a.tar.xz |
Change: [Linkgraph] Pause the game when linkgraph jobs lag (#6470)
Check if the job is still running two date fract ticks before it is due
to join, and if so pause the game until its done.
When loading a game, check if the game would block immediately due to
a job which is scheduled to be joined within two date fract ticks,
and if so pause the game until its done.
This avoids the main thread being blocked on a thread join, which appears
to the user as if the game is unresponsive, as the UI does not repaint
and cannot be interacted with.
Show if pause is due to link graph job in status bar, update network
messages.
This does not apply for network clients.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/network.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index a100b6b95..da341f253 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -342,7 +342,8 @@ void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode) case PM_PAUSED_NORMAL: case PM_PAUSED_JOIN: case PM_PAUSED_GAME_SCRIPT: - case PM_PAUSED_ACTIVE_CLIENTS: { + case PM_PAUSED_ACTIVE_CLIENTS: + case PM_PAUSED_LINK_GRAPH: { bool changed = ((_pause_mode == PM_UNPAUSED) != (prev_mode == PM_UNPAUSED)); bool paused = (_pause_mode != PM_UNPAUSED); if (!paused && !changed) return; @@ -355,6 +356,7 @@ void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode) if ((_pause_mode & PM_PAUSED_JOIN) != PM_UNPAUSED) SetDParam(++i, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_CONNECTING_CLIENTS); if ((_pause_mode & PM_PAUSED_GAME_SCRIPT) != PM_UNPAUSED) SetDParam(++i, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_GAME_SCRIPT); if ((_pause_mode & PM_PAUSED_ACTIVE_CLIENTS) != PM_UNPAUSED) SetDParam(++i, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_NOT_ENOUGH_PLAYERS); + if ((_pause_mode & PM_PAUSED_LINK_GRAPH) != PM_UNPAUSED) SetDParam(++i, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_LINK_GRAPH); str = STR_NETWORK_SERVER_MESSAGE_GAME_STILL_PAUSED_1 + i; } else { switch (changed_mode) { @@ -362,6 +364,7 @@ void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode) case PM_PAUSED_JOIN: SetDParam(0, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_CONNECTING_CLIENTS); break; case PM_PAUSED_GAME_SCRIPT: SetDParam(0, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_GAME_SCRIPT); break; case PM_PAUSED_ACTIVE_CLIENTS: SetDParam(0, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_NOT_ENOUGH_PLAYERS); break; + case PM_PAUSED_LINK_GRAPH: SetDParam(0, STR_NETWORK_SERVER_MESSAGE_GAME_REASON_LINK_GRAPH); break; default: NOT_REACHED(); } str = paused ? STR_NETWORK_SERVER_MESSAGE_GAME_PAUSED : STR_NETWORK_SERVER_MESSAGE_GAME_UNPAUSED; |