1
0
Fork 0

(svn r13357) -Codechange: add constness to YAPF.

release/0.7
rubidium 2008-06-02 06:44:06 +00:00
parent 10b494d260
commit 3efece1284
8 changed files with 48 additions and 46 deletions

View File

@ -22,7 +22,7 @@ struct CFollowTrackT
EC_NO_WAY, 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 TileIndex m_old_tile; ///< the origin (vehicle moved from) before move
Trackdir m_old_td; ///< the trackdir (the vehicle was on) 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) 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 bool m_is_station; ///< last turn passed station
int m_tiles_skipped; ///< number of skipped tunnel or station tiles int m_tiles_skipped; ///< number of skipped tunnel or station tiles
ErrorCode m_err; 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); 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)); assert(!IsRailTT() || (v != NULL && v->type == VEH_TRAIN));
m_veh = v; m_veh = v;

View File

@ -16,7 +16,7 @@
* @param tracks available tracks on the new tile (to choose from) * @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 * @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. /** Finds the best path for given road vehicle.
* @param v the RV that needs to find a path * @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 * @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 * @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. /** Finds the best path for given train.
* @param v the train that needs to find a path * @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') * @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 * @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. /** 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) * @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 * @param reversed receives true if train needs to reversed first
* @return the true if depot was found. * @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 */ /** 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 */ /** Use this function to notify YAPF that track layout (or signal configuration) has change */
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track); void YapfNotifyTrackLayoutChange(TileIndex tile, Track track);
/** performance measurement helpers */ /** performance measurement helpers */
void* NpfBeginInterval(); void* NpfBeginInterval();
int NpfEndInterval(void* perf); int NpfEndInterval(void *perf);
extern int _aystar_stats_open_size; extern int _aystar_stats_open_size;

View File

