diff options
author | fonsinchen <fonsinchen@openttd.org> | 2013-06-23 08:29:28 +0000 |
---|---|---|
committer | fonsinchen <fonsinchen@openttd.org> | 2013-06-23 08:29:28 +0000 |
commit | 930c19dae292d5863b201ded98444c9fb2e7b20a (patch) | |
tree | 952bc05730d25b4aa32622d07b75aba7f9a28b7b /src/station.cpp | |
parent | 3dd811e1794bc9247d5ace0bad7ade5998a7b54f (diff) | |
download | openttd-930c19dae292d5863b201ded98444c9fb2e7b20a.tar.xz |
(svn r25435) -Fix: reroute cargo in vehicles if station is deleted
Diffstat (limited to 'src/station.cpp')
-rw-r--r-- | src/station.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/station.cpp b/src/station.cpp index 555c6369c..00c6a6d2a 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -92,18 +92,19 @@ Station::~Station() for (CargoID c = 0; c < NUM_CARGO; ++c) { LinkGraph *lg = LinkGraph::GetIfValid(this->goods[c].link_graph); - if (lg != NULL) { - lg->RemoveNode(this->goods[c].node); - if (lg->Size() == 0) { - LinkGraphSchedule::Instance()->Unqueue(lg); - delete lg; + if (lg == NULL) continue; + + for (NodeID node = 0; node < lg->Size(); ++node) { + if ((*lg)[node][this->goods[c].node].LastUpdate() != INVALID_DATE) { + Station *st = Station::Get((*lg)[node].Station()); + st->goods[c].flows.DeleteFlows(this->index); + RerouteCargo(st, c, this->index, st->index); } } - Station *st; - FOR_ALL_STATIONS(st) { - GoodsEntry *ge = &st->goods[c]; - ge->flows.DeleteFlows(this->index); - ge->cargo.Reroute(UINT_MAX, &ge->cargo, this->index, st->index, ge); + lg->RemoveNode(this->goods[c].node); + if (lg->Size() == 0) { + LinkGraphSchedule::Instance()->Unqueue(lg); + delete lg; } } |