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:
@@ -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