@ -51,11 +51,11 @@ public:
NodeList m_nodes; ///< node list multi-container NodeList m_nodes; ///< node list multi-container
protected: protected:
Node* m_pBestDestNode; ///< pointer to the destination node found at last round 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_pBestIntermediateNode; ///< here should be node closest to the destination if path not found
const YAPFSettings *m_settings; ///< current settings (_settings_game.yapf) 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 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_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 int m_stats_cache_hits; ///< stats - how many node's costs were reused from cache
@ -281,7 +281,7 @@ public:
m_nodes.InsertOpenNode(n); m_nodes.InsertOpenNode(n);
} }
const Vehicle* GetVehicle() const {return m_veh;} const Vehicle * GetVehicle() const {return m_veh;}
void DumpBase(DumpTarget &dmp) const void DumpBase(DumpTarget &dmp) const
{ {

View File

@ -191,7 +191,7 @@ public:
FORCEINLINE int PlatformLengthPenalty(int platform_length) FORCEINLINE int PlatformLengthPenalty(int platform_length)
{ {
int cost = 0; int cost = 0;
const Vehicle* v = Yapf().GetVehicle(); const Vehicle *v = Yapf().GetVehicle();
assert(v != NULL); assert(v != NULL);
assert(v->type == VEH_TRAIN); assert(v->type == VEH_TRAIN);
assert(v->u.rail.cached_total_length != 0); assert(v->u.rail.cached_total_length != 0);
@ -261,7 +261,7 @@ public:
int segment_entry_cost = 0; int segment_entry_cost = 0;
int segment_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 // 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); TILE cur(n.m_key.m_tile, n.m_key.m_td);

View File

@ -11,7 +11,7 @@ protected:
RailTypes m_compatible_railtypes; RailTypes m_compatible_railtypes;
public: public:
void SetDestination(Vehicle* v) void SetDestination(const Vehicle* v)
{ {
m_compatible_railtypes = v->u.rail.compatible_railtypes; m_compatible_railtypes = v->u.rail.compatible_railtypes;
} }
@ -84,7 +84,7 @@ protected:
} }
public: public:
void SetDestination(Vehicle* v) void SetDestination(const Vehicle* v)
{ {
switch (v->current_order.GetType()) { switch (v->current_order.GetType()) {
case OT_GOTO_STATION: case OT_GOTO_STATION:

View File

@ -45,7 +45,7 @@ public:
/// return debug report character to identify the transportation type /// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 't';} 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; Tpf pf1;
bool result1 = pf1.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, depot_tile, reversed); bool result1 = pf1.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, depot_tile, reversed);
@ -64,7 +64,7 @@ public:
return result1; 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 // set origin and destination nodes
Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true); Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true);
@ -121,7 +121,7 @@ public:
/// return debug report character to identify the transportation type /// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 't';} 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 // create pathfinder instance
Tpf pf1; Tpf pf1;
@ -148,7 +148,7 @@ public:
return result1; 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 // set origin and destination nodes
Yapf().SetOrigin(v->tile, GetVehicleTrackdir(v), INVALID_TILE, INVALID_TRACKDIR, 1, true); Yapf().SetOrigin(v->tile, GetVehicleTrackdir(v), INVALID_TILE, INVALID_TRACKDIR, 1, true);
@ -181,7 +181,7 @@ public:
return next_trackdir; 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; Tpf pf1;
bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty); bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
@ -198,7 +198,7 @@ public:
return result1; 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 // create pathfinder instance
// set origin and destination nodes // 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> > {}; 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 // 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; PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
// check if non-default YAPF type needed // check if non-default YAPF type needed
@ -263,10 +263,10 @@ Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir,
return td_ret; return td_ret;
} }
bool YapfCheckReverseTrain(Vehicle* v) bool YapfCheckReverseTrain(const Vehicle* v)
{ {
/* last wagon */ /* last wagon */
Vehicle* last_veh = GetLastVehicleInChain(v); const Vehicle *last_veh = GetLastVehicleInChain(v);
// get trackdirs of both ends // get trackdirs of both ends
Trackdir td = GetVehicleTrackdir(v); Trackdir td = GetVehicleTrackdir(v);
@ -307,7 +307,7 @@ bool YapfCheckReverseTrain(Vehicle* v)
reverse_penalty += DistanceManhattan(cur_tile, tile_rev) * YAPF_TILE_LENGTH; 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; PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
// check if non-default YAPF type needed // check if non-default YAPF type needed
@ -323,12 +323,12 @@ bool YapfCheckReverseTrain(Vehicle* v)
return reverse; 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; *depot_tile = INVALID_TILE;
*reversed = false; *reversed = false;
Vehicle* last_veh = GetLastVehicleInChain(v); const Vehicle *last_veh = GetLastVehicleInChain(v);
TileIndex tile = v->tile; TileIndex tile = v->tile;
TileIndex last_tile = last_veh->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 = GetVehicleTrackdir(v);
Trackdir td_rev = ReverseTrackdir(GetVehicleTrackdir(last_veh)); 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; PfnFindNearestDepotTwoWay pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail1::stFindNearestDepotTwoWay;
// check if non-default YAPF type needed // check if non-default YAPF type needed

View File

@ -83,7 +83,7 @@ public:
// base tile cost depending on distance between edges // base tile cost depending on distance between edges
segment_cost += Yapf().OneTileCost(tile, trackdir); 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 // 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; 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 /// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 'r';} 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; Tpf pf;
return pf.ChooseRoadTrack(v, tile, enterdir); 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 // handle special case - when next tile is destination tile
if (tile == v->dest_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> > {}; 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 // 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 PfnChooseRoadTrack pfnChooseRoadTrack = &CYapfRoad2::stChooseRoadTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type should be used // 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 pfnChooseRoadTrack = &CYapfRoad1::stChooseRoadTrack; // Trackdir, allow 90-deg
}
Trackdir td_ret = pfnChooseRoadTrack(v, tile, enterdir); Trackdir td_ret = pfnChooseRoadTrack(v, tile, enterdir);
return td_ret; return td_ret;
} }
uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile) uint YapfRoadVehDistanceToTile(const Vehicle *v, TileIndex tile)
{ {
// default is YAPF type 2 // default is YAPF type 2
typedef uint (*PfnDistanceToTile)(const Vehicle*, TileIndex); typedef uint (*PfnDistanceToTile)(const Vehicle*, TileIndex);

View File

@ -34,7 +34,7 @@ public:
/// return debug report character to identify the transportation type /// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 'w';} 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 // handle special case - when next tile is destination tile
if (tile == v->dest_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> > {}; struct CYapfShip3 : CYapfT<CYapfShip_TypesT<CYapfShip3, CFollowTrackWaterNo90, CShipNodeListTrackDir> > {};
/** Ship controller helper - path finder invoker */ /** 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 // 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 PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type needed // 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 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 pfnChooseShipTrack = &CYapfShip1::ChooseShipTrack; // Trackdir, allow 90-deg
}
Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks); Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks);
return td_ret; return td_ret;
} }
/** performance measurement helper */ /** performance measurement helper */
void* NpfBeginInterval() void * NpfBeginInterval()
{ {
CPerformanceTimer& perf = *new CPerformanceTimer; CPerformanceTimer& perf = *new CPerformanceTimer;
perf.Start(); perf.Start();
@ -172,7 +173,7 @@ void* NpfBeginInterval()
} }
/** performance measurement helper */ /** performance measurement helper */
int NpfEndInterval(void* vperf) int NpfEndInterval(void *vperf)
{ {
CPerformanceTimer& perf = *(CPerformanceTimer*)vperf; CPerformanceTimer& perf = *(CPerformanceTimer*)vperf;
perf.Stop(); perf.Stop();