diff options
author | fonsinchen <fonsinchen@openttd.org> | 2014-02-16 11:17:17 +0000 |
---|---|---|
committer | fonsinchen <fonsinchen@openttd.org> | 2014-02-16 11:17:17 +0000 |
commit | 2945e762691740993e0b62c54aa0f978ce15dbe9 (patch) | |
tree | e8923e94aa9fc9e0b00f46c01e0548d56c2a3bf3 /src | |
parent | 997b2634c53e2a9e3dbfbcc4be758a5ab39c85fd (diff) | |
download | openttd-2945e762691740993e0b62c54aa0f978ce15dbe9.tar.xz |
(svn r26341) -Fix [FS#5902]: Reroute cargo when automatic distribution is switched off.
Diffstat (limited to 'src')
-rw-r--r-- | src/linkgraph/linkgraphjob.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/linkgraph/linkgraphjob.cpp b/src/linkgraph/linkgraphjob.cpp index 318186d3f..cd00d5fa7 100644 --- a/src/linkgraph/linkgraphjob.cpp +++ b/src/linkgraph/linkgraphjob.cpp @@ -102,8 +102,8 @@ LinkGraphJob::~LinkGraphJob() /* Swap shares and invalidate ones that are completely deleted. Don't * really delete them as we could then end up with unroutable cargo - * somewhere. Do delete them if automatic distribution has been turned - * off for that cargo, though. */ + * somewhere. Do delete them and also reroute relevant cargo if + * automatic distribution has been turned off for that cargo. */ for (FlowStatMap::iterator it(ge.flows.begin()); it != ge.flows.end();) { FlowStatMap::iterator new_it = flows.find(it->first); if (new_it == flows.end()) { @@ -111,7 +111,13 @@ LinkGraphJob::~LinkGraphJob() it->second.Invalidate(); ++it; } else { + FlowStat shares(INVALID_STATION, 1); + it->second.SwapShares(shares); ge.flows.erase(it++); + for (FlowStat::SharesMap::const_iterator shares_it(shares.GetShares()->begin()); + shares_it != shares.GetShares()->end(); ++shares_it) { + RerouteCargo(st, this->Cargo(), shares_it->second, st->index); + } } } else { it->second.SwapShares(new_it->second); |