(svn r15609) -Fix: Code style...

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
peter1138 15 years ago
parent 0682c1c46c
commit f0de54bc10

@ -46,28 +46,41 @@ public:
{
m_new_node = NULL;
}
/** destructor */
~CNodeList_HashTableT()
{
}
/** return number of open nodes */
FORCEINLINE int OpenCount() {return m_open.Count();}
FORCEINLINE int OpenCount()
{
return m_open.Count();
}
/** return number of closed nodes */
FORCEINLINE int ClosedCount() {return m_closed.Count();}
FORCEINLINE int ClosedCount()
{
return m_closed.Count();
}
/** allocate new data item from m_arr */
FORCEINLINE Titem_ *CreateNewNode()
{
if (m_new_node == NULL) m_new_node = &m_arr.Add();
return m_new_node;
}
/** notify the nodelist, that we don't want to discard the given node */
FORCEINLINE void FoundBestNode(Titem_& item)
{
// for now it is enough to invalidate m_new_node if it is our given node
if (&item == m_new_node)
if (&item == m_new_node) {
m_new_node = NULL;
}
// TODO: do we need to store best nodes found in some extra list/array? Probably not now.
}
/** insert given item as open node (into m_open and m_open_queue) */
FORCEINLINE void InsertOpenNode(Titem_& item)
{
@ -76,9 +89,11 @@ public:
// TODO: check if m_open_queue is not full
assert(!m_open_queue.IsFull());
m_open_queue.Push(item);
if (&item == m_new_node)
if (&item == m_new_node) {
m_new_node = NULL;
}
}
/** return the best open node */
FORCEINLINE Titem_ *GetBestOpenNode()
{
@ -88,6 +103,7 @@ public:
}
return NULL;
}
/** remove and return the best open node */
FORCEINLINE Titem_ *PopBestOpenNode()
{
@ -98,12 +114,14 @@ public:
}
return NULL;
}
/** return the open node specified by a key or NULL if not found */
FORCEINLINE Titem_ *FindOpenNode(const Key& key)
{
Titem_ *item = m_open.Find(key);
return item;
}
/** remove and return the open node specified by a key */
FORCEINLINE Titem_& PopOpenNode(const Key& key)
{
@ -112,12 +130,14 @@ public:
m_open_queue.RemoveByIdx(idxPop);
return item;
}
/** close node */
FORCEINLINE void InsertClosedNode(Titem_& item)
{
assert(m_open.Find(item.GetKey()) == NULL);
m_closed.Push(item);
}
/** return the closed node specified by a key or NULL if not found */
FORCEINLINE Titem_ *FindClosedNode(const Key& key)
{

@ -41,21 +41,53 @@ struct CPerformanceTimer
CPerformanceTimer() : m_start(0), m_acc(0) {}
FORCEINLINE void Start() {m_start = QueryTime();}
FORCEINLINE void Stop() {m_acc += QueryTime() - m_start;}
FORCEINLINE int Get(int64 coef) {return (int)(m_acc * coef / QueryFrequency());}
FORCEINLINE int64 QueryTime() {return ottd_rdtsc();}
FORCEINLINE int64 QueryFrequency() {return ((int64)2200 * 1000000);}
FORCEINLINE void Start()
{
m_start = QueryTime();
}
FORCEINLINE void Stop()
{
m_acc += QueryTime() - m_start;
}
FORCEINLINE int Get(int64 coef)
{
return (int)(m_acc * coef / QueryFrequency());
}
FORCEINLINE int64 QueryTime()
{
return ottd_rdtsc();
}
FORCEINLINE int64 QueryFrequency()
{
return ((int64)2200 * 1000000);
}
};
struct CPerfStartReal
{
CPerformanceTimer *m_pperf;
FORCEINLINE CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf) {if (m_pperf != NULL) m_pperf->Start();}
FORCEINLINE ~CPerfStartReal() {Stop();}
FORCEINLINE void Stop() {if (m_pperf != NULL) {m_pperf->Stop(); m_pperf = NULL;}}
FORCEINLINE CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf)
{
if (m_pperf != NULL) m_pperf->Start();
}
FORCEINLINE ~CPerfStartReal()
{
Stop();
}
FORCEINLINE void Stop()
{
if (m_pperf != NULL) {
m_pperf->Stop();
m_pperf = NULL;
}
}
};
struct CPerfStartFake

