diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 3a2c379772..3c5aee8720 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -447,6 +447,9 @@ public: /** Minimum effective distance for timeout calculation. */ static const uint MIN_TIMEOUT_DISTANCE = 32; + /** Number of days before deleting links served only by vehicles stopped in depot. */ + static const uint STALE_LINK_DEPOT_TIMEOUT = 1024; + /** Minimum number of days between subsequent compressions of a LG. */ static const uint COMPRESSION_INTERVAL = 256; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index e2c232ac7e..fa11c05d5b 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3688,8 +3688,11 @@ void DeleteStaleLinks(Station *from) auto iter = vehicles.begin(); while (iter != vehicles.end()) { Vehicle *v = *iter; - - LinkRefresher::Run(v, false); // Don't allow merging. Otherwise lg might get deleted. + /* Do not refresh links of vehicles that have been stopped in depot for a long time. */ + if (!v->IsStoppedInDepot() || static_cast(_date - v->date_of_last_service) <= + LinkGraph::STALE_LINK_DEPOT_TIMEOUT) { + LinkRefresher::Run(v, false); // Don't allow merging. Otherwise lg might get deleted. + } if (edge.LastUpdate() == _date) { updated = true; break;