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

@@ -201,39 +201,6 @@ SaveLoadTable GetLinkGraphScheduleDesc()
return schedule_desc;
}
/**
* Spawn the threads for running link graph calculations.
* Has to be done after loading as the cargo classes might have changed.
*/
void AfterLoadLinkGraphs()
{
if (IsSavegameVersionBefore(SLV_191)) {
for (LinkGraph *lg : LinkGraph::Iterate()) {
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
const Station *st = Station::GetIfValid((*lg)[node_id].Station());
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
}
}
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
LinkGraph *lg = &(const_cast<LinkGraph &>(lgj->Graph()));
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
const Station *st = Station::GetIfValid((*lg)[node_id].Station());
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
}
}
}
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
GetLinkGraphJobDayLengthScaleAfterLoad(lgj);
}
LinkGraphSchedule::instance.SpawnAll();
if (!_networking || _network_server) {
AfterLoad_LinkGraphPauseControl();
}
}
/**
* All link graphs.
*/
@@ -286,6 +253,8 @@ struct LGRJChunkHandler : ChunkHandler {
while ((index = SlIterateArray()) != -1) {
LinkGraphJob *lgj = new (index) LinkGraphJob();
SlObject(lgj, slt);
GetLinkGraphJobDayLengthScaleAfterLoad(lgj);
}
}
};