mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Adjust overtaking RV state and direction pre-conditions
This commit is contained in:
parent
ffe3c769a3
commit
b0dbcf33c1
@ -917,13 +917,22 @@ static bool IsNonOvertakingStationTile(TileIndex tile, DiagDirection diag_dir)
|
|||||||
return GetDriveThroughStopDisallowedRoadDirections(tile) != diagdir_to_drd[diag_dir];
|
return GetDriveThroughStopDisallowedRoadDirections(tile) != diagdir_to_drd[diag_dir];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool IsValidRoadVehStateForOvertake(const RoadVehicle *v)
|
||||||
|
{
|
||||||
|
if (v->state == RVSB_IN_DEPOT) return false;
|
||||||
|
if (v->state < TRACKDIR_END && !IsDiagonalTrackdir((Trackdir)v->state)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
|
static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
|
||||||
{
|
{
|
||||||
/* Trams can't overtake other trams */
|
/* Trams can't overtake other trams */
|
||||||
if (RoadTypeIsTram(v->roadtype)) return;
|
if (RoadTypeIsTram(v->roadtype)) return;
|
||||||
|
|
||||||
/* Vehicles are not driving in same direction || direction is not a diagonal direction */
|
/* Other vehicle is facing the opposite direction || direction is not a diagonal direction */
|
||||||
if (v->direction != u->direction || !(v->direction & 1)) return;
|
if (v->direction == ReverseDir(u->Last()->direction) || !(v->direction & 1)) return;
|
||||||
|
|
||||||
|
if (!IsValidRoadVehStateForOvertake(v)) return;
|
||||||
|
|
||||||
/* Don't overtake in stations */
|
/* Don't overtake in stations */
|
||||||
if (IsNonOvertakingStationTile(u->tile, DirToDiagDir(u->direction))) return;
|
if (IsNonOvertakingStationTile(u->tile, DirToDiagDir(u->direction))) return;
|
||||||
@ -938,6 +947,8 @@ static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
|
|||||||
if (v->GetOvertakingCounterThreshold() > 255) return;
|
if (v->GetOvertakingCounterThreshold() > 255) return;
|
||||||
|
|
||||||
for (RoadVehicle *w = v; w != nullptr; w = w->Next()) {
|
for (RoadVehicle *w = v; w != nullptr; w = w->Next()) {
|
||||||
|
if (!IsValidRoadVehStateForOvertake(w)) return;
|
||||||
|
|
||||||
/* Don't overtake in stations */
|
/* Don't overtake in stations */
|
||||||
if (IsNonOvertakingStationTile(w->tile, DirToDiagDir(w->direction))) return;
|
if (IsNonOvertakingStationTile(w->tile, DirToDiagDir(w->direction))) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user