@ -88,7 +88,10 @@ public:
protected:
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/// return current settings (can be custom - company based - but later)
@ -118,12 +121,14 @@ public:
while (true) {
m_num_steps++;
Node *n = m_nodes.GetBestOpenNode();
if (n == NULL)
if (n == NULL) {
break;
}
// if the best open node was worse than the best path found, we can finish
if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate())
if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate()) {
break;
}
Yapf().PfFollowNode(*n);
if (m_max_search_nodes == 0 || m_nodes.ClosedCount() < m_max_search_nodes) {
@ -281,7 +286,10 @@ public:
m_nodes.InsertOpenNode(n);
}
const Vehicle * GetVehicle() const {return m_veh;}
const Vehicle * GetVehicle() const
{
return m_veh;
}
void DumpBase(DumpTarget &dmp) const
{

@ -19,7 +19,10 @@ protected:
TrackdirBits m_orgTrackdirs; ///< origin trackdir mask
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/// Set origin tile / trackdir mask
@ -60,7 +63,10 @@ protected:
bool m_treat_first_red_two_way_signal_as_eol; ///< in some cases (leaving station) we need to handle first two-way signal differently
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/// set origin (tiles, trackdirs, etc.)
@ -120,7 +126,10 @@ public:
protected:
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/// Called by YAPF to detect if node ends in the desired destination

@ -11,7 +11,7 @@ struct CYapfCostBase {
if (IsDiagonalTrackdir(td)) {
if (IsBridgeTile(tile)) {
// it is bridge ramp, check if we are entering the bridge
if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty
if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are leaving it, no penalty
// we are entering the bridge
Slope tile_slope = GetTileSlope(tile, NULL);
Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));

@ -23,13 +23,13 @@ public:
FORCEINLINE bool PfNodeCacheFetch(Node& n)
{
return false;
};
}
/** Called by YAPF to flush the cached segment cost data back into cache storage.
* Current cache implementation doesn't use that. */
FORCEINLINE void PfNodeCacheFlush(Node& n)
{
};
}
};
@ -52,7 +52,10 @@ protected:
LocalCache m_local_cache;
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/** Called by YAPF to attach cached or local segment cost data to the given node.
@ -62,13 +65,13 @@ public:
CacheKey key(n.GetKey());
Yapf().ConnectNodeToCachedData(n, *new (&m_local_cache.AddNC()) CachedData(key));
return false;
};
}
/** Called by YAPF to flush the cached segment cost data back into cache storage.
* Current cache implementation doesn't use that. */
FORCEINLINE void PfNodeCacheFlush(Node& n)
{
};
}
};
@ -81,7 +84,10 @@ struct CSegmentCostCacheBase
{
static int s_rail_change_counter;
static void NotifyTrackLayoutChange(TileIndex tile, Track track) {s_rail_change_counter++;}
static void NotifyTrackLayoutChange(TileIndex tile, Track track)
{
s_rail_change_counter++;
}
};
@ -109,7 +115,11 @@ struct CSegmentCostCacheT
FORCEINLINE CSegmentCostCacheT() {}
/** flush (clear) the cache */
FORCEINLINE void Flush() {m_map.Clear(); m_heap.Clear();};
FORCEINLINE void Flush()
{
m_map.Clear();
m_heap.Clear();
}
FORCEINLINE Tsegment& Get(Key& key, bool *found)
{
@ -148,7 +158,10 @@ protected:
FORCEINLINE CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {};
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
FORCEINLINE static Cache& stGetGlobalCache()
{
@ -184,17 +197,13 @@ public:
CachedData& item = m_global_cache.Get(key, &found);
Yapf().ConnectNodeToCachedData(n, item);
return found;
};
}
/** Called by YAPF to flush the cached segment cost data back into cache storage.
* Current cache implementation doesn't use that. */
FORCEINLINE void PfNodeCacheFlush(Node& n)
{
};
}
};
#endif /* YAPF_COSTCACHE_HPP */

