From 1c83ea86948724c4c214b685b5ffa96f9cb9570a Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 3 Mar 2024 18:49:38 +0000 Subject: [PATCH] Fix double-leave of crashed road vehicle in drive-through stop See: #662 --- src/roadveh_cmd.cpp | 1 + src/vehicle.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index dc4c9c0da9..28359d817f 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -613,6 +613,7 @@ uint RoadVehicle::Crash(bool flooded) /* If we're in a drive through road stop we ought to leave it */ if (IsInsideMM(this->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END)) { RoadStop::GetByTile(this->tile, GetRoadStopType(this->tile))->Leave(this); + this->state &= RVSB_ROAD_STOP_TRACKDIR_MASK; } } this->crashed_ctr = flooded ? 2000 : 1; // max 2220, disappear pretty fast when flooded diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 1753c56bbf..1d8793af2e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1204,7 +1204,7 @@ void Vehicle::PreDestructor() if (this->type == VEH_ROAD && this->IsPrimaryVehicle()) { RoadVehicle *v = RoadVehicle::From(this); - if (IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) || IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) { + if ((!(v->vehstatus & VS_CRASHED) && IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END)) || IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) { /* Leave the roadstop (bay or drive-through), when you have not already left it. */ RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile))->Leave(v); }