mirror of https://github.com/OpenTTD/OpenTTD
Fix #10028: Did Some Overtaking Routine Fixes
parent
82c70ed3b8
commit
1e75f87780
|
@ -77,7 +77,7 @@ static const uint RVC_DRIVE_THROUGH_STOP_FRAME = 11;
|
||||||
static const uint RVC_DEPOT_STOP_FRAME = 11;
|
static const uint RVC_DEPOT_STOP_FRAME = 11;
|
||||||
|
|
||||||
/** The number of ticks a vehicle has for overtaking. */
|
/** The number of ticks a vehicle has for overtaking. */
|
||||||
static const byte RV_OVERTAKE_TIMEOUT = 35;
|
static const byte RV_OVERTAKE_TIMEOUT = 25;
|
||||||
|
|
||||||
void RoadVehUpdateCache(RoadVehicle *v, bool same_length = false);
|
void RoadVehUpdateCache(RoadVehicle *v, bool same_length = false);
|
||||||
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
|
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
|
||||||
|
|
|
@ -768,8 +768,16 @@ struct OvertakeData {
|
||||||
static Vehicle *EnumFindVehBlockingOvertake(Vehicle *v, void *data)
|
static Vehicle *EnumFindVehBlockingOvertake(Vehicle *v, void *data)
|
||||||
{
|
{
|
||||||
const OvertakeData *od = (OvertakeData*)data;
|
const OvertakeData *od = (OvertakeData*)data;
|
||||||
|
TileIndexDiff front = TileOffsByDiagDir(DirToDiagDir(od->v->direction));
|
||||||
|
|
||||||
return (v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v) ? v : nullptr;
|
/* Distinct road engine is blocking if it's within the tile or the next few of the passer as well as either it being
|
||||||
|
* directionally opposed to passer, the passed pending movement, or the blocker being stopped while overtaking. */
|
||||||
|
return (v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v
|
||||||
|
&&
|
||||||
|
( v->tile == od->v->tile || v->tile == od->v->tile + front || v->tile == od->v->tile + front + front || v->tile == od->u->tile + front + front )
|
||||||
|
&&
|
||||||
|
( v->direction == ReverseDir(od->v->direction) || !(od->u->vehstatus & VS_STOPPED) || (v->vehstatus & VS_STOPPED && ( (RoadVehicle*)v )->overtaking ) ) )
|
||||||
|
? v : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -833,10 +841,10 @@ static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
|
||||||
* - No barred levelcrossing
|
* - No barred levelcrossing
|
||||||
* - No other vehicles in the way
|
* - No other vehicles in the way
|
||||||
*/
|
*/
|
||||||
|
|
||||||
od.tile = v->tile;
|
od.tile = v->tile;
|
||||||
if (CheckRoadBlockedForOvertaking(&od)) return;
|
if (CheckRoadBlockedForOvertaking(&od)) return;
|
||||||
|
od.tile += TileOffsByDiagDir(DirToDiagDir(v->direction));
|
||||||
od.tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction));
|
|
||||||
if (CheckRoadBlockedForOvertaking(&od)) return;
|
if (CheckRoadBlockedForOvertaking(&od)) return;
|
||||||
|
|
||||||
/* When the vehicle in front of us is stopped we may only take
|
/* When the vehicle in front of us is stopped we may only take
|
||||||
|
|
Loading…
Reference in New Issue