summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2013-10-22 16:13:28 +0000
committerfonsinchen <fonsinchen@openttd.org>2013-10-22 16:13:28 +0000
commit29e987f3fc13dc1e2a90f07556bf033b81a13e36 (patch)
treec8f1abf4c61c5c7994792b231ead35f2910559e8 /src/station_cmd.cpp
parentec2d36a4a40646e260f4fbcdcd984e278ce8387a (diff)
downloadopenttd-29e987f3fc13dc1e2a90f07556bf033b81a13e36.tar.xz
(svn r25898) -Codechange: Add second timestamp for 'restricted links' to all edges.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index acc036636..f8bf61968 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -3417,13 +3417,18 @@ void DeleteStaleLinks(Station *from)
Edge edge = it->second;
Station *to = Station::Get((*lg)[it->first].Station());
assert(to->goods[c].node == it->first);
- ++it; // Do that before removing the node. Anything else may crash.
+ ++it; // Do that before removing the edge. Anything else may crash.
assert(_date >= edge.LastUpdate());
- if ((uint)(_date - edge.LastUpdate()) > LinkGraph::MIN_TIMEOUT_DISTANCE +
- (DistanceManhattan(from->xy, to->xy) >> 2)) {
+ uint timeout = LinkGraph::MIN_TIMEOUT_DISTANCE + (DistanceManhattan(from->xy, to->xy) >> 2);
+ if ((uint)(_date - edge.LastUpdate()) > timeout) {
node.RemoveEdge(to->goods[c].node);
ge.flows.DeleteFlows(to->index);
RerouteCargo(from, c, to->index, from->index);
+ } else if (edge.LastUnrestrictedUpdate() != INVALID_DATE && (uint)(_date - edge.LastUnrestrictedUpdate()) > timeout) {
+ edge.Restrict();
+ RerouteCargo(from, c, to->index, from->index);
+ } else if (edge.LastRestrictedUpdate() != INVALID_DATE && (uint)(_date - edge.LastRestrictedUpdate()) > timeout) {
+ edge.Release();
}
}
assert(_date >= lg->LastCompression());