summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-06-02 06:44:06 +0000
committerrubidium <rubidium@openttd.org>2008-06-02 06:44:06 +0000
commit3efece128469f5bcee86e350f910c9efe40ff2f6 (patch)
treef0769372f37b0f18b63ea52080267ad955972437 /src
parent10b494d260ca14b77ff18048c02c61d6e805d824 (diff)
downloadopenttd-3efece128469f5bcee86e350f910c9efe40ff2f6.tar.xz
(svn r13357) -Codechange: add constness to YAPF.
Diffstat (limited to 'src')
-rw-r--r--src/yapf/follow_track.hpp8
-rw-r--r--src/yapf/yapf.h12
-rw-r--r--src/yapf/yapf_base.hpp8
-rw-r--r--src/yapf/yapf_costrail.hpp4
-rw-r--r--src/yapf/yapf_destrail.hpp4
-rw-r--r--src/yapf/yapf_rail.cpp28
-rw-r--r--src/yapf/yapf_road.cpp15
-rw-r--r--src/yapf/yapf_ship.cpp15
8 files changed, 48 insertions, 46 deletions
diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp
index e72d9deda..362a3d355 100644
--- a/src/yapf/follow_track.hpp
+++ b/src/yapf/follow_track.hpp
@@ -22,7 +22,7 @@ struct CFollowTrackT
EC_NO_WAY,
};
- const Vehicle* m_veh; ///< moving vehicle
+ const Vehicle *m_veh; ///< moving vehicle
TileIndex m_old_tile; ///< the origin (vehicle moved from) before move
Trackdir m_old_td; ///< the trackdir (the vehicle was on) before move
TileIndex m_new_tile; ///< the new tile (the vehicle has entered)
@@ -33,14 +33,14 @@ struct CFollowTrackT
bool m_is_station; ///< last turn passed station
int m_tiles_skipped; ///< number of skipped tunnel or station tiles
ErrorCode m_err;
- CPerformanceTimer* m_pPerf;
+ CPerformanceTimer *m_pPerf;
- FORCEINLINE CFollowTrackT(const Vehicle* v = NULL, CPerformanceTimer* pPerf = NULL)
+ FORCEINLINE CFollowTrackT(const Vehicle *v = NULL, CPerformanceTimer* pPerf = NULL)
{
Init(v, pPerf);
}
- FORCEINLINE void Init(const Vehicle* v, CPerformanceTimer* pPerf)
+ FORCEINLINE void Init(const Vehicle *v, CPerformanceTimer* pPerf)
{
assert(!IsRailTT() || (v != NULL && v->type == VEH_TRAIN));
m_veh = v;
diff --git a/src/yapf/yapf.h b/src/yapf/yapf.h
index a4c435fcf..ca400a754 100644
--- a/src/yapf/yapf.h
+++ b/src/yapf/yapf.h
@@ -16,7 +16,7 @@
* @param tracks available tracks on the new tile (to choose from)
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/
-Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
+Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
/** Finds the best path for given road vehicle.
* @param v the RV that needs to find a path
@@ -24,7 +24,7 @@ Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir,
* @param enterdir diagonal direction which the RV will enter this new tile from
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/
-Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir);
+Trackdir YapfChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir);
/** Finds the best path for given train.
* @param v the train that needs to find a path
@@ -34,7 +34,7 @@ Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir)
* @param path_not_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess')
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/
-Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found);
+Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found);
/** Used by RV multistop feature to find the nearest road stop that has a free slot.
* @param v RV (its current tile will be the origin)
@@ -58,17 +58,17 @@ Depot* YapfFindNearestRoadDepot(const Vehicle *v);
* @param reversed receives true if train needs to reversed first
* @return the true if depot was found.
*/
-bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed);
+bool YapfFindNearestRailDepotTwoWay(const Vehicle *v, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed);
/** Returns true if it is better to reverse the train before leaving station */
-bool YapfCheckReverseTrain(Vehicle* v);
+bool YapfCheckReverseTrain(const Vehicle* v);
/** Use this function to notify YAPF that track layout (or signal configuration) has change */
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track);
/** performance measurement helpers */
void* NpfBeginInterval();
-int NpfEndInterval(void* perf);
+int NpfEndInterval(void *perf);
extern int _aystar_stats_open_size;
diff --git a/src/yapf/yapf_base.hpp b/src/yapf/yapf_base.hpp
index d31e2fb9e..f09a97d61 100644
--- a/src/yapf/yapf_base.hpp
+++ b/src/yapf/yapf_base.hpp
@@ -51,11 +51,11 @@ public:
NodeList m_nodes; ///< node list multi-container
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
+ 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 (_settings_game.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
+ const Vehicle *m_veh; ///< vehicle that we are trying to drive
int m_stats_cost_calcs; ///< stats - how many node's costs were calculated
int m_stats_cache_hits; ///< stats - how many node's costs were reused from cache
@@ -281,7 +281,7 @@ public:
m_nodes.InsertOpenNode(n);
}
- const Vehicle* GetVehicle() const {return m_veh;}
+ const Vehicle * GetVehicle() const {return m_veh;}
void DumpBase(DumpTarget &dmp) const
{
diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp
index eaba2fe80..abd421068 100644
--- a/src/yapf/yapf_costrail.hpp
+++ b/src/yapf/yapf_costrail.hpp
@@ -191,7 +191,7 @@ public:
FORCEINLINE int PlatformLengthPenalty(int platform_length)
{
int cost = 0;
- const Vehicle* v = Yapf().GetVehicle();
+ const Vehicle *v = Yapf().GetVehicle();
assert(v != NULL);
assert(v->type == VEH_TRAIN);
assert(v->u.rail.cached_total_length != 0);
@@ -261,7 +261,7 @@ public:
int segment_entry_cost = 0;
int segment_cost = 0;
- const Vehicle* v = Yapf().GetVehicle();
+ const Vehicle *v = Yapf().GetVehicle();
// start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment
TILE cur(n.m_key.m_tile, n.m_key.m_td);
diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp
index b648642cf..aba409419 100644
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -11,7 +11,7 @@ protected:
RailTypes m_compatible_railtypes;
public:
- void SetDestination(Vehicle* v)
+ void SetDestination(const Vehicle* v)
{
m_compatible_railtypes = v->u.rail.compatible_railtypes;
}
@@ -84,7 +84,7 @@ protected:
}
public:
- void SetDestination(Vehicle* v)
+ void SetDestination(const Vehicle* v)
{
switch (v->current_order.GetType()) {
case OT_GOTO_STATION:
diff --git a/src/yapf/yapf_rail.cpp b/src/yapf/yapf_rail.cpp
index d5d95f435..7d7d4ee38 100644
--- a/src/yapf/yapf_rail.cpp
+++ b/src/yapf/yapf_rail.cpp
@@ -45,7 +45,7 @@ public:
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 't';}
- static bool stFindNearestDepotTwoWay(Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
+ static bool stFindNearestDepotTwoWay(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
{
Tpf pf1;
bool result1 = pf1.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, depot_tile, reversed);
@@ -64,7 +64,7 @@ public:
return result1;
}
- FORCEINLINE bool FindNearestDepotTwoWay(Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
+ FORCEINLINE bool FindNearestDepotTwoWay(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
{
// set origin and destination nodes
Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true);
@@ -121,7 +121,7 @@ public:
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 't';}
- static Trackdir stChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
+ static Trackdir stChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
{
// create pathfinder instance
Tpf pf1;
@@ -148,7 +148,7 @@ public:
return result1;
}
- FORCEINLINE Trackdir ChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
+ FORCEINLINE Trackdir ChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
{
// set origin and destination nodes
Yapf().SetOrigin(v->tile, GetVehicleTrackdir(v), INVALID_TILE, INVALID_TRACKDIR, 1, true);
@@ -181,7 +181,7 @@ public:
return next_trackdir;
}
- static bool stCheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
+ static bool stCheckReverseTrain(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
{
Tpf pf1;
bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
@@ -198,7 +198,7 @@ public:
return result1;
}
- FORCEINLINE bool CheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
+ FORCEINLINE bool CheckReverseTrain(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
{
// create pathfinder instance
// set origin and destination nodes
@@ -247,10 +247,10 @@ struct CYapfAnyDepotRail1 : CYapfT<CYapfRail_TypesT<CYapfAnyDepotRail1, CFollowT
struct CYapfAnyDepotRail2 : CYapfT<CYapfRail_TypesT<CYapfAnyDepotRail2, CFollowTrackRailNo90, CRailNodeListTrackDir, CYapfDestinationAnyDepotRailT , CYapfFollowAnyDepotRailT> > {};
-Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
+Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
{
// default is YAPF type 2
- typedef Trackdir (*PfnChooseRailTrack)(Vehicle*, TileIndex, DiagDirection, TrackBits, bool*);
+ typedef Trackdir (*PfnChooseRailTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits, bool*);
PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
// check if non-default YAPF type needed
@@ -263,10 +263,10 @@ Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir,
return td_ret;
}
-bool YapfCheckReverseTrain(Vehicle* v)
+bool YapfCheckReverseTrain(const Vehicle* v)
{
/* last wagon */
- Vehicle* last_veh = GetLastVehicleInChain(v);
+ const Vehicle *last_veh = GetLastVehicleInChain(v);
// get trackdirs of both ends
Trackdir td = GetVehicleTrackdir(v);
@@ -307,7 +307,7 @@ bool YapfCheckReverseTrain(Vehicle* v)
reverse_penalty += DistanceManhattan(cur_tile, tile_rev) * YAPF_TILE_LENGTH;
}
- typedef bool (*PfnCheckReverseTrain)(Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int);
+ typedef bool (*PfnCheckReverseTrain)(const Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int);
PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
// check if non-default YAPF type needed
@@ -323,12 +323,12 @@ bool YapfCheckReverseTrain(Vehicle* v)
return reverse;
}
-bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
+bool YapfFindNearestRailDepotTwoWay(const Vehicle *v, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
{
*depot_tile = INVALID_TILE;
*reversed = false;
- Vehicle* last_veh = GetLastVehicleInChain(v);
+ const Vehicle *last_veh = GetLastVehicleInChain(v);
TileIndex tile = v->tile;
TileIndex last_tile = last_veh->tile;
@@ -337,7 +337,7 @@ bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_pe
Trackdir td = GetVehicleTrackdir(v);
Trackdir td_rev = ReverseTrackdir(GetVehicleTrackdir(last_veh));
- typedef bool (*PfnFindNearestDepotTwoWay)(Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int, int, TileIndex*, bool*);
+ typedef bool (*PfnFindNearestDepotTwoWay)(const Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int, int, TileIndex*, bool*);
PfnFindNearestDepotTwoWay pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail1::stFindNearestDepotTwoWay;
// check if non-default YAPF type needed
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index a925ba280..c9422c903 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -83,7 +83,7 @@ public:
// base tile cost depending on distance between edges
segment_cost += Yapf().OneTileCost(tile, trackdir);
- const Vehicle* v = Yapf().GetVehicle();
+ const Vehicle *v = Yapf().GetVehicle();
// we have reached the vehicle's destination - segment should end here to avoid target skipping
if (v->current_order.IsType(OT_GOTO_STATION) && tile == v->dest_tile) break;
@@ -253,13 +253,13 @@ public:
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 'r';}
- static Trackdir stChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir)
+ static Trackdir stChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir)
{
Tpf pf;
return pf.ChooseRoadTrack(v, tile, enterdir);
}
- FORCEINLINE Trackdir ChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir)
+ FORCEINLINE Trackdir ChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir)
{
// handle special case - when next tile is destination tile
if (tile == v->dest_tile) {
@@ -400,21 +400,22 @@ struct CYapfRoadAnyDepot1 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot1, CRoadNod
struct CYapfRoadAnyDepot2 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot2, CRoadNodeListExitDir , CYapfDestinationAnyDepotRoadT> > {};
-Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir)
+Trackdir YapfChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir)
{
// default is YAPF type 2
- typedef Trackdir (*PfnChooseRoadTrack)(Vehicle*, TileIndex, DiagDirection);
+ typedef Trackdir (*PfnChooseRoadTrack)(const Vehicle*, TileIndex, DiagDirection);
PfnChooseRoadTrack pfnChooseRoadTrack = &CYapfRoad2::stChooseRoadTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type should be used
- if (_settings_game.pf.yapf.disable_node_optimization)
+ if (_settings_game.pf.yapf.disable_node_optimization) {
pfnChooseRoadTrack = &CYapfRoad1::stChooseRoadTrack; // Trackdir, allow 90-deg
+ }
Trackdir td_ret = pfnChooseRoadTrack(v, tile, enterdir);
return td_ret;
}
-uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile)
+uint YapfRoadVehDistanceToTile(const Vehicle *v, TileIndex tile)
{
// default is YAPF type 2
typedef uint (*PfnDistanceToTile)(const Vehicle*, TileIndex);
diff --git a/src/yapf/yapf_ship.cpp b/src/yapf/yapf_ship.cpp
index 11a4f1e57..bf8d00e64 100644
--- a/src/yapf/yapf_ship.cpp
+++ b/src/yapf/yapf_ship.cpp
@@ -34,7 +34,7 @@ public:
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 'w';}
- static Trackdir ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
+ static Trackdir ChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
{
// handle special case - when next tile is destination tile
if (tile == v->dest_tile) {
@@ -147,24 +147,25 @@ struct CYapfShip2 : CYapfT<CYapfShip_TypesT<CYapfShip2, CFollowTrackWater , C
struct CYapfShip3 : CYapfT<CYapfShip_TypesT<CYapfShip3, CFollowTrackWaterNo90, CShipNodeListTrackDir> > {};
/** Ship controller helper - path finder invoker */
-Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
+Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
{
// default is YAPF type 2
- typedef Trackdir (*PfnChooseShipTrack)(Vehicle*, TileIndex, DiagDirection, TrackBits);
+ typedef Trackdir (*PfnChooseShipTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits);
PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type needed
- if (_settings_game.pf.forbid_90_deg)
+ if (_settings_game.pf.forbid_90_deg) {
pfnChooseShipTrack = &CYapfShip3::ChooseShipTrack; // Trackdir, forbid 90-deg
- else if (_settings_game.pf.yapf.disable_node_optimization)
+ } else if (_settings_game.pf.yapf.disable_node_optimization) {
pfnChooseShipTrack = &CYapfShip1::ChooseShipTrack; // Trackdir, allow 90-deg
+ }
Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks);
return td_ret;
}
/** performance measurement helper */
-void* NpfBeginInterval()
+void * NpfBeginInterval()
{
CPerformanceTimer& perf = *new CPerformanceTimer;
perf.Start();
@@ -172,7 +173,7 @@ void* NpfBeginInterval()
}
/** performance measurement helper */
-int NpfEndInterval(void* vperf)
+int NpfEndInterval(void *vperf)
{
CPerformanceTimer& perf = *(CPerformanceTimer*)vperf;
perf.Stop();