1
0
Fork 0

Adjusted overtaking to ensure stopped vehicles do not prevent an overtake

pull/12807/head
sevii1 2024-06-24 20:12:46 -04:00
parent 64781df29f
commit e7125176b2
1 changed files with 11 additions and 1 deletions

View File

@ -772,7 +772,17 @@ static Vehicle *EnumFindVehBlockingOvertake(Vehicle *v, void *data)
{ {
const OvertakeData *od = (OvertakeData*)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;
} }
/** /**