diff --git a/src/departures.cpp b/src/departures.cpp index 327de30bfb..cee6a1cf3c 100644 --- a/src/departures.cpp +++ b/src/departures.cpp @@ -612,15 +612,20 @@ DepartureList* MakeDepartureList(StationID station, const std::vectorsize() - 1; ++i) { Departure *d_first = (*result)[i]; uint k = (uint)d_first->calling_at.size() - 2; - for (uint j = (uint)d->calling_at.size(); j > 0; --j) { + uint j = (uint)d->calling_at.size(); + while (j > 0) { CallAt c = CallAt(d->calling_at[j - 1]); if (d_first->terminus >= c && d_first->calling_at.size() >= 2) { d_first->terminus = CallAt(d_first->calling_at[k]); + if (d_first->via == d_first->terminus.station) d_first->via = INVALID_STATION; if (k == 0) break; k--; + j = (uint)d->calling_at.size(); + } else { + j--; } } }