Fix crash which could occur when trying to extend invalidated reservation

When using realistic braking
This commit is contained in:
Jonathan G Rennison
2024-01-16 17:31:23 +00:00
parent c8d82eb988
commit 091fb0da44

View File

@@ -1016,7 +1016,11 @@ static void AdvanceLookAheadPosition(Train *v)
if (v->lookahead->current_position == v->lookahead->next_extend_position) { if (v->lookahead->current_position == v->lookahead->next_extend_position) {
SetTrainReservationLookaheadEnd(v); SetTrainReservationLookaheadEnd(v);
/* This may clear the lookahead if it has become invalid */
TryLongReserveChooseTrainTrackFromReservationEnd(v, true); TryLongReserveChooseTrainTrackFromReservationEnd(v, true);
if (v->lookahead == nullptr) return;
v->lookahead->SetNextExtendPositionIfUnset(); v->lookahead->SetNextExtendPositionIfUnset();
} }
} }