summaryrefslogtreecommitdiff
path: root/src/station.cpp
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2013-06-23 08:29:28 +0000
committerfonsinchen <fonsinchen@openttd.org>2013-06-23 08:29:28 +0000
commit930c19dae292d5863b201ded98444c9fb2e7b20a (patch)
tree952bc05730d25b4aa32622d07b75aba7f9a28b7b /src/station.cpp
parent3dd811e1794bc9247d5ace0bad7ade5998a7b54f (diff)
downloadopenttd-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.cpp21
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;
}
}