summaryrefslogtreecommitdiff
path: root/src/yapf
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-25 19:17:03 +0000
committerrubidium <rubidium@openttd.org>2008-05-25 19:17:03 +0000
commitdc77647ea4a2becac4eff3190970cb35671b0131 (patch)
treed480693e848eb121add7037faa150875d750cc98 /src/yapf
parent26ee8f3ca10d1d277b5faaa8554b0a8305711664 (diff)
downloadopenttd-dc77647ea4a2becac4eff3190970cb35671b0131.tar.xz
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
-Codechange: move all Settings into substructs of _settings in a way that they are logically grouped.
Diffstat (limited to 'src/yapf')
-rw-r--r--src/yapf/yapf_base.hpp7
-rw-r--r--src/yapf/yapf_rail.cpp6
-rw-r--r--src/yapf/yapf_road.cpp6
-rw-r--r--src/yapf/yapf_settings.h72
-rw-r--r--src/yapf/yapf_ship.cpp4
5 files changed, 12 insertions, 83 deletions
diff --git a/src/yapf/yapf_base.hpp b/src/yapf/yapf_base.hpp
index f83ecbb20..7ccd4ebf5 100644
--- a/src/yapf/yapf_base.hpp
+++ b/src/yapf/yapf_base.hpp
@@ -6,6 +6,7 @@
#define YAPF_BASE_HPP
#include "../debug.h"
+#include "../settings_type.h"
extern int _total_pf_time_us;
@@ -52,7 +53,7 @@ public:
protected:
Node* m_pBestDestNode; ///< pointer to the destination node found at last round
Node* m_pBestIntermediateNode; ///< here should be node closest to the destination if path not found
- const YapfSettings *m_settings; ///< current settings (_patches.yapf)
+ const YAPFSettings *m_settings; ///< current settings (_settings.yapf)
int m_max_search_nodes; ///< maximum number of nodes we are allowed to visit before we give up
const Vehicle* m_veh; ///< vehicle that we are trying to drive
@@ -73,7 +74,7 @@ public:
FORCEINLINE CYapfBaseT()
: m_pBestDestNode(NULL)
, m_pBestIntermediateNode(NULL)
- , m_settings(&_patches.yapf)
+ , m_settings(&_settings.pf.yapf)
, m_max_search_nodes(PfGetSettings().max_search_nodes)
, m_veh(NULL)
, m_stats_cost_calcs(0)
@@ -91,7 +92,7 @@ protected:
public:
/// return current settings (can be custom - player based - but later)
- FORCEINLINE const YapfSettings& PfGetSettings() const
+ FORCEINLINE const YAPFSettings& PfGetSettings() const
{
return *m_settings;
}
diff --git a/src/yapf/yapf_rail.cpp b/src/yapf/yapf_rail.cpp
index ffbb1a2c1..2651a9df4 100644
--- a/src/yapf/yapf_rail.cpp
+++ b/src/yapf/yapf_rail.cpp
@@ -254,7 +254,7 @@ Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir,
PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg) {
+ if (_settings.pf.forbid_90_deg) {
pfnChooseRailTrack = &CYapfRail2::stChooseRailTrack; // Trackdir, forbid 90-deg
}
@@ -311,7 +311,7 @@ bool YapfCheckReverseTrain(Vehicle* v)
PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg) {
+ if (_settings.pf.forbid_90_deg) {
pfnCheckReverseTrain = &CYapfRail2::stCheckReverseTrain; // Trackdir, forbid 90-deg
}
@@ -341,7 +341,7 @@ bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_pe
PfnFindNearestDepotTwoWay pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail1::stFindNearestDepotTwoWay;
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg) {
+ if (_settings.pf.forbid_90_deg) {
pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail2::stFindNearestDepotTwoWay; // Trackdir, forbid 90-deg
}
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index 8f775bc3c..6234a7e63 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -407,7 +407,7 @@ Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir)
PfnChooseRoadTrack pfnChooseRoadTrack = &CYapfRoad2::stChooseRoadTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type should be used
- if (_patches.yapf.disable_node_optimization)
+ if (_settings.pf.yapf.disable_node_optimization)
pfnChooseRoadTrack = &CYapfRoad1::stChooseRoadTrack; // Trackdir, allow 90-deg
Trackdir td_ret = pfnChooseRoadTrack(v, tile, enterdir);
@@ -421,7 +421,7 @@ uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile)
PfnDistanceToTile pfnDistanceToTile = &CYapfRoad2::stDistanceToTile; // default: ExitDir, allow 90-deg
// check if non-default YAPF type should be used
- if (_patches.yapf.disable_node_optimization)
+ if (_settings.pf.yapf.disable_node_optimization)
pfnDistanceToTile = &CYapfRoad1::stDistanceToTile; // Trackdir, allow 90-deg
// measure distance in YAPF units
@@ -450,7 +450,7 @@ Depot* YapfFindNearestRoadDepot(const Vehicle *v)
PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot;
// check if non-default YAPF type should be used
- if (_patches.yapf.disable_node_optimization)
+ if (_settings.pf.yapf.disable_node_optimization)
pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg
Depot* ret = pfnFindNearestDepot(v, tile, trackdir);
diff --git a/src/yapf/yapf_settings.h b/src/yapf/yapf_settings.h
deleted file mode 100644
index 18f7947b8..000000000
--- a/src/yapf/yapf_settings.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* $Id$ */
-
-/** @file yapf_settings.h Penalty settings for YAPF. */
-
-#if !defined(YAPF_SETTINGS_H) || defined(YS_DEF)
-
-# ifndef YAPF_SETTINGS_H
-# define YAPF_SETTINGS_H
-# endif
-
-# ifndef YS_DEF
-/*
- * if YS_DEF is not defined, we will only do following declaration:
- * struct YapfSettings {
- * bool disable_node_optimization;
- * uint32 max_search_nodes;
- * .... all other yapf related settings ...
- * };
- *
- * otherwise we will just expand YS_DEF_xx macros and then #undef them
- */
-# define YS_DEF_BEGIN struct YapfSettings {
-# define YS_DEF(type, name) type name;
-# define YS_DEF_END };
-
-# endif /* !YS_DEF */
-
-# ifndef YS_DEF_BEGIN
-# define YS_DEF_BEGIN
-# endif // YS_DEF_BEGIN
-
-# ifndef YS_DEF_END
-# define YS_DEF_END
-# endif // YS_DEF_END
-
-YS_DEF_BEGIN
- YS_DEF(bool , disable_node_optimization) ///< whether to use exit-dir instead of trackdir in node key
- YS_DEF(uint32, max_search_nodes) ///< stop path-finding when this number of nodes visited
- YS_DEF(bool , ship_use_yapf) ///< use YAPF for ships
- YS_DEF(bool , road_use_yapf) ///< use YAPF for road
- YS_DEF(bool , rail_use_yapf) ///< use YAPF for rail
- YS_DEF(uint32, road_slope_penalty) ///< penalty for up-hill slope
- YS_DEF(uint32, road_curve_penalty) ///< penalty for curves
- YS_DEF(uint32, road_crossing_penalty) ///< penalty for level crossing
- YS_DEF(uint32, road_stop_penalty) ///< penalty for going through a drive-through road stop
- YS_DEF(bool , rail_firstred_twoway_eol) ///< treat first red two-way signal as dead end
- YS_DEF(uint32, rail_firstred_penalty) ///< penalty for first red signal
- YS_DEF(uint32, rail_firstred_exit_penalty) ///< penalty for first red exit signal
- YS_DEF(uint32, rail_lastred_penalty) ///< penalty for last red signal
- YS_DEF(uint32, rail_lastred_exit_penalty) ///< penalty for last red exit signal
- YS_DEF(uint32, rail_station_penalty) ///< penalty for non-target station tile
- YS_DEF(uint32, rail_slope_penalty) ///< penalty for up-hill slope
- YS_DEF(uint32, rail_curve45_penalty) ///< penalty for curve
- YS_DEF(uint32, rail_curve90_penalty) ///< penalty for 90-deg curve
- YS_DEF(uint32, rail_depot_reverse_penalty) ///< penalty for reversing in the depot
- YS_DEF(uint32, rail_crossing_penalty) ///< penalty for level crossing
- YS_DEF(uint32, rail_look_ahead_max_signals)///< max. number of signals taken into consideration in look-ahead load balancer
- YS_DEF(int32 , rail_look_ahead_signal_p0) ///< constant in polynomial penalty function
- YS_DEF(int32 , rail_look_ahead_signal_p1) ///< constant in polynomial penalty function
- YS_DEF(int32 , rail_look_ahead_signal_p2) ///< constant in polynomial penalty function
-
- YS_DEF(uint32, rail_longer_platform_penalty) ///< penalty for longer station platform than train
- YS_DEF(uint32, rail_longer_platform_per_tile_penalty) ///< penalty for longer station platform than train (per tile)
- YS_DEF(uint32, rail_shorter_platform_penalty) ///< penalty for shorter station platform than train
- YS_DEF(uint32, rail_shorter_platform_per_tile_penalty) ///< penalty for shorter station platform than train (per tile)
-YS_DEF_END
-
-#undef YS_DEF_BEGIN
-#undef YS_DEF
-#undef YS_DEF_END
-
-#endif /* !YAPF_SETTINGS_H || YS_DEF */
diff --git a/src/yapf/yapf_ship.cpp b/src/yapf/yapf_ship.cpp
index 9a6f57123..bd433d84d 100644
--- a/src/yapf/yapf_ship.cpp
+++ b/src/yapf/yapf_ship.cpp
@@ -154,9 +154,9 @@ Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir,
PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg)
+ if (_settings.pf.forbid_90_deg)
pfnChooseShipTrack = &CYapfShip3::ChooseShipTrack; // Trackdir, forbid 90-deg
- else if (_patches.yapf.disable_node_optimization)
+ else if (_settings.pf.yapf.disable_node_optimization)
pfnChooseShipTrack = &CYapfShip1::ChooseShipTrack; // Trackdir, allow 90-deg
Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks);