diff --git a/src/pathfinder/yapf/yapf_node_rail.hpp b/src/pathfinder/yapf/yapf_node_rail.hpp index fafa75dbca..53483d30e3 100644 --- a/src/pathfinder/yapf/yapf_node_rail.hpp +++ b/src/pathfinder/yapf/yapf_node_rail.hpp @@ -110,9 +110,8 @@ struct CYapfRailSegment { }; /** Yapf Node for rail YAPF */ -template -struct CYapfRailNodeT : CYapfNodeT> { - typedef CYapfNodeT> base; +struct CYapfRailNode : CYapfNodeT { + typedef CYapfNodeT base; typedef CYapfRailSegment CachedData; CYapfRailSegment *segment; @@ -128,7 +127,7 @@ struct CYapfRailNodeT : CYapfNodeT> { SignalType last_red_signal_type; SignalType last_signal_type; - inline void Set(CYapfRailNodeT *parent, TileIndex tile, Trackdir td, bool is_choice) + inline void Set(CYapfRailNode *parent, TileIndex tile, Trackdir td, bool is_choice) { this->base::Set(parent, tile, td, is_choice); this->segment = nullptr; @@ -206,12 +205,6 @@ struct CYapfRailNodeT : CYapfNodeT> { } }; -/* now define two major node types (that differ by key type) */ -typedef CYapfRailNodeT CYapfRailNodeExitDir; -typedef CYapfRailNodeT CYapfRailNodeTrackDir; - -/* Default NodeList types */ -typedef NodeList CRailNodeListExitDir; -typedef NodeList CRailNodeListTrackDir; +typedef NodeList CRailNodeList; #endif /* YAPF_NODE_RAIL_HPP */ diff --git a/src/pathfinder/yapf/yapf_node_road.hpp b/src/pathfinder/yapf/yapf_node_road.hpp index 0a9dc59648..b70e118870 100644 --- a/src/pathfinder/yapf/yapf_node_road.hpp +++ b/src/pathfinder/yapf/yapf_node_road.hpp @@ -16,14 +16,13 @@ #include "yapf_node.hpp" /** Yapf Node for road YAPF */ -template -struct CYapfRoadNodeT : CYapfNodeT> { - typedef CYapfNodeT> base; +struct CYapfRoadNode : CYapfNodeT { + typedef CYapfNodeT base; TileIndex segment_last_tile; Trackdir segment_last_td; - void Set(CYapfRoadNodeT *parent, TileIndex tile, Trackdir td, bool is_choice) + void Set(CYapfRoadNode *parent, TileIndex tile, Trackdir td, bool is_choice) { this->base::Set(parent, tile, td, is_choice); this->segment_last_tile = tile; @@ -31,12 +30,6 @@ struct CYapfRoadNodeT : CYapfNodeT> { } }; -/* now define two major node types (that differ by key type) */ -typedef CYapfRoadNodeT CYapfRoadNodeExitDir; -typedef CYapfRoadNodeT CYapfRoadNodeTrackDir; - -/* Default NodeList types */ -typedef NodeList CRoadNodeListExitDir; -typedef NodeList CRoadNodeListTrackDir; +typedef NodeList CRoadNodeList; #endif /* YAPF_NODE_ROAD_HPP */ diff --git a/src/pathfinder/yapf/yapf_node_ship.hpp b/src/pathfinder/yapf/yapf_node_ship.hpp index 8b79a6a47e..481d77b9fe 100644 --- a/src/pathfinder/yapf/yapf_node_ship.hpp +++ b/src/pathfinder/yapf/yapf_node_ship.hpp @@ -16,16 +16,9 @@ #include "yapf_node.hpp" /** Yapf Node for ships */ -template -struct CYapfShipNodeT : CYapfNodeT> { +struct CYapfShipNode : CYapfNodeT { }; -/* now define two major node types (that differ by key type) */ -typedef CYapfShipNodeT CYapfShipNodeExitDir; -typedef CYapfShipNodeT CYapfShipNodeTrackDir; - -/* Default NodeList types */ -typedef NodeList CShipNodeListExitDir; -typedef NodeList CShipNodeListTrackDir; +typedef NodeList CShipNodeList; #endif /* YAPF_NODE_SHIP_HPP */ diff --git a/src/pathfinder/yapf/yapf_rail.cpp b/src/pathfinder/yapf/yapf_rail.cpp index b462b4eee8..208b65b737 100644 --- a/src/pathfinder/yapf/yapf_rail.cpp +++ b/src/pathfinder/yapf/yapf_rail.cpp @@ -528,13 +528,13 @@ public: } }; -template class TdestinationT, template class TfollowT> +template class TdestinationT, template class TfollowT> struct CYapfRail_TypesT { - typedef CYapfRail_TypesT Types; + typedef CYapfRail_TypesT Types; typedef Tpf_ Tpf; typedef Ttrack_follower TrackFollower; - typedef Tnode_list NodeList; + typedef CRailNodeList NodeList; typedef Train VehicleType; typedef CYapfBaseT PfBase; typedef TfollowT PfFollow; @@ -544,21 +544,21 @@ struct CYapfRail_TypesT { typedef CYapfCostRailT PfCost; }; -struct CYapfRail1 : CYapfT> {}; -struct CYapfRail2 : CYapfT> {}; +struct CYapfRail : CYapfT> {}; +struct CYapfRailNo90 : CYapfT> {}; -struct CYapfAnyDepotRail1 : CYapfT> {}; -struct CYapfAnyDepotRail2 : CYapfT> {}; +struct CYapfAnyDepotRail : CYapfT> {}; +struct CYapfAnyDepotRailNo90 : CYapfT> {}; -struct CYapfAnySafeTileRail1 : CYapfT> {}; -struct CYapfAnySafeTileRail2 : CYapfT> {}; +struct CYapfAnySafeTileRail : CYapfT> {}; +struct CYapfAnySafeTileRailNo90 : CYapfT> {}; Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target, TileIndex *dest) { Trackdir td_ret = _settings_game.pf.forbid_90_deg - ? CYapfRail2::stChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target, dest) - : CYapfRail1::stChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target, dest); + ? CYapfRailNo90::stChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target, dest) + : CYapfRail::stChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target, dest); return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : FindFirstTrack(tracks); } @@ -610,8 +610,8 @@ bool YapfTrainCheckReverse(const Train *v) if (reverse_penalty == 0) reverse_penalty = 1; bool reverse = _settings_game.pf.forbid_90_deg - ? CYapfRail2::stCheckReverseTrain(v, tile, td, tile_rev, td_rev, reverse_penalty) - : CYapfRail1::stCheckReverseTrain(v, tile, td, tile_rev, td_rev, reverse_penalty); + ? CYapfRailNo90::stCheckReverseTrain(v, tile, td, tile_rev, td_rev, reverse_penalty) + : CYapfRail::stCheckReverseTrain(v, tile, td, tile_rev, td_rev, reverse_penalty); return reverse; } @@ -625,15 +625,15 @@ FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_penalty) Trackdir td_rev = ReverseTrackdir(last_veh->GetVehicleTrackdir()); return _settings_game.pf.forbid_90_deg - ? CYapfAnyDepotRail2::stFindNearestDepotTwoWay(v, origin.tile, origin.trackdir, last_tile, td_rev, max_penalty, YAPF_INFINITE_PENALTY) - : CYapfAnyDepotRail1::stFindNearestDepotTwoWay(v, origin.tile, origin.trackdir, last_tile, td_rev, max_penalty, YAPF_INFINITE_PENALTY); + ? CYapfAnyDepotRailNo90::stFindNearestDepotTwoWay(v, origin.tile, origin.trackdir, last_tile, td_rev, max_penalty, YAPF_INFINITE_PENALTY) + : CYapfAnyDepotRail::stFindNearestDepotTwoWay(v, origin.tile, origin.trackdir, last_tile, td_rev, max_penalty, YAPF_INFINITE_PENALTY); } bool YapfTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir td, bool override_railtype) { return _settings_game.pf.forbid_90_deg - ? CYapfAnySafeTileRail2::stFindNearestSafeTile(v, tile, td, override_railtype) - : CYapfAnySafeTileRail1::stFindNearestSafeTile(v, tile, td, override_railtype); + ? CYapfAnySafeTileRailNo90::stFindNearestSafeTile(v, tile, td, override_railtype) + : CYapfAnySafeTileRail::stFindNearestSafeTile(v, tile, td, override_railtype); } /** if any track changes, this counter is incremented - that will invalidate segment cost cache */ diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index f886a90774..2611ceb379 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -485,13 +485,13 @@ public: } }; -template class Tdestination> +template class Tdestination> struct CYapfRoad_TypesT { - typedef CYapfRoad_TypesT Types; + typedef CYapfRoad_TypesT Types; typedef Tpf_ Tpf; typedef CFollowTrackRoad TrackFollower; - typedef Tnode_list NodeList; + typedef CRoadNodeList NodeList; typedef RoadVehicle VehicleType; typedef CYapfBaseT PfBase; typedef CYapfFollowRoadT PfFollow; @@ -501,18 +501,13 @@ struct CYapfRoad_TypesT { typedef CYapfCostRoadT PfCost; }; -struct CYapfRoad1 : CYapfT> {}; -struct CYapfRoad2 : CYapfT> {}; - -struct CYapfRoadAnyDepot1 : CYapfT> {}; -struct CYapfRoadAnyDepot2 : CYapfT> {}; +struct CYapfRoad : CYapfT> {}; +struct CYapfRoadAnyDepot : CYapfT> {}; Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool &path_found, RoadVehPathCache &path_cache) { - Trackdir td_ret = _settings_game.pf.yapf.disable_node_optimization - ? CYapfRoad1::stChooseRoadTrack(v, tile, enterdir, path_found, path_cache) // Trackdir - : CYapfRoad2::stChooseRoadTrack(v, tile, enterdir, path_found, path_cache); // ExitDir, allow 90-deg + Trackdir td_ret = CYapfRoad::stChooseRoadTrack(v, tile, enterdir, path_found, path_cache); return (td_ret != INVALID_TRACKDIR) ? td_ret : (Trackdir)FindFirstBit(trackdirs); } @@ -526,7 +521,5 @@ FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_dist return FindDepotData(); } - return _settings_game.pf.yapf.disable_node_optimization - ? CYapfRoadAnyDepot1::stFindNearestDepot(v, tile, trackdir, max_distance) // Trackdir - : CYapfRoadAnyDepot2::stFindNearestDepot(v, tile, trackdir, max_distance); // ExitDir + return CYapfRoadAnyDepot::stFindNearestDepot(v, tile, trackdir, max_distance); } diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index a5f1ef67a2..335a589ef6 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -398,13 +398,13 @@ public: * Config struct of YAPF for ships. * Defines all 6 base YAPF modules as classes providing services for CYapfBaseT. */ -template +template struct CYapfShip_TypesT { - typedef CYapfShip_TypesT Types; ///< Shortcut for this struct type. - typedef Tpf_ Tpf; ///< Pathfinder type. - typedef Ttrack_follower TrackFollower; ///< Track follower helper class. - typedef Tnode_list NodeList; - typedef Ship VehicleType; + typedef CYapfShip_TypesT Types; ///< Shortcut for this struct type. + typedef Tpf_ Tpf; ///< Pathfinder type. + typedef CFollowTrackWater TrackFollower; ///< Track follower helper class. + typedef CShipNodeList NodeList; + typedef Ship VehicleType; /** Pathfinder components (modules). */ typedef CYapfBaseT PfBase; ///< Base pathfinder class. @@ -415,7 +415,7 @@ struct CYapfShip_TypesT { typedef CYapfCostShipT PfCost; ///< Cost provider. }; -struct CYapfShip : CYapfT> { +struct CYapfShip : CYapfT> { explicit CYapfShip(int max_nodes) { this->max_search_nodes = max_nodes; } }; diff --git a/src/saveload/compat/settings_sl_compat.h b/src/saveload/compat/settings_sl_compat.h index 422e5a2785..9fe49f8b12 100644 --- a/src/saveload/compat/settings_sl_compat.h +++ b/src/saveload/compat/settings_sl_compat.h @@ -185,7 +185,7 @@ const SaveLoadCompat _settings_sl_compat[] = { SLC_NULL(4, SLV_47, SLV_TABLE_CHUNKS), SLC_NULL(8, SLV_130, SLV_TABLE_CHUNKS), SLC_NULL(4, SLV_131, SLV_TABLE_CHUNKS), - SLC_VAR("pf.yapf.disable_node_optimization"), + SLC_NULL(1, SLV_28, SLV_TABLE_CHUNKS), SLC_VAR("pf.yapf.max_search_nodes"), SLC_VAR("pf.yapf.rail_firstred_twoway_eol"), SLC_VAR("pf.yapf.rail_firstred_penalty"), diff --git a/src/settings_type.h b/src/settings_type.h index 3c596d32c1..86350e4054 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -431,7 +431,6 @@ struct ScriptSettings { /** Settings related to the yet another pathfinder. */ struct YAPFSettings { - bool disable_node_optimization; ///< whether to use exit-dir instead of trackdir in node key uint32_t max_search_nodes; ///< stop path-finding when this number of nodes visited uint32_t maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot uint32_t road_slope_penalty; ///< penalty for up-hill slope diff --git a/src/table/settings/pathfinding_settings.ini b/src/table/settings/pathfinding_settings.ini index daf7b804bb..1bf6efac3a 100644 --- a/src/table/settings/pathfinding_settings.ini +++ b/src/table/settings/pathfinding_settings.ini @@ -98,12 +98,6 @@ min = 1 max = 255 cat = SC_EXPERT -[SDT_BOOL] -var = pf.yapf.disable_node_optimization -from = SLV_28 -def = false -cat = SC_EXPERT - [SDT_VAR] var = pf.yapf.max_search_nodes type = SLE_UINT