Don't check safe waiting point in FollowTrainReservation if result unused
This commit is contained in:
@@ -211,7 +211,7 @@ static void FixAllReservations()
|
||||
* detect this by first finding the end of the reservation,
|
||||
* then switch sharing on and try again. If these two ends differ,
|
||||
* unreserve the path, switch sharing off and try to reserve a new path */
|
||||
PBSTileInfo end_tile_info = FollowTrainReservation(v, nullptr, FTRF_IGNORE_LOOKAHEAD);
|
||||
PBSTileInfo end_tile_info = FollowTrainReservation(v, nullptr, FTRF_IGNORE_LOOKAHEAD | FTRF_OKAY_UNUSED);
|
||||
|
||||
/* first do a quick test to determine whether the next tile has any reservation at all */
|
||||
TileIndex next_tile = end_tile_info.tile + TileOffsByDiagDir(TrackdirToExitdir(end_tile_info.trackdir));
|
||||
@@ -220,7 +220,7 @@ static void FixAllReservations()
|
||||
|
||||
/* change sharing setting temporarily */
|
||||
_settings_game.economy.infrastructure_sharing[VEH_TRAIN] = true;
|
||||
PBSTileInfo end_tile_info2 = FollowTrainReservation(v, nullptr, FTRF_IGNORE_LOOKAHEAD);
|
||||
PBSTileInfo end_tile_info2 = FollowTrainReservation(v, nullptr, FTRF_IGNORE_LOOKAHEAD | FTRF_OKAY_UNUSED);
|
||||
/* if these two reservation ends differ, unreserve the path and try to reserve a new path */
|
||||
if (end_tile_info.tile != end_tile_info2.tile || end_tile_info.trackdir != end_tile_info2.trackdir) {
|
||||
FreeTrainTrackReservation(v);
|
||||
|
@@ -540,7 +540,7 @@ public:
|
||||
if (target != nullptr) target->tile = INVALID_TILE;
|
||||
|
||||
/* set origin and destination nodes */
|
||||
PBSTileInfo origin = FollowTrainReservation(v);
|
||||
PBSTileInfo origin = FollowTrainReservation(v, nullptr, FTRF_OKAY_UNUSED);
|
||||
Yapf().SetOrigin(origin.tile, origin.trackdir, INVALID_TILE, INVALID_TRACKDIR, 1, true);
|
||||
Yapf().SetDestination(v);
|
||||
|
||||
@@ -744,7 +744,7 @@ FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_penalty)
|
||||
{
|
||||
const Train *last_veh = v->Last();
|
||||
|
||||
PBSTileInfo origin = FollowTrainReservation(v);
|
||||
PBSTileInfo origin = FollowTrainReservation(v, nullptr, FTRF_OKAY_UNUSED);
|
||||
TileIndex last_tile = last_veh->tile;
|
||||
Trackdir td_rev = ReverseTrackdir(last_veh->GetVehicleTrackdir());
|
||||
|
||||
|
@@ -693,7 +693,7 @@ PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res, Follo
|
||||
|
||||
FindTrainOnTrackInfo ftoti;
|
||||
ftoti.res = FollowReservation(v->owner, GetRailTypeInfo(v->railtype)->all_compatible_railtypes, tile, trackdir, FRF_NONE, v, nullptr);
|
||||
ftoti.res.okay = IsSafeWaitingPosition(v, ftoti.res.tile, ftoti.res.trackdir, true, _settings_game.pf.forbid_90_deg);
|
||||
ftoti.res.okay = (flags & FTRF_OKAY_UNUSED) ? false : IsSafeWaitingPosition(v, ftoti.res.tile, ftoti.res.trackdir, true, _settings_game.pf.forbid_90_deg);
|
||||
if (train_on_res != nullptr) {
|
||||
FindVehicleOnPos(ftoti.res.tile, VEH_TRAIN, &ftoti, FindTrainOnTrackEnum);
|
||||
if (ftoti.best != nullptr) *train_on_res = ftoti.best->First();
|
||||
|
@@ -137,6 +137,7 @@ struct TrainReservationLookAhead {
|
||||
enum FollowTrainReservationFlags {
|
||||
FTRF_NONE = 0, ///< No flags
|
||||
FTRF_IGNORE_LOOKAHEAD = 0x01, ///< No use of cached lookahead
|
||||
FTRF_OKAY_UNUSED = 0x02, ///< 'okay' return value is not used
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(FollowTrainReservationFlags)
|
||||
|
||||
|
@@ -2984,7 +2984,7 @@ static FindDepotData FindClosestTrainDepot(Train *v, int max_distance)
|
||||
|
||||
if (IsRailDepotTile(v->tile)) return FindDepotData(v->tile, 0);
|
||||
|
||||
PBSTileInfo origin = FollowTrainReservation(v);
|
||||
PBSTileInfo origin = FollowTrainReservation(v, nullptr, FTRF_OKAY_UNUSED);
|
||||
if (IsRailDepotTile(origin.tile)) return FindDepotData(origin.tile, 0);
|
||||
|
||||
switch (_settings_game.pf.pathfinder_for_trains) {
|
||||
@@ -3927,7 +3927,7 @@ static void TryLongReserveChooseTrainTrack(Train *v, TileIndex tile, Trackdir td
|
||||
|
||||
static void TryLongReserveChooseTrainTrackFromReservationEnd(Train *v, bool no_reserve_vehicle_tile)
|
||||
{
|
||||
PBSTileInfo origin = FollowTrainReservation(v);
|
||||
PBSTileInfo origin = FollowTrainReservation(v, nullptr, FTRF_OKAY_UNUSED);
|
||||
if (IsRailDepotTile(origin.tile)) return;
|
||||
|
||||
ChooseTrainTrackLookAheadState lookahead_state;
|
||||
@@ -4012,7 +4012,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir,
|
||||
v->lookahead.reset();
|
||||
}
|
||||
|
||||
PBSTileInfo origin = FollowTrainReservation(v);
|
||||
PBSTileInfo origin = FollowTrainReservation(v, nullptr, FTRF_OKAY_UNUSED);
|
||||
PBSTileInfo res_dest(tile, INVALID_TRACKDIR, false);
|
||||
DiagDirection dest_enterdir = enterdir;
|
||||
if (do_track_reservation) {
|
||||
@@ -4083,7 +4083,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir,
|
||||
/* No possible reservation target found, we are probably lost. */
|
||||
if (res_dest.tile == INVALID_TILE) {
|
||||
/* Try to find any safe destination. */
|
||||
PBSTileInfo path_end = FollowTrainReservation(v);
|
||||
PBSTileInfo path_end = FollowTrainReservation(v, nullptr, FTRF_OKAY_UNUSED);
|
||||
if (TryReserveSafeTrack(v, path_end.tile, path_end.trackdir, false)) {
|
||||
TrackBits res = GetReservedTrackbits(tile) & DiagdirReachesTracks(enterdir);
|
||||
best_track = FindFirstTrack(res);
|
||||
|
Reference in New Issue
Block a user