* Pause the game if in 2 TimerGameEconomy::date_fract ticks, we would do a join with the next * link graph job, but it is still running. * The check is done 2 TimerGameEconomy::date_fract ticks early instead of 1, as in multiplayer * calls to DoCommandP are executed after a delay of 1 TimerGameEconomy::date_fract tick. * If we previously paused, unpause if the job is now ready to be joined wit
| 167 | * If we previously paused, unpause if the job is now ready to be joined with. |
| 168 | */ |
| 169 | void StateGameLoop_LinkGraphPauseControl() |
| 170 | { |
| 171 | if (_pause_mode.Test(PauseMode::LinkGraph)) { |
| 172 | /* We are paused waiting on a job, check the job every tick. */ |
| 173 | if (!LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) { |
| 174 | Command<CMD_PAUSE>::Post(PauseMode::LinkGraph, false); |
| 175 | } |
| 176 | } else if (_pause_mode.None() && |
| 177 | TimerGameEconomy::date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 && |
| 178 | TimerGameEconomy::date.base() % (_settings_game.linkgraph.recalc_interval / EconomyTime::SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / EconomyTime::SECONDS_PER_DAY) / 2 && |
| 179 | LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) { |
| 180 | /* Perform check two TimerGameEconomy::date_fract ticks before we would join, to make |
| 181 | * sure it also works in multiplayer. */ |
| 182 | Command<CMD_PAUSE>::Post(PauseMode::LinkGraph, true); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Pause the game on load if we would do a join with the next link graph job, |
no test coverage detected