From e7125176b263c55d9ba46019816de9e89de0f96e Mon Sep 17 00:00:00 2001 From: sevii1 <127436701+sevii1@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:12:46 -0400 Subject: [PATCH] Adjusted overtaking to ensure stopped vehicles do not prevent an overtake --- src/roadveh_cmd.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index a638f379fe..88e809eabc 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -772,7 +772,17 @@ static Vehicle *EnumFindVehBlockingOvertake(Vehicle *v, void *data) { const OvertakeData *od = (OvertakeData*)data; - return (v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v) ? v : nullptr; + /** + * first ensure that the vehicle we are looking at is a road vehicle + * also ensure that the vehicle we are looking at is neither of the vehicles stored in OvertakeData + * + * A block can only happen if more than two vehicles are involved, so we can skip past this if there are only two + */ + if ((v->type == VEH_ROAD && v->First() == v) && (v != od->u && v != od->v)) { + /* ensure that third vehicle overtaking does not get stuck in place by allowing it to overtake */ + return (((RoadVehicle *)v)->overtaking && v->cur_speed == 0) ? v : nullptr; + } + return nullptr; } /**