Link graph: Fix incorrect job start/join dates when loading upstream saves

This commit is contained in:
Jonathan G Rennison
2023-11-25 14:55:38 +00:00
parent acc54fabfe
commit 7d65fbd6e8
2 changed files with 12 additions and 34 deletions

View File

@@ -41,7 +41,16 @@ void GetLinkGraphJobDayLengthScaleAfterLoad(LinkGraphJob *lgj)
{
lgj->join_date_ticks *= DAY_TICKS;
lgj->join_date_ticks += LinkGraphSchedule::SPAWN_JOIN_TICK;
lgj->start_date_ticks = lgj->join_date_ticks - (lgj->Settings().recalc_time * DAY_TICKS);
uint recalc_scale;
if (IsSavegameVersionBefore(SLV_LINKGRAPH_SECONDS) && SlXvIsFeatureMissing(XSLFI_LINKGRAPH_DAY_SCALE, 3)) {
/* recalc time is in days */
recalc_scale = DAY_TICKS;
} else {
/* recalc time is in seconds */
recalc_scale = DAY_TICKS / SECONDS_PER_DAY;
}
lgj->start_date_ticks = lgj->join_date_ticks - (lgj->Settings().recalc_time * recalc_scale);
}
/**