Merge branch 'master' into jgrpp
# Conflicts: # src/depot_type.h # src/lang/german.txt # src/order_gui.cpp # src/pathfinder/yapf/yapf_rail.cpp # src/script/api/script_window.hpp.in # src/settings_table.cpp # src/train_cmd.cpp
This commit is contained in:
@@ -56,9 +56,10 @@ Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDi
|
||||
* @param path_found [out] Whether a path has been found (true) or has been guessed (false)
|
||||
* @param reserve_track indicates whether YAPF should try to reserve the found path
|
||||
* @param target [out] the target tile of the reservation, free is set to true if path was reserved
|
||||
* @param dest [out] the final tile of the best path found
|
||||
* @return the best track for next turn
|
||||
*/
|
||||
Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, struct PBSTileInfo *target);
|
||||
Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, struct PBSTileInfo *target, TileIndex *dest);
|
||||
|
||||
/**
|
||||
* Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.
|
||||
|
@@ -128,6 +128,7 @@ protected:
|
||||
TileIndex m_destTile;
|
||||
TrackdirBits m_destTrackdirs;
|
||||
StationID m_dest_station_id;
|
||||
bool m_any_depot;
|
||||
|
||||
/** to access inherited path finder */
|
||||
Tpf& Yapf()
|
||||
@@ -138,6 +139,7 @@ protected:
|
||||
public:
|
||||
void SetDestination(const Train *v)
|
||||
{
|
||||
m_any_depot = false;
|
||||
switch (v->current_order.GetType()) {
|
||||
case OT_GOTO_WAYPOINT:
|
||||
if (!Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) {
|
||||
@@ -156,6 +158,12 @@ public:
|
||||
m_destTrackdirs = INVALID_TRACKDIR_BIT;
|
||||
break;
|
||||
|
||||
case OT_GOTO_DEPOT:
|
||||
if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
|
||||
m_any_depot = true;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
|
||||
default:
|
||||
m_destTile = v->dest_tile;
|
||||
m_dest_station_id = INVALID_STATION;
|
||||
@@ -180,6 +188,10 @@ public:
|
||||
&& (GetRailStationTrack(tile) == TrackdirToTrack(td));
|
||||
}
|
||||
|
||||
if (m_any_depot) {
|
||||
return IsRailDepotTile(tile);
|
||||
}
|
||||
|
||||
return (tile == m_destTile) && HasTrackdir(m_destTrackdirs, td);
|
||||
}
|
||||
|
||||
|
@@ -519,19 +519,19 @@ public:
|
||||
return 't';
|
||||
}
|
||||
|
||||
static Trackdir stChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target)
|
||||
static Trackdir stChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target, TileIndex *dest)
|
||||
{
|
||||
/* create pathfinder instance */
|
||||
Tpf pf1;
|
||||
Trackdir result1;
|
||||
|
||||
if (_debug_yapfdesync_level < 1 && _debug_desync_level < 2) {
|
||||
result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
|
||||
result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target, dest);
|
||||
} else {
|
||||
result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, false, nullptr);
|
||||
result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, false, nullptr, nullptr);
|
||||
Tpf pf2;
|
||||
pf2.DisableCache(true);
|
||||
Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
|
||||
Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target, dest);
|
||||
if (result1 != result2) {
|
||||
DEBUG(desync, 0, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2);
|
||||
DumpState(pf1, pf2);
|
||||
@@ -543,9 +543,10 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
inline Trackdir ChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target)
|
||||
inline Trackdir ChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target, TileIndex *dest)
|
||||
{
|
||||
if (target != nullptr) target->tile = INVALID_TILE;
|
||||
if (dest != nullptr) *dest = INVALID_TILE;
|
||||
|
||||
/* set origin and destination nodes */
|
||||
PBSTileInfo origin = FollowTrainReservation(v, nullptr, FTRF_OKAY_UNUSED);
|
||||
@@ -575,7 +576,10 @@ public:
|
||||
Node &best_next_node = *pPrev;
|
||||
next_trackdir = best_next_node.GetTrackdir();
|
||||
|
||||
if (reserve_track && path_found) this->TryReservePath(target, pNode->GetLastTile());
|
||||
if (reserve_track && path_found) {
|
||||
if (dest != nullptr) *dest = Yapf().GetBestNode()->GetLastTile();
|
||||
this->TryReservePath(target, pNode->GetLastTile());
|
||||
}
|
||||
}
|
||||
|
||||
/* Treat the path as found if stopped on the first two way signal(s). */
|
||||
@@ -656,10 +660,10 @@ struct CYapfAnySafeTileRail1 : CYapfT<CYapfRail_TypesT<CYapfAnySafeTileRail1, CF
|
||||
struct CYapfAnySafeTileRail2 : CYapfT<CYapfRail_TypesT<CYapfAnySafeTileRail2, CFollowTrackFreeRailNo90, CRailNodeListTrackDir, CYapfDestinationAnySafeTileRailT , CYapfFollowAnySafeTileRailT> > {};
|
||||
|
||||
|
||||
Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target)
|
||||
Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target, TileIndex *dest)
|
||||
{
|
||||
/* default is YAPF type 2 */
|
||||
typedef Trackdir (*PfnChooseRailTrack)(const Train*, TileIndex, DiagDirection, TrackBits, bool&, bool, PBSTileInfo*);
|
||||
typedef Trackdir (*PfnChooseRailTrack)(const Train*, TileIndex, DiagDirection, TrackBits, bool&, bool, PBSTileInfo*, TileIndex*);
|
||||
PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
|
||||
|
||||
/* check if non-default YAPF type needed */
|
||||
@@ -667,7 +671,7 @@ Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdi
|
||||
pfnChooseRailTrack = &CYapfRail2::stChooseRailTrack; // Trackdir, forbid 90-deg
|
||||
}
|
||||
|
||||
Trackdir td_ret = pfnChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
|
||||
Trackdir td_ret = pfnChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target, dest);
|
||||
return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : FindFirstTrack(tracks);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user