@ -74,12 +74,16 @@ protected:
int p1 = Yapf().PfGetSettings().rail_look_ahead_signal_p1;
int p2 = Yapf().PfGetSettings().rail_look_ahead_signal_p2;
int *pen = m_sig_look_ahead_costs.GrowSizeNC(Yapf().PfGetSettings().rail_look_ahead_max_signals);
for (uint i = 0; i < Yapf().PfGetSettings().rail_look_ahead_max_signals; i++)
for (uint i = 0; i < Yapf().PfGetSettings().rail_look_ahead_max_signals; i++) {
pen[i] = p0 + i * (p1 + i * p2);
}
}
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
FORCEINLINE int SlopeCost(TileIndex tile, Trackdir td)
@ -125,8 +129,9 @@ public:
switch (GetTileType(tile)) {
case MP_ROAD:
/* Increase the cost for level crossings */
if (IsLevelCrossing(tile))
if (IsLevelCrossing(tile)) {
cost += Yapf().PfGetSettings().rail_crossing_penalty;
}
break;
default:
@ -215,7 +220,7 @@ public:
case SIGTYPE_NORMAL:
case SIGTYPE_ENTRY: cost += Yapf().PfGetSettings().rail_firstred_penalty; break;
default: break;
};
}
}
}
@ -251,9 +256,10 @@ public:
}
public:
FORCEINLINE void SetMaxCost(int max_cost) {m_max_cost = max_cost;}
FORCEINLINE void SetMaxCost(int max_cost)
{
m_max_cost = max_cost;
}
/** Called by YAPF to calculate the cost from the origin to the given node.
* Calculates only the cost of given node, adds it to the parent node cost
@ -412,10 +418,12 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
{
int min_speed = 0;
int max_speed = tf->GetSpeedLimit(&min_speed);
if (max_speed < v->max_speed)
if (max_speed < v->max_speed) {
extra_cost += YAPF_TILE_LENGTH * (v->max_speed - max_speed) * (4 + tf->m_tiles_skipped) / v->max_speed;
if (min_speed > v->max_speed)
}
if (min_speed > v->max_speed) {
extra_cost += YAPF_TILE_LENGTH * (min_speed - v->max_speed);
}
}
/* Finish if we already exceeded the maximum path cost (i.e. when
@ -569,6 +577,4 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
}
};
#endif /* YAPF_COSTRAIL_HPP */

@ -38,7 +38,10 @@ public:
typedef typename Node::Key Key; ///< key to hash tables
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
/// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(Node& n)
@ -73,7 +76,10 @@ public:
typedef typename Types::TrackFollower TrackFollower; ///< TrackFollower. Need to typedef for gcc 2.95
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
/// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(Node& n)
@ -113,7 +119,10 @@ protected:
StationID m_dest_station_id;
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
void SetDestination(const Vehicle *v)
@ -200,5 +209,4 @@ public:
}
};
#endif /* YAPF_DESTRAIL_HPP */

