Fix crash which could occur when removing invalidated link graph flow.
This commit is contained in:
@@ -153,12 +153,13 @@ void LinkGraphJob::FinaliseJob()
|
|||||||
if (new_it == flows.end()) {
|
if (new_it == flows.end()) {
|
||||||
if (_settings_game.linkgraph.GetDistributionType(this->Cargo()) != DT_MANUAL) {
|
if (_settings_game.linkgraph.GetDistributionType(this->Cargo()) != DT_MANUAL) {
|
||||||
if (it->Invalidate()) {
|
if (it->Invalidate()) {
|
||||||
|
NodeID origin = it->GetOrigin();
|
||||||
FlowStat shares(INVALID_STATION, INVALID_STATION, 1);
|
FlowStat shares(INVALID_STATION, INVALID_STATION, 1);
|
||||||
it->SwapShares(shares);
|
it->SwapShares(shares);
|
||||||
it = ge.flows.erase(it);
|
it = ge.flows.erase(it);
|
||||||
for (FlowStat::const_iterator shares_it(shares.begin());
|
for (FlowStat::const_iterator shares_it(shares.begin());
|
||||||
shares_it != shares.end(); ++shares_it) {
|
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 {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
|
Reference in New Issue
Block a user