Fix crash which could occur when removing invalidated link graph flow.

This commit is contained in:
Jonathan G Rennison
2022-01-07 17:38:26 +00:00
parent 0ffa1b1db6
commit f54e19083e

View File

@@ -153,12 +153,13 @@ void LinkGraphJob::FinaliseJob()
if (new_it == flows.end()) {
if (_settings_game.linkgraph.GetDistributionType(this->Cargo()) != DT_MANUAL) {
if (it->Invalidate()) {
NodeID origin = it->GetOrigin();
FlowStat shares(INVALID_STATION, INVALID_STATION, 1);
it->SwapShares(shares);
it = ge.flows.erase(it);
for (FlowStat::const_iterator shares_it(shares.begin());
shares_it != shares.end(); ++shares_it) {
RerouteCargoFromSource(st, this->Cargo(), it->GetOrigin(), shares_it->second, st->index);
RerouteCargoFromSource(st, this->Cargo(), origin, shares_it->second, st->index);
}
} else {
++it;