@ -11,15 +11,41 @@ struct CYapfRailSegmentKey
uint32 m_value;
FORCEINLINE CYapfRailSegmentKey(const CYapfRailSegmentKey& src) : m_value(src.m_value) {}
FORCEINLINE CYapfRailSegmentKey(const CYapfNodeKeyTrackDir& node_key) {Set(node_key);}
FORCEINLINE void Set(const CYapfRailSegmentKey& src) {m_value = src.m_value;}
FORCEINLINE void Set(const CYapfNodeKeyTrackDir& node_key) {m_value = (((int)node_key.m_tile) << 4) | node_key.m_td;}
FORCEINLINE CYapfRailSegmentKey(const CYapfNodeKeyTrackDir& node_key)
{
Set(node_key);
}
FORCEINLINE void Set(const CYapfRailSegmentKey& src)
{
m_value = src.m_value;
}
FORCEINLINE void Set(const CYapfNodeKeyTrackDir& node_key)
{
m_value = (((int)node_key.m_tile) << 4) | node_key.m_td;
}
FORCEINLINE int32 CalcHash() const
{
return m_value;
}
FORCEINLINE TileIndex GetTile() const
{
return (TileIndex)(m_value >> 4);
}
FORCEINLINE Trackdir GetTrackdir() const
{
return (Trackdir)(m_value & 0x0F);
}
FORCEINLINE int32 CalcHash() const {return m_value;}
FORCEINLINE TileIndex GetTile() const {return (TileIndex)(m_value >> 4);}
FORCEINLINE Trackdir GetTrackdir() const {return (Trackdir)(m_value & 0x0F);}
FORCEINLINE bool operator == (const CYapfRailSegmentKey& other) const {return m_value == other.m_value;}
FORCEINLINE bool operator == (const CYapfRailSegmentKey& other) const
{
return m_value == other.m_value;
}
void Dump(DumpTarget &dmp) const
{
@ -122,10 +148,25 @@ struct CYapfRailSegment
, m_hash_next(NULL)
{}
FORCEINLINE const Key& GetKey() const {return m_key;}
FORCEINLINE TileIndex GetTile() const {return m_key.GetTile();}
FORCEINLINE CYapfRailSegment *GetHashNext() {return m_hash_next;}
FORCEINLINE void SetHashNext(CYapfRailSegment *next) {m_hash_next = next;}
FORCEINLINE const Key& GetKey() const
{
return m_key;
}
FORCEINLINE TileIndex GetTile() const
{
return m_key.GetTile();
}
FORCEINLINE CYapfRailSegment *GetHashNext()
{
return m_hash_next;
}
FORCEINLINE void SetHashNext(CYapfRailSegment *next)
{
m_hash_next = next;
}
void Dump(DumpTarget &dmp) const
{
@ -175,9 +216,24 @@ struct CYapfRailNodeT
flags_u.flags_s.m_choice_seen |= is_choice;
}
FORCEINLINE TileIndex GetLastTile() const {assert(m_segment != NULL); return m_segment->m_last_tile;}
FORCEINLINE Trackdir GetLastTrackdir() const {assert(m_segment != NULL); return m_segment->m_last_td;}
FORCEINLINE void SetLastTileTrackdir(TileIndex tile, Trackdir td) {assert(m_segment != NULL); m_segment->m_last_tile = tile; m_segment->m_last_td = td;}
FORCEINLINE TileIndex GetLastTile() const
{
assert(m_segment != NULL);
return m_segment->m_last_tile;
}
FORCEINLINE Trackdir GetLastTrackdir() const
{
assert(m_segment != NULL);
return m_segment->m_last_td;
}
FORCEINLINE void SetLastTileTrackdir(TileIndex tile, Trackdir td)
{
assert(m_segment != NULL);
m_segment->m_last_tile = tile;
m_segment->m_last_td = td;
}
template <class Tbase, class Tfunc, class Tpf>
bool IterateTiles(const Vehicle *v, Tpf &yapf, Tbase &obj, bool (Tfunc::*func)(TileIndex, Trackdir)) const
@ -218,6 +274,4 @@ typedef CYapfRailNodeT<CYapfNodeKeyTrackDir> CYapfRailNodeTrackDir;
typedef CNodeList_HashTableT<CYapfRailNodeExitDir , 10, 12> CRailNodeListExitDir;
typedef CNodeList_HashTableT<CYapfRailNodeTrackDir, 12, 16> CRailNodeListTrackDir;
#endif /* YAPF_NODE_RAIL_HPP */

@ -5,8 +5,6 @@
#ifndef YAPF_NODE_ROAD_HPP
#define YAPF_NODE_ROAD_HPP
/** Yapf Node for road YAPF */
template <class Tkey_>
struct CYapfRoadNodeT
@ -33,6 +31,4 @@ typedef CYapfRoadNodeT<CYapfNodeKeyTrackDir> CYapfRoadNodeTrackDir;
typedef CNodeList_HashTableT<CYapfRoadNodeExitDir , 8, 12> CRoadNodeListExitDir;
typedef CNodeList_HashTableT<CYapfRoadNodeTrackDir, 10, 14> CRoadNodeListTrackDir;
#endif /* YAPF_NODE_ROAD_HPP */

@ -15,8 +15,6 @@
int _total_pf_time_us = 0;
template <class Types>
class CYapfReserveTrack
{
@ -27,7 +25,10 @@ public:
protected:
/// to access inherited pathfinder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
private:
TileIndex m_res_dest; ///< The reservation target tile
@ -171,7 +172,10 @@ public:
protected:
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/** Called by YAPF to move from the given node to the next tile. For each
@ -180,12 +184,16 @@ public:
inline void PfFollowNode(Node& old_node)
{
TrackFollower F(Yapf().GetVehicle());
if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir()))
if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir())) {
Yapf().AddMultipleNodes(&old_node, F);
}
}
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 't';}
FORCEINLINE char TransportTypeChar() const
{
return 't';
}
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)
{
@ -247,7 +255,10 @@ public:
protected:
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/** Called by YAPF to move from the given node to the next tile. For each
@ -256,12 +267,16 @@ public:
inline void PfFollowNode(Node& old_node)
{
TrackFollower F(Yapf().GetVehicle(), Yapf().GetCompatibleRailTypes());
if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir()) && F.MaskReservedTracks())
if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir()) && F.MaskReservedTracks()) {
Yapf().AddMultipleNodes(&old_node, F);
}
}
/** Return debug report character to identify the transportation type */
FORCEINLINE char TransportTypeChar() const {return 't';}
FORCEINLINE char TransportTypeChar() const
{
return 't';
}
static bool stFindNearestSafeTile(const Vehicle *v, TileIndex t1, Trackdir td, bool override_railtype)
{
@ -329,7 +344,10 @@ public:
protected:
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/** Called by YAPF to move from the given node to the next tile. For each
@ -338,12 +356,16 @@ public:
inline void PfFollowNode(Node& old_node)
{
TrackFollower F(Yapf().GetVehicle());
if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir()))
if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir())) {
Yapf().AddMultipleNodes(&old_node, F);
}
}
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 't';}
FORCEINLINE char TransportTypeChar() const
{
return 't';
}
static Trackdir stChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
{
@ -600,4 +622,7 @@ bool YapfRailFindNearestSafeTile(const Vehicle *v, TileIndex tile, Trackdir td,
/** if any track changes, this counter is incremented - that will invalidate segment cost cache */
int CSegmentCostCacheBase::s_rail_change_counter = 0;
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track) {CSegmentCostCacheBase::NotifyTrackLayoutChange(tile, track);}
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
{
CSegmentCostCacheBase::NotifyTrackLayoutChange(tile, track);
}

@ -20,7 +20,10 @@ public:
protected:
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
int SlopeCost(TileIndex tile, TileIndex next_tile, Trackdir trackdir)
{
@ -51,12 +54,15 @@ protected:
switch (GetTileType(tile)) {
case MP_ROAD:
/* Increase the cost for level crossings */
if (IsLevelCrossing(tile))
if (IsLevelCrossing(tile)) {
cost += Yapf().PfGetSettings().road_crossing_penalty;
}
break;
case MP_STATION:
if (IsDriveThroughStopTile(tile))
if (IsDriveThroughStopTile(tile)) {
cost += Yapf().PfGetSettings().road_stop_penalty;
}
break;
default:
@ -144,7 +150,10 @@ public:
typedef typename Node::Key Key; ///< key to hash tables
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
/// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(Node& n)
@ -190,7 +199,10 @@ public:
protected:
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/// Called by YAPF to detect if node ends in the desired destination
@ -246,7 +258,10 @@ public:
protected:
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
@ -256,12 +271,16 @@ public:
inline void PfFollowNode(Node& old_node)
{
TrackFollower F(Yapf().GetVehicle());
if (F.Follow(old_node.m_segment_last_tile, old_node.m_segment_last_td))
if (F.Follow(old_node.m_segment_last_tile, old_node.m_segment_last_td)) {
Yapf().AddMultipleNodes(&old_node, F);
}
}
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 'r';}
FORCEINLINE char TransportTypeChar() const
{
return 'r';
}
static Trackdir stChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir)
{
@ -433,14 +452,17 @@ 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 (_settings_game.pf.yapf.disable_node_optimization)
if (_settings_game.pf.yapf.disable_node_optimization) {
pfnDistanceToTile = &CYapfRoad1::stDistanceToTile; // Trackdir, allow 90-deg
}
// measure distance in YAPF units
uint dist = pfnDistanceToTile(v, tile);
// convert distance to tiles
if (dist != UINT_MAX)
if (dist != UINT_MAX) {
dist = (dist + YAPF_TILE_LENGTH - 1) / YAPF_TILE_LENGTH;
}
return dist;
}
@ -448,8 +470,9 @@ Depot *YapfFindNearestRoadDepot(const Vehicle *v)
{
TileIndex tile = v->tile;
Trackdir trackdir = GetVehicleTrackdir(v);
if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0)
if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) {
return NULL;
}
// handle the case when our vehicle is already in the depot tile
if (IsRoadDepotTile(tile)) {
@ -462,8 +485,9 @@ Depot *YapfFindNearestRoadDepot(const Vehicle *v)
PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot;
// 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) {
pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg
}
Depot *ret = pfnFindNearestDepot(v, tile, trackdir);
return ret;

@ -18,7 +18,10 @@ public:
protected:
/// to access inherited path finder
FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
FORCEINLINE Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/** Called by YAPF to move from the given node to the next tile. For each
@ -27,12 +30,16 @@ public:
inline void PfFollowNode(Node& old_node)
{
TrackFollower F(Yapf().GetVehicle());
if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td))
if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td)) {
Yapf().AddMultipleNodes(&old_node, F);
}
}
/// return debug report character to identify the transportation type
FORCEINLINE char TransportTypeChar() const {return 'w';}
FORCEINLINE char TransportTypeChar() const
{
return 'w';
}
static Trackdir ChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
{
@ -94,7 +101,10 @@ public:
protected:
/// to access inherited path finder
Tpf& Yapf() {return *static_cast<Tpf*>(this);}
Tpf& Yapf()
{
return *static_cast<Tpf*>(this);
}
public:
/** Called by YAPF to calculate the cost from the origin to the given node.
@ -168,7 +178,7 @@ Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection ent
}
/** performance measurement helper */
void * NpfBeginInterval()
void *NpfBeginInterval()
{
CPerformanceTimer& perf = *new CPerformanceTimer;
perf.Start();

Loading…
Cancel
Save