diff options
author | fonsinchen <fonsinchen@openttd.org> | 2013-06-17 20:38:11 +0000 |
---|---|---|
committer | fonsinchen <fonsinchen@openttd.org> | 2013-06-17 20:38:11 +0000 |
commit | f0119308f602c9435c793b95b0fa9af3be3a5296 (patch) | |
tree | 63bb3de599615feed1d36dc6c525e32b76476f08 /src/linkgraph | |
parent | b923eb31a8ca78cfc4f7e5be00b5f158edbb7588 (diff) | |
download | openttd-f0119308f602c9435c793b95b0fa9af3be3a5296.tar.xz |
(svn r25424) -Fix: keep old flows around in an invalidated state to continue routing cargo if necessary
Diffstat (limited to 'src/linkgraph')
-rw-r--r-- | src/linkgraph/linkgraphjob.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/linkgraph/linkgraphjob.cpp b/src/linkgraph/linkgraphjob.cpp index 2feaa8b92..4f583e04a 100644 --- a/src/linkgraph/linkgraphjob.cpp +++ b/src/linkgraph/linkgraphjob.cpp @@ -72,7 +72,19 @@ LinkGraphJob::~LinkGraphJob() } } - ge.flows.swap(flows); + /* Swap shares and invalidate ones that are completely deleted. Don't + * really delete them as we could then end up with unroutable cargo + * somewhere. */ + for (FlowStatMap::iterator it(ge.flows.begin()); it != ge.flows.end(); ++it) { + FlowStatMap::iterator new_it = flows.find(it->first); + if (new_it == flows.end()) { + it->second.Invalidate(); + } else { + it->second.SwapShares(new_it->second); + flows.erase(new_it); + } + } + ge.flows.insert(flows.begin(), flows.end()); InvalidateWindowData(WC_STATION_VIEW, st->index, this->Cargo()); } } |