mirror of https://github.com/OpenTTD/OpenTTD
Change: Adapt pathfinders for extended road depots.
parent
718b92539a
commit
c270cebb59
|
@ -101,7 +101,7 @@ struct CFollowTrackT
|
||||||
{
|
{
|
||||||
assert(IsTram()); // this function shouldn't be called in other cases
|
assert(IsTram()); // this function shouldn't be called in other cases
|
||||||
|
|
||||||
if (IsNormalRoadTile(tile)) {
|
if (IsNormalRoadTile(tile) || IsExtendedRoadDepotTile(tile)) {
|
||||||
RoadBits rb = GetRoadBits(tile, RTT_TRAM);
|
RoadBits rb = GetRoadBits(tile, RTT_TRAM);
|
||||||
switch (rb) {
|
switch (rb) {
|
||||||
case ROAD_NW: return DIAGDIR_NW;
|
case ROAD_NW: return DIAGDIR_NW;
|
||||||
|
@ -272,14 +272,16 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* road depots can be also left in one direction only */
|
/* road depots can be also left in one direction sometimes */
|
||||||
if (IsRoadTT() && IsDepotTypeTile(m_old_tile, TT())) {
|
if (IsRoadTT() && IsDepotTypeTile(m_old_tile, TT())) {
|
||||||
DiagDirection exitdir = GetRoadDepotDirection(m_old_tile);
|
RoadTramType rtt = IsTram() ? RTT_TRAM : RTT_ROAD;
|
||||||
if (exitdir != m_exitdir) {
|
RoadBits rb = GetRoadBits(m_old_tile, rtt);
|
||||||
|
if ((rb & DiagDirToRoadBits(m_exitdir)) == ROAD_NONE) {
|
||||||
m_err = EC_NO_WAY;
|
m_err = EC_NO_WAY;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,16 +308,17 @@ protected:
|
||||||
|
|
||||||
/* road and rail depots can also be entered from one direction only */
|
/* road and rail depots can also be entered from one direction only */
|
||||||
if (IsRoadTT() && IsDepotTypeTile(m_new_tile, TT())) {
|
if (IsRoadTT() && IsDepotTypeTile(m_new_tile, TT())) {
|
||||||
DiagDirection exitdir = GetRoadDepotDirection(m_new_tile);
|
|
||||||
if (ReverseDiagDir(exitdir) != m_exitdir) {
|
|
||||||
m_err = EC_NO_WAY;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* don't try to enter other company's depots */
|
/* don't try to enter other company's depots */
|
||||||
if (GetTileOwner(m_new_tile) != m_veh_owner) {
|
if (GetTileOwner(m_new_tile) != m_veh_owner) {
|
||||||
m_err = EC_OWNER;
|
m_err = EC_OWNER;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
RoadTramType rtt = IsTram() ? RTT_TRAM : RTT_ROAD;
|
||||||
|
RoadBits rb = GetRoadBits(m_new_tile, rtt);
|
||||||
|
if ((rb & DiagDirToRoadBits(ReverseDiagDir(m_exitdir))) == ROAD_NONE) {
|
||||||
|
m_err = EC_NO_WAY;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (IsRailTT() && IsStandardRailDepotTile(m_new_tile)) {
|
if (IsRailTT() && IsStandardRailDepotTile(m_new_tile)) {
|
||||||
DiagDirection exitdir = GetRailDepotDirection(m_new_tile);
|
DiagDirection exitdir = GetRailDepotDirection(m_new_tile);
|
||||||
|
@ -404,9 +407,11 @@ protected:
|
||||||
if (IsExtendedRailDepot(m_old_tile)) return false;
|
if (IsExtendedRailDepot(m_old_tile)) return false;
|
||||||
exitdir = GetRailDepotDirection(m_old_tile);
|
exitdir = GetRailDepotDirection(m_old_tile);
|
||||||
break;
|
break;
|
||||||
case TRANSPORT_ROAD:
|
case TRANSPORT_ROAD: {
|
||||||
exitdir = GetRoadDepotDirection(m_old_tile);
|
if (GetRoadBits(m_old_tile, IsTram() ? RTT_TRAM : RTT_ROAD) != DiagDirToRoadBits(m_exitdir)) return false;
|
||||||
|
exitdir = ReverseDiagDir(m_exitdir);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,19 @@ protected:
|
||||||
/* Increase the cost for level crossings */
|
/* Increase the cost for level crossings */
|
||||||
if (IsLevelCrossing(tile)) {
|
if (IsLevelCrossing(tile)) {
|
||||||
cost += Yapf().PfGetSettings().road_crossing_penalty;
|
cost += Yapf().PfGetSettings().road_crossing_penalty;
|
||||||
|
} else if (IsRoadDepot(tile) && IsExtendedRoadDepot(tile)) {
|
||||||
|
switch (GetDepotReservation(tile, IsDiagDirFacingSouth(TrackdirToExitdir(trackdir)))) {
|
||||||
|
case DEPOT_RESERVATION_FULL_STOPPED_VEH:
|
||||||
|
cost += 16 * YAPF_TILE_LENGTH;
|
||||||
|
break;
|
||||||
|
case DEPOT_RESERVATION_IN_USE:
|
||||||
|
cost += 8 * YAPF_TILE_LENGTH;
|
||||||
|
break;
|
||||||
|
case DEPOT_RESERVATION_EMPTY:
|
||||||
|
cost += YAPF_TILE_LENGTH;
|
||||||
|
break;
|
||||||
|
default: NOT_REACHED();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -135,7 +148,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stop if we have just entered the depot */
|
/* stop if we have just entered the depot */
|
||||||
if (IsRoadDepotTile(tile) && trackdir == DiagDirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
|
if (IsRoadDepotTile(tile) && !IsExtendedRoadDepotTile(tile) && trackdir == DiagDirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
|
||||||
/* next time we will reverse and leave the depot */
|
/* next time we will reverse and leave the depot */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +214,7 @@ public:
|
||||||
/** Called by YAPF to detect if node ends in the desired destination */
|
/** Called by YAPF to detect if node ends in the desired destination */
|
||||||
inline bool PfDetectDestination(Node &n)
|
inline bool PfDetectDestination(Node &n)
|
||||||
{
|
{
|
||||||
return IsRoadDepotTile(n.m_segment_last_tile);
|
return PfDetectDestinationTile(n.m_segment_last_tile, n.m_segment_last_td);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool PfDetectDestinationTile(TileIndex tile, Trackdir)
|
inline bool PfDetectDestinationTile(TileIndex tile, Trackdir)
|
||||||
|
|
Loading…
Reference in New Issue