diff --git a/src/linkgraph/linkgraphschedule.cpp b/src/linkgraph/linkgraphschedule.cpp index 48f5357..f484b2c 100644 --- a/src/linkgraph/linkgraphschedule.cpp +++ b/src/linkgraph/linkgraphschedule.cpp @@ -178,7 +178,7 @@ void StateGameLoop_LinkGraphPauseControl() DoCommandP(0, PM_PAUSED_LINK_GRAPH, 0, CMD_PAUSE); } } else if (_pause_mode == PM_UNPAUSED && - _date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 1 && + ((_date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 1) || (_date_fract == LinkGraphSchedule::SECONDARY_JOIN_TICK - 1)) && _date % _settings_game.linkgraph.recalc_interval == _settings_game.linkgraph.recalc_interval / 2 && LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) { /* perform check one _date_fract tick before we would join */ @@ -192,11 +192,11 @@ void StateGameLoop_LinkGraphPauseControl() */ void OnTick_LinkGraph() { - if (_date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK) return; Date offset = _date % _settings_game.linkgraph.recalc_interval; - if (offset == 0) { + if (_date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK && offset == 0) { LinkGraphSchedule::instance.SpawnNext(); - } else if (offset == _settings_game.linkgraph.recalc_interval / 2) { + } else if ((_date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK || _date_fract == LinkGraphSchedule::SECONDARY_JOIN_TICK) && + offset == _settings_game.linkgraph.recalc_interval / 2) { LinkGraphSchedule::instance.JoinNext(); } } diff --git a/src/linkgraph/linkgraphschedule.h b/src/linkgraph/linkgraphschedule.h index 3e8742d..48feac5 100644 --- a/src/linkgraph/linkgraphschedule.h +++ b/src/linkgraph/linkgraphschedule.h @@ -49,8 +49,15 @@ protected: JobList running; ///< Currently running jobs. public: - /* This is a tick where not much else is happening, so a small lag might go unnoticed. */ - static const uint SPAWN_JOIN_TICK = 21; ///< Tick when jobs are spawned or joined every day. + /* + * This is a tick where not much else is happening, so a small lag might go unnoticed. + * + * If there is backlog of jobs which are due to be joined, this will be gradually reduced + * as jobs are checked for joining at both SPAWN_JOIN_TICK and SECONDARY_JOIN_TICK, + * but only spawned at SPAWN_JOIN_TICK. + */ + static const uint SPAWN_JOIN_TICK = 21; ///< Tick when jobs are spawned or joined every day. + static const uint SECONDARY_JOIN_TICK = 58; ///< Tick when jobs are joined every day, if not already joined in SPAWN_JOIN_TICK static LinkGraphSchedule instance; static void Run(void *j);