(svn r25435) -Fix: reroute cargo in vehicles if station is deleted

This commit is contained in:
fonsinchen
2013-06-23 08:29:28 +00:00
parent 3dd811e179
commit 930c19dae2
3 changed files with 37 additions and 21 deletions

View File

@@ -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;
}
}