(svn r23640) -Fix: stop using FORCEINLINE (1/3rd of the instances were, the others were still regular inline), but make sure inline is always a 'forced' inline (I am looking at you MSVC)
This commit is contained in:
@@ -53,25 +53,25 @@ struct CFollowTrackT
|
||||
CPerformanceTimer *m_pPerf;
|
||||
RailTypes m_railtypes;
|
||||
|
||||
FORCEINLINE CFollowTrackT(const VehicleType *v = NULL, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL)
|
||||
inline CFollowTrackT(const VehicleType *v = NULL, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL)
|
||||
{
|
||||
Init(v, railtype_override, pPerf);
|
||||
}
|
||||
|
||||
FORCEINLINE CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL)
|
||||
inline CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL)
|
||||
{
|
||||
m_veh = NULL;
|
||||
Init(o, railtype_override, pPerf);
|
||||
}
|
||||
|
||||
FORCEINLINE void Init(const VehicleType *v, RailTypes railtype_override, CPerformanceTimer *pPerf)
|
||||
inline void Init(const VehicleType *v, RailTypes railtype_override, CPerformanceTimer *pPerf)
|
||||
{
|
||||
assert(!IsRailTT() || (v != NULL && v->type == VEH_TRAIN));
|
||||
m_veh = v;
|
||||
Init(v != NULL ? v->owner : INVALID_OWNER, IsRailTT() && railtype_override == INVALID_RAILTYPES ? Train::From(v)->compatible_railtypes : railtype_override, pPerf);
|
||||
}
|
||||
|
||||
FORCEINLINE void Init(Owner o, RailTypes railtype_override, CPerformanceTimer *pPerf)
|
||||
inline void Init(Owner o, RailTypes railtype_override, CPerformanceTimer *pPerf)
|
||||
{
|
||||
assert((!IsRoadTT() || m_veh != NULL) && (!IsRailTT() || railtype_override != INVALID_RAILTYPES));
|
||||
m_veh_owner = o;
|
||||
@@ -86,16 +86,16 @@ struct CFollowTrackT
|
||||
m_railtypes = railtype_override;
|
||||
}
|
||||
|
||||
FORCEINLINE static TransportType TT() {return Ttr_type_;}
|
||||
FORCEINLINE static bool IsWaterTT() {return TT() == TRANSPORT_WATER;}
|
||||
FORCEINLINE static bool IsRailTT() {return TT() == TRANSPORT_RAIL;}
|
||||
FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(RoadVehicle::From(m_veh)->compatible_roadtypes, ROADTYPE_TRAM);}
|
||||
FORCEINLINE static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;}
|
||||
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
|
||||
FORCEINLINE static bool DoTrackMasking() {return IsRailTT() && Tmask_reserved_tracks;}
|
||||
inline static TransportType TT() {return Ttr_type_;}
|
||||
inline static bool IsWaterTT() {return TT() == TRANSPORT_WATER;}
|
||||
inline static bool IsRailTT() {return TT() == TRANSPORT_RAIL;}
|
||||
inline bool IsTram() {return IsRoadTT() && HasBit(RoadVehicle::From(m_veh)->compatible_roadtypes, ROADTYPE_TRAM);}
|
||||
inline static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;}
|
||||
inline static bool Allow90degTurns() {return T90deg_turns_allowed_;}
|
||||
inline static bool DoTrackMasking() {return IsRailTT() && Tmask_reserved_tracks;}
|
||||
|
||||
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
|
||||
FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile)
|
||||
inline DiagDirection GetSingleTramBit(TileIndex tile)
|
||||
{
|
||||
assert(IsTram()); // this function shouldn't be called in other cases
|
||||
|
||||
@@ -189,7 +189,7 @@ struct CFollowTrackT
|
||||
|
||||
protected:
|
||||
/** Follow the m_exitdir from m_old_tile and fill m_new_tile and m_tiles_skipped */
|
||||
FORCEINLINE void FollowTileExit()
|
||||
inline void FollowTileExit()
|
||||
{
|
||||
m_is_station = m_is_bridge = m_is_tunnel = false;
|
||||
m_tiles_skipped = 0;
|
||||
@@ -227,7 +227,7 @@ protected:
|
||||
}
|
||||
|
||||
/** stores track status (available trackdirs) for the new tile into m_new_td_bits */
|
||||
FORCEINLINE bool QueryNewTileTrackStatus()
|
||||
inline bool QueryNewTileTrackStatus()
|
||||
{
|
||||
CPerfStart perf(*m_pPerf);
|
||||
if (IsRailTT() && IsPlainRailTile(m_new_tile)) {
|
||||
@@ -257,7 +257,7 @@ protected:
|
||||
}
|
||||
|
||||
/** return true if we can leave m_old_tile in m_exitdir */
|
||||
FORCEINLINE bool CanExitOldTile()
|
||||
inline bool CanExitOldTile()
|
||||
{
|
||||
/* road stop can be left at one direction only unless it's a drive-through stop */
|
||||
if (IsRoadTT() && IsStandardRoadStopTile(m_old_tile)) {
|
||||
@@ -289,7 +289,7 @@ protected:
|
||||
}
|
||||
|
||||
/** return true if we can enter m_new_tile from m_exitdir */
|
||||
FORCEINLINE bool CanEnterNewTile()
|
||||
inline bool CanEnterNewTile()
|
||||
{
|
||||
if (IsRoadTT() && IsStandardRoadStopTile(m_new_tile)) {
|
||||
/* road stop can be entered from one direction only unless it's a drive-through stop */
|
||||
@@ -386,7 +386,7 @@ protected:
|
||||
}
|
||||
|
||||
/** return true if we must reverse (in depots and single tram bits) */
|
||||
FORCEINLINE bool ForcedReverse()
|
||||
inline bool ForcedReverse()
|
||||
{
|
||||
/* rail and road depots cause reversing */
|
||||
if (!IsWaterTT() && IsDepotTypeTile(m_old_tile, TT())) {
|
||||
@@ -417,7 +417,7 @@ protected:
|
||||
}
|
||||
|
||||
/** return true if we successfully reversed at end of road/track */
|
||||
FORCEINLINE bool TryReverse()
|
||||
inline bool TryReverse()
|
||||
{
|
||||
if (IsRoadTT() && !IsTram()) {
|
||||
/* if we reached the end of road, we can reverse the RV and continue moving */
|
||||
|
@@ -43,7 +43,7 @@ struct BinaryHeap {
|
||||
* @param i Element to access (starts at offset \c 1).
|
||||
* @return Value of the element.
|
||||
*/
|
||||
FORCEINLINE BinaryHeapNode &GetElement(uint i)
|
||||
inline BinaryHeapNode &GetElement(uint i)
|
||||
{
|
||||
assert(i > 0);
|
||||
return this->elements[(i - 1) >> BINARY_HEAP_BLOCKSIZE_BITS][(i - 1) & BINARY_HEAP_BLOCKSIZE_MASK];
|
||||
@@ -96,7 +96,7 @@ struct Hash {
|
||||
/**
|
||||
* Gets the current size of the hash.
|
||||
*/
|
||||
FORCEINLINE uint GetSize() const
|
||||
inline uint GetSize() const
|
||||
{
|
||||
return this->size;
|
||||
}
|
||||
|
@@ -21,27 +21,27 @@ struct CPerformanceTimer
|
||||
|
||||
CPerformanceTimer() : m_start(0), m_acc(0) {}
|
||||
|
||||
FORCEINLINE void Start()
|
||||
inline void Start()
|
||||
{
|
||||
m_start = QueryTime();
|
||||
}
|
||||
|
||||
FORCEINLINE void Stop()
|
||||
inline void Stop()
|
||||
{
|
||||
m_acc += QueryTime() - m_start;
|
||||
}
|
||||
|
||||
FORCEINLINE int Get(int64 coef)
|
||||
inline int Get(int64 coef)
|
||||
{
|
||||
return (int)(m_acc * coef / QueryFrequency());
|
||||
}
|
||||
|
||||
FORCEINLINE int64 QueryTime()
|
||||
inline int64 QueryTime()
|
||||
{
|
||||
return ottd_rdtsc();
|
||||
}
|
||||
|
||||
FORCEINLINE int64 QueryFrequency()
|
||||
inline int64 QueryFrequency()
|
||||
{
|
||||
return ((int64)2200 * 1000000);
|
||||
}
|
||||
@@ -51,17 +51,17 @@ struct CPerfStartReal
|
||||
{
|
||||
CPerformanceTimer *m_pperf;
|
||||
|
||||
FORCEINLINE CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf)
|
||||
inline CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf)
|
||||
{
|
||||
if (m_pperf != NULL) m_pperf->Start();
|
||||
}
|
||||
|
||||
FORCEINLINE ~CPerfStartReal()
|
||||
inline ~CPerfStartReal()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
FORCEINLINE void Stop()
|
||||
inline void Stop()
|
||||
{
|
||||
if (m_pperf != NULL) {
|
||||
m_pperf->Stop();
|
||||
@@ -72,9 +72,9 @@ struct CPerfStartReal
|
||||
|
||||
struct CPerfStartFake
|
||||
{
|
||||
FORCEINLINE CPerfStartFake(CPerformanceTimer& perf) {}
|
||||
FORCEINLINE ~CPerfStartFake() {}
|
||||
FORCEINLINE void Stop() {}
|
||||
inline CPerfStartFake(CPerformanceTimer& perf) {}
|
||||
inline ~CPerfStartFake() {}
|
||||
inline void Stop() {}
|
||||
};
|
||||
|
||||
typedef CPerfStartFake CPerfStart;
|
||||
|
@@ -62,26 +62,26 @@ public:
|
||||
}
|
||||
|
||||
/** return number of open nodes */
|
||||
FORCEINLINE int OpenCount()
|
||||
inline int OpenCount()
|
||||
{
|
||||
return m_open.Count();
|
||||
}
|
||||
|
||||
/** return number of closed nodes */
|
||||
FORCEINLINE int ClosedCount()
|
||||
inline int ClosedCount()
|
||||
{
|
||||
return m_closed.Count();
|
||||
}
|
||||
|
||||
/** allocate new data item from m_arr */
|
||||
FORCEINLINE Titem_ *CreateNewNode()
|
||||
inline Titem_ *CreateNewNode()
|
||||
{
|
||||
if (m_new_node == NULL) m_new_node = m_arr.AppendC();
|
||||
return m_new_node;
|
||||
}
|
||||
|
||||
/** Notify the nodelist that we don't want to discard the given node. */
|
||||
FORCEINLINE void FoundBestNode(Titem_& item)
|
||||
inline 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) {
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
}
|
||||
|
||||
/** insert given item as open node (into m_open and m_open_queue) */
|
||||
FORCEINLINE void InsertOpenNode(Titem_& item)
|
||||
inline void InsertOpenNode(Titem_& item)
|
||||
{
|
||||
assert(m_closed.Find(item.GetKey()) == NULL);
|
||||
m_open.Push(item);
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
/** return the best open node */
|
||||
FORCEINLINE Titem_ *GetBestOpenNode()
|
||||
inline Titem_ *GetBestOpenNode()
|
||||
{
|
||||
if (!m_open_queue.IsEmpty()) {
|
||||
return m_open_queue.Begin();
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
}
|
||||
|
||||
/** remove and return the best open node */
|
||||
FORCEINLINE Titem_ *PopBestOpenNode()
|
||||
inline Titem_ *PopBestOpenNode()
|
||||
{
|
||||
if (!m_open_queue.IsEmpty()) {
|
||||
Titem_ *item = m_open_queue.Shift();
|
||||
@@ -122,14 +122,14 @@ public:
|
||||
}
|
||||
|
||||
/** return the open node specified by a key or NULL if not found */
|
||||
FORCEINLINE Titem_ *FindOpenNode(const Key& key)
|
||||
inline 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)
|
||||
inline Titem_& PopOpenNode(const Key& key)
|
||||
{
|
||||
Titem_& item = m_open.Pop(key);
|
||||
uint idxPop = m_open_queue.FindIndex(item);
|
||||
@@ -138,23 +138,23 @@ public:
|
||||
}
|
||||
|
||||
/** close node */
|
||||
FORCEINLINE void InsertClosedNode(Titem_& item)
|
||||
inline 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)
|
||||
inline Titem_ *FindClosedNode(const Key& key)
|
||||
{
|
||||
Titem_ *item = m_closed.Find(key);
|
||||
return item;
|
||||
}
|
||||
|
||||
/** The number of items. */
|
||||
FORCEINLINE int TotalCount() {return m_arr.Length();}
|
||||
inline int TotalCount() {return m_arr.Length();}
|
||||
/** Get a particular item. */
|
||||
FORCEINLINE Titem_& ItemAt(int idx) {return m_arr[idx];}
|
||||
inline Titem_& ItemAt(int idx) {return m_arr[idx];}
|
||||
|
||||
/** Helper for creating output of this array. */
|
||||
template <class D> void Dump(D &dmp) const
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#include "yapf.h"
|
||||
|
||||
//#undef FORCEINLINE
|
||||
//#define FORCEINLINE inline
|
||||
//#define inline inline
|
||||
|
||||
#include "../../misc/blob.hpp"
|
||||
#include "../../misc/str.hpp"
|
||||
|
@@ -37,11 +37,11 @@ extern int _total_pf_time_us;
|
||||
* Requrements to your pathfinder class derived from CYapfBaseT:
|
||||
* -------------------------------------------------------------
|
||||
* Your pathfinder derived class needs to implement following methods:
|
||||
* FORCEINLINE void PfSetStartupNodes()
|
||||
* FORCEINLINE void PfFollowNode(Node& org)
|
||||
* FORCEINLINE bool PfCalcCost(Node& n)
|
||||
* FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||
* FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
* inline void PfSetStartupNodes()
|
||||
* inline void PfFollowNode(Node& org)
|
||||
* inline bool PfCalcCost(Node& n)
|
||||
* inline bool PfCalcEstimate(Node& n)
|
||||
* inline bool PfDetectDestination(Node& n)
|
||||
*
|
||||
* For more details about those methods, look at the end of CYapfBaseT
|
||||
* declaration. There are some examples. For another example look at
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
|
||||
public:
|
||||
/** default constructor */
|
||||
FORCEINLINE CYapfBaseT()
|
||||
inline CYapfBaseT()
|
||||
: m_pBestDestNode(NULL)
|
||||
, m_pBestIntermediateNode(NULL)
|
||||
, m_settings(&_settings_game.pf.yapf)
|
||||
@@ -97,14 +97,14 @@ public:
|
||||
|
||||
protected:
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
|
||||
public:
|
||||
/** return current settings (can be custom - company based - but later) */
|
||||
FORCEINLINE const YAPFSettings& PfGetSettings() const
|
||||
inline const YAPFSettings& PfGetSettings() const
|
||||
{
|
||||
return *m_settings;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
* If path was found return the best node that has reached the destination. Otherwise
|
||||
* return the best visited node (which was nearest to the destination).
|
||||
*/
|
||||
FORCEINLINE Node *GetBestNode()
|
||||
inline Node *GetBestNode()
|
||||
{
|
||||
return (m_pBestDestNode != NULL) ? m_pBestDestNode : m_pBestIntermediateNode;
|
||||
}
|
||||
@@ -191,14 +191,14 @@ public:
|
||||
* Calls NodeList::CreateNewNode() - allocates new node that can be filled and used
|
||||
* as argument for AddStartupNode() or AddNewNode()
|
||||
*/
|
||||
FORCEINLINE Node& CreateNewNode()
|
||||
inline Node& CreateNewNode()
|
||||
{
|
||||
Node& node = *m_nodes.CreateNewNode();
|
||||
return node;
|
||||
}
|
||||
|
||||
/** Add new node (created by CreateNewNode and filled with data) into open list */
|
||||
FORCEINLINE void AddStartupNode(Node& n)
|
||||
inline void AddStartupNode(Node& n)
|
||||
{
|
||||
Yapf().PfNodeCacheFetch(n);
|
||||
/* insert the new node only if it is not there */
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
}
|
||||
|
||||
/** add multiple nodes - direct children of the given node */
|
||||
FORCEINLINE void AddMultipleNodes(Node *parent, const TrackFollower &tf)
|
||||
inline void AddMultipleNodes(Node *parent, const TrackFollower &tf)
|
||||
{
|
||||
bool is_choice = (KillFirstBit(tf.m_new_td_bits) != TRACKDIR_BIT_NONE);
|
||||
for (TrackdirBits rtds = tf.m_new_td_bits; rtds != TRACKDIR_BIT_NONE; rtds = KillFirstBit(rtds)) {
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
|
||||
#if 0
|
||||
/** Example: PfSetStartupNodes() - set source (origin) nodes */
|
||||
FORCEINLINE void PfSetStartupNodes()
|
||||
inline void PfSetStartupNodes()
|
||||
{
|
||||
/* example: */
|
||||
Node& n1 = *base::m_nodes.CreateNewNode();
|
||||
@@ -326,7 +326,7 @@ public:
|
||||
}
|
||||
|
||||
/** Example: PfFollowNode() - set following (child) nodes of the given node */
|
||||
FORCEINLINE void PfFollowNode(Node& org)
|
||||
inline void PfFollowNode(Node& org)
|
||||
{
|
||||
for (each follower of node org) {
|
||||
Node& n = *base::m_nodes.CreateNewNode();
|
||||
@@ -339,7 +339,7 @@ public:
|
||||
}
|
||||
|
||||
/** Example: PfCalcCost() - set path cost from origin to the given node */
|
||||
FORCEINLINE bool PfCalcCost(Node& n)
|
||||
inline bool PfCalcCost(Node& n)
|
||||
{
|
||||
/* evaluate last step cost */
|
||||
int cost = ...;
|
||||
@@ -349,7 +349,7 @@ public:
|
||||
}
|
||||
|
||||
/** Example: PfCalcEstimate() - set path cost estimate from origin to the target through given node */
|
||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||
inline bool PfCalcEstimate(Node& n)
|
||||
{
|
||||
/* evaluate the distance to our destination */
|
||||
int distance = ...;
|
||||
@@ -359,7 +359,7 @@ public:
|
||||
}
|
||||
|
||||
/** Example: PfDetectDestination() - return true if the given node is our destination */
|
||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
inline bool PfDetectDestination(Node& n)
|
||||
{
|
||||
bool bDest = (n.m_key.m_x == m_x2) && (n.m_key.m_y == m_y2);
|
||||
return bDest;
|
||||
|
@@ -26,7 +26,7 @@ protected:
|
||||
TrackdirBits m_orgTrackdirs; ///< origin trackdir mask
|
||||
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ 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()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
}
|
||||
|
||||
/** return true if first two-way signal should be treated as dead end */
|
||||
FORCEINLINE bool TreatFirstRedTwoWaySignalAsEOL()
|
||||
inline bool TreatFirstRedTwoWaySignalAsEOL()
|
||||
{
|
||||
return Yapf().PfGetSettings().rail_firstred_twoway_eol && m_treat_first_red_two_way_signal_as_eol;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ protected:
|
||||
|
||||
public:
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
inline bool PfDetectDestination(Node& n)
|
||||
{
|
||||
bool bDest = (n.m_key.m_tile == m_destTile) && ((m_destTrackdirs & TrackdirToTrackdirBits(n.GetTrackdir())) != TRACKDIR_BIT_NONE);
|
||||
return bDest;
|
||||
|
@@ -20,7 +20,7 @@ struct CYapfCostBase {
|
||||
* @param td The track direction to check.
|
||||
* @return True if there's a slope, otherwise false.
|
||||
*/
|
||||
FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td)
|
||||
inline static bool stSlopeCost(TileIndex tile, Trackdir td)
|
||||
{
|
||||
if (IsDiagonalTrackdir(td)) {
|
||||
if (IsBridgeTile(tile)) {
|
||||
|
@@ -30,7 +30,7 @@ public:
|
||||
* Called by YAPF to attach cached or local segment cost data to the given node.
|
||||
* @return true if globally cached data were used or false if local data was used
|
||||
*/
|
||||
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
||||
inline bool PfNodeCacheFetch(Node& n)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
* 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)
|
||||
inline void PfNodeCacheFlush(Node& n)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -65,7 +65,7 @@ protected:
|
||||
LocalCache m_local_cache;
|
||||
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
* Called by YAPF to attach cached or local segment cost data to the given node.
|
||||
* @return true if globally cached data were used or false if local data was used
|
||||
*/
|
||||
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
||||
inline bool PfNodeCacheFetch(Node& n)
|
||||
{
|
||||
CacheKey key(n.GetKey());
|
||||
Yapf().ConnectNodeToCachedData(n, *new (m_local_cache.Append()) CachedData(key));
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
* 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)
|
||||
inline void PfNodeCacheFlush(Node& n)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -133,16 +133,16 @@ struct CSegmentCostCacheT
|
||||
HashTable m_map;
|
||||
Heap m_heap;
|
||||
|
||||
FORCEINLINE CSegmentCostCacheT() {}
|
||||
inline CSegmentCostCacheT() {}
|
||||
|
||||
/** flush (clear) the cache */
|
||||
FORCEINLINE void Flush()
|
||||
inline void Flush()
|
||||
{
|
||||
m_map.Clear();
|
||||
m_heap.Clear();
|
||||
}
|
||||
|
||||
FORCEINLINE Tsegment& Get(Key& key, bool *found)
|
||||
inline Tsegment& Get(Key& key, bool *found)
|
||||
{
|
||||
Tsegment *item = m_map.Find(key);
|
||||
if (item == NULL) {
|
||||
@@ -177,15 +177,15 @@ public:
|
||||
protected:
|
||||
Cache& m_global_cache;
|
||||
|
||||
FORCEINLINE CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {};
|
||||
inline CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {};
|
||||
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
|
||||
FORCEINLINE static Cache& stGetGlobalCache()
|
||||
inline static Cache& stGetGlobalCache()
|
||||
{
|
||||
static int last_rail_change_counter = 0;
|
||||
static Date last_date = 0;
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
* Called by YAPF to attach cached or local segment cost data to the given node.
|
||||
* @return true if globally cached data were used or false if local data was used
|
||||
*/
|
||||
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
||||
inline bool PfNodeCacheFetch(Node& n)
|
||||
{
|
||||
if (!Yapf().CanUseGlobalCache(n)) {
|
||||
return Tlocal::PfNodeCacheFetch(n);
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
* 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)
|
||||
inline void PfNodeCacheFlush(Node& n)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@@ -96,14 +96,14 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
FORCEINLINE int SlopeCost(TileIndex tile, Trackdir td)
|
||||
inline int SlopeCost(TileIndex tile, Trackdir td)
|
||||
{
|
||||
CPerfStart perf_cost(Yapf().m_perf_slope_cost);
|
||||
if (!stSlopeCost(tile, td)) return 0;
|
||||
return Yapf().PfGetSettings().rail_slope_penalty;
|
||||
}
|
||||
|
||||
FORCEINLINE int CurveCost(Trackdir td1, Trackdir td2)
|
||||
inline int CurveCost(Trackdir td1, Trackdir td2)
|
||||
{
|
||||
assert(IsValidTrackdir(td1));
|
||||
assert(IsValidTrackdir(td2));
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
return cost;
|
||||
}
|
||||
|
||||
FORCEINLINE int SwitchCost(TileIndex tile1, TileIndex tile2, DiagDirection exitdir)
|
||||
inline int SwitchCost(TileIndex tile1, TileIndex tile2, DiagDirection exitdir)
|
||||
{
|
||||
if (IsPlainRailTile(tile1) && IsPlainRailTile(tile2)) {
|
||||
bool t1 = KillFirstBit(GetTrackBits(tile1) & DiagdirReachesTracks(ReverseDiagDir(exitdir))) != TRACK_BIT_NONE;
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
}
|
||||
|
||||
/** Return one tile cost (base cost + level crossing penalty). */
|
||||
FORCEINLINE int OneTileCost(TileIndex& tile, Trackdir trackdir)
|
||||
inline int OneTileCost(TileIndex& tile, Trackdir trackdir)
|
||||
{
|
||||
int cost = 0;
|
||||
/* set base cost */
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
}
|
||||
|
||||
/** Check for a reserved station platform. */
|
||||
FORCEINLINE bool IsAnyStationTileReserved(TileIndex tile, Trackdir trackdir, int skipped)
|
||||
inline bool IsAnyStationTileReserved(TileIndex tile, Trackdir trackdir, int skipped)
|
||||
{
|
||||
TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(trackdir)));
|
||||
for (; skipped >= 0; skipped--, tile += diff) {
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
}
|
||||
|
||||
/** The cost for reserved tiles, including skipped ones. */
|
||||
FORCEINLINE int ReservationCost(Node& n, TileIndex tile, Trackdir trackdir, int skipped)
|
||||
inline int ReservationCost(Node& n, TileIndex tile, Trackdir trackdir, int skipped)
|
||||
{
|
||||
if (n.m_num_signals_passed >= m_sig_look_ahead_costs.Size() / 2) return 0;
|
||||
if (!IsPbsSignal(n.m_last_signal_type)) return 0;
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
return cost;
|
||||
}
|
||||
|
||||
FORCEINLINE int PlatformLengthPenalty(int platform_length)
|
||||
inline int PlatformLengthPenalty(int platform_length)
|
||||
{
|
||||
int cost = 0;
|
||||
const Train *v = Yapf().GetVehicle();
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
FORCEINLINE void SetMaxCost(int max_cost)
|
||||
inline void SetMaxCost(int max_cost)
|
||||
{
|
||||
m_max_cost = max_cost;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
* Calculates only the cost of given node, adds it to the parent node cost
|
||||
* and stores the result into Node::m_cost member
|
||||
*/
|
||||
FORCEINLINE bool PfCalcCost(Node &n, const TrackFollower *tf)
|
||||
inline bool PfCalcCost(Node &n, const TrackFollower *tf)
|
||||
{
|
||||
assert(!n.flags_u.flags_s.m_targed_seen);
|
||||
assert(tf->m_new_tile == n.m_key.m_tile);
|
||||
@@ -613,14 +613,14 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||
return true;
|
||||
}
|
||||
|
||||
FORCEINLINE bool CanUseGlobalCache(Node& n) const
|
||||
inline bool CanUseGlobalCache(Node& n) const
|
||||
{
|
||||
return !m_disable_cache
|
||||
&& (n.m_parent != NULL)
|
||||
&& (n.m_parent->m_num_signals_passed >= m_sig_look_ahead_costs.Size());
|
||||
}
|
||||
|
||||
FORCEINLINE void ConnectNodeToCachedData(Node& n, CachedData& ci)
|
||||
inline void ConnectNodeToCachedData(Node& n, CachedData& ci)
|
||||
{
|
||||
n.m_segment = &ci;
|
||||
if (n.m_segment->m_cost < 0) {
|
||||
|
@@ -51,13 +51,13 @@ public:
|
||||
}
|
||||
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
inline bool PfDetectDestination(Node& n)
|
||||
{
|
||||
return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
|
||||
}
|
||||
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||
inline bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||
{
|
||||
bool bDest = IsRailDepotTile(tile);
|
||||
return bDest;
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
* Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate
|
||||
*/
|
||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||
inline bool PfCalcEstimate(Node& n)
|
||||
{
|
||||
n.m_estimate = n.m_cost;
|
||||
return true;
|
||||
@@ -91,13 +91,13 @@ public:
|
||||
}
|
||||
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
inline bool PfDetectDestination(Node& n)
|
||||
{
|
||||
return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
|
||||
}
|
||||
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||
inline bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||
{
|
||||
return IsSafeWaitingPosition(Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
|
||||
IsWaitingPositionFree(Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
* Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate.
|
||||
*/
|
||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||
inline bool PfCalcEstimate(Node& n)
|
||||
{
|
||||
n.m_estimate = n.m_cost;
|
||||
return true;
|
||||
@@ -164,13 +164,13 @@ public:
|
||||
}
|
||||
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
inline bool PfDetectDestination(Node& n)
|
||||
{
|
||||
return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
|
||||
}
|
||||
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||
inline bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||
{
|
||||
bool bDest;
|
||||
if (m_dest_station_id != INVALID_STATION) {
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
* Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate
|
||||
*/
|
||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||
inline bool PfCalcEstimate(Node& n)
|
||||
{
|
||||
static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
||||
static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
|
||||
|
@@ -18,15 +18,15 @@ struct CYapfNodeKeyExitDir {
|
||||
Trackdir m_td;
|
||||
DiagDirection m_exitdir;
|
||||
|
||||
FORCEINLINE void Set(TileIndex tile, Trackdir td)
|
||||
inline void Set(TileIndex tile, Trackdir td)
|
||||
{
|
||||
m_tile = tile;
|
||||
m_td = td;
|
||||
m_exitdir = (m_td == INVALID_TRACKDIR) ? INVALID_DIAGDIR : TrackdirToExitdir(m_td);
|
||||
}
|
||||
|
||||
FORCEINLINE int CalcHash() const {return m_exitdir | (m_tile << 2);}
|
||||
FORCEINLINE bool operator == (const CYapfNodeKeyExitDir& other) const {return (m_tile == other.m_tile) && (m_exitdir == other.m_exitdir);}
|
||||
inline int CalcHash() const {return m_exitdir | (m_tile << 2);}
|
||||
inline bool operator == (const CYapfNodeKeyExitDir& other) const {return (m_tile == other.m_tile) && (m_exitdir == other.m_exitdir);}
|
||||
|
||||
void Dump(DumpTarget &dmp) const
|
||||
{
|
||||
@@ -38,8 +38,8 @@ struct CYapfNodeKeyExitDir {
|
||||
|
||||
struct CYapfNodeKeyTrackDir : public CYapfNodeKeyExitDir
|
||||
{
|
||||
FORCEINLINE int CalcHash() const {return m_td | (m_tile << 4);}
|
||||
FORCEINLINE bool operator == (const CYapfNodeKeyTrackDir& other) const {return (m_tile == other.m_tile) && (m_td == other.m_td);}
|
||||
inline int CalcHash() const {return m_td | (m_tile << 4);}
|
||||
inline bool operator == (const CYapfNodeKeyTrackDir& other) const {return (m_tile == other.m_tile) && (m_td == other.m_td);}
|
||||
};
|
||||
|
||||
/** Yapf Node base */
|
||||
@@ -54,7 +54,7 @@ struct CYapfNodeT {
|
||||
int m_cost;
|
||||
int m_estimate;
|
||||
|
||||
FORCEINLINE void Set(Node *parent, TileIndex tile, Trackdir td, bool is_choice)
|
||||
inline void Set(Node *parent, TileIndex tile, Trackdir td, bool is_choice)
|
||||
{
|
||||
m_key.Set(tile, td);
|
||||
m_hash_next = NULL;
|
||||
@@ -63,14 +63,14 @@ struct CYapfNodeT {
|
||||
m_estimate = 0;
|
||||
}
|
||||
|
||||
FORCEINLINE Node *GetHashNext() {return m_hash_next;}
|
||||
FORCEINLINE void SetHashNext(Node *pNext) {m_hash_next = pNext;}
|
||||
FORCEINLINE TileIndex GetTile() const {return m_key.m_tile;}
|
||||
FORCEINLINE Trackdir GetTrackdir() const {return m_key.m_td;}
|
||||
FORCEINLINE const Tkey_& GetKey() const {return m_key;}
|
||||
FORCEINLINE int GetCost() const {return m_cost;}
|
||||
FORCEINLINE int GetCostEstimate() const {return m_estimate;}
|
||||
FORCEINLINE bool operator < (const Node& other) const {return m_estimate < other.m_estimate;}
|
||||
inline Node *GetHashNext() {return m_hash_next;}
|
||||
inline void SetHashNext(Node *pNext) {m_hash_next = pNext;}
|
||||
inline TileIndex GetTile() const {return m_key.m_tile;}
|
||||
inline Trackdir GetTrackdir() const {return m_key.m_td;}
|
||||
inline const Tkey_& GetKey() const {return m_key;}
|
||||
inline int GetCost() const {return m_cost;}
|
||||
inline int GetCostEstimate() const {return m_estimate;}
|
||||
inline bool operator < (const Node& other) const {return m_estimate < other.m_estimate;}
|
||||
|
||||
void Dump(DumpTarget &dmp) const
|
||||
{
|
||||
|
@@ -17,39 +17,39 @@ struct CYapfRailSegmentKey
|
||||
{
|
||||
uint32 m_value;
|
||||
|
||||
FORCEINLINE CYapfRailSegmentKey(const CYapfRailSegmentKey& src) : m_value(src.m_value) {}
|
||||
inline CYapfRailSegmentKey(const CYapfRailSegmentKey& src) : m_value(src.m_value) {}
|
||||
|
||||
FORCEINLINE CYapfRailSegmentKey(const CYapfNodeKeyTrackDir& node_key)
|
||||
inline CYapfRailSegmentKey(const CYapfNodeKeyTrackDir& node_key)
|
||||
{
|
||||
Set(node_key);
|
||||
}
|
||||
|
||||
FORCEINLINE void Set(const CYapfRailSegmentKey& src)
|
||||
inline void Set(const CYapfRailSegmentKey& src)
|
||||
{
|
||||
m_value = src.m_value;
|
||||
}
|
||||
|
||||
FORCEINLINE void Set(const CYapfNodeKeyTrackDir& node_key)
|
||||
inline void Set(const CYapfNodeKeyTrackDir& node_key)
|
||||
{
|
||||
m_value = (((int)node_key.m_tile) << 4) | node_key.m_td;
|
||||
}
|
||||
|
||||
FORCEINLINE int32 CalcHash() const
|
||||
inline int32 CalcHash() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
FORCEINLINE TileIndex GetTile() const
|
||||
inline TileIndex GetTile() const
|
||||
{
|
||||
return (TileIndex)(m_value >> 4);
|
||||
}
|
||||
|
||||
FORCEINLINE Trackdir GetTrackdir() const
|
||||
inline Trackdir GetTrackdir() const
|
||||
{
|
||||
return (Trackdir)(m_value & 0x0F);
|
||||
}
|
||||
|
||||
FORCEINLINE bool operator == (const CYapfRailSegmentKey& other) const
|
||||
inline bool operator == (const CYapfRailSegmentKey& other) const
|
||||
{
|
||||
return m_value == other.m_value;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ struct CYapfRailSegment
|
||||
EndSegmentReasonBits m_end_segment_reason;
|
||||
CYapfRailSegment *m_hash_next;
|
||||
|
||||
FORCEINLINE CYapfRailSegment(const CYapfRailSegmentKey& key)
|
||||
inline CYapfRailSegment(const CYapfRailSegmentKey& key)
|
||||
: m_key(key)
|
||||
, m_last_tile(INVALID_TILE)
|
||||
, m_last_td(INVALID_TRACKDIR)
|
||||
@@ -155,22 +155,22 @@ struct CYapfRailSegment
|
||||
, m_hash_next(NULL)
|
||||
{}
|
||||
|
||||
FORCEINLINE const Key& GetKey() const
|
||||
inline const Key& GetKey() const
|
||||
{
|
||||
return m_key;
|
||||
}
|
||||
|
||||
FORCEINLINE TileIndex GetTile() const
|
||||
inline TileIndex GetTile() const
|
||||
{
|
||||
return m_key.GetTile();
|
||||
}
|
||||
|
||||
FORCEINLINE CYapfRailSegment *GetHashNext()
|
||||
inline CYapfRailSegment *GetHashNext()
|
||||
{
|
||||
return m_hash_next;
|
||||
}
|
||||
|
||||
FORCEINLINE void SetHashNext(CYapfRailSegment *next)
|
||||
inline void SetHashNext(CYapfRailSegment *next)
|
||||
{
|
||||
m_hash_next = next;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ struct CYapfRailNodeT
|
||||
SignalType m_last_red_signal_type;
|
||||
SignalType m_last_signal_type;
|
||||
|
||||
FORCEINLINE void Set(CYapfRailNodeT *parent, TileIndex tile, Trackdir td, bool is_choice)
|
||||
inline void Set(CYapfRailNodeT *parent, TileIndex tile, Trackdir td, bool is_choice)
|
||||
{
|
||||
base::Set(parent, tile, td, is_choice);
|
||||
m_segment = NULL;
|
||||
@@ -236,19 +236,19 @@ struct CYapfRailNodeT
|
||||
flags_u.flags_s.m_choice_seen |= is_choice;
|
||||
}
|
||||
|
||||
FORCEINLINE TileIndex GetLastTile() const
|
||||
inline TileIndex GetLastTile() const
|
||||
{
|
||||
assert(m_segment != NULL);
|
||||
return m_segment->m_last_tile;
|
||||
}
|
||||
|
||||
FORCEINLINE Trackdir GetLastTrackdir() const
|
||||
inline Trackdir GetLastTrackdir() const
|
||||
{
|
||||
assert(m_segment != NULL);
|
||||
return m_segment->m_last_td;
|
||||
}
|
||||
|
||||
FORCEINLINE void SetLastTileTrackdir(TileIndex tile, Trackdir td)
|
||||
inline void SetLastTileTrackdir(TileIndex tile, Trackdir td)
|
||||
{
|
||||
assert(m_segment != NULL);
|
||||
m_segment->m_last_tile = tile;
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
protected:
|
||||
/** to access inherited pathfinder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
|
||||
protected:
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
}
|
||||
|
||||
/** return debug report character to identify the transportation type */
|
||||
FORCEINLINE char TransportTypeChar() const
|
||||
inline char TransportTypeChar() const
|
||||
{
|
||||
return 't';
|
||||
}
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
FORCEINLINE bool FindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_penalty, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
inline bool FindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_penalty, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
{
|
||||
/* set origin and destination nodes */
|
||||
Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true);
|
||||
@@ -293,7 +293,7 @@ public:
|
||||
|
||||
protected:
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -313,7 +313,7 @@ public:
|
||||
}
|
||||
|
||||
/** Return debug report character to identify the transportation type */
|
||||
FORCEINLINE char TransportTypeChar() const
|
||||
inline char TransportTypeChar() const
|
||||
{
|
||||
return 't';
|
||||
}
|
||||
@@ -376,7 +376,7 @@ public:
|
||||
|
||||
protected:
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -396,7 +396,7 @@ public:
|
||||
}
|
||||
|
||||
/** return debug report character to identify the transportation type */
|
||||
FORCEINLINE char TransportTypeChar() const
|
||||
inline char TransportTypeChar() const
|
||||
{
|
||||
return 't';
|
||||
}
|
||||
@@ -422,7 +422,7 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
FORCEINLINE Trackdir ChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target)
|
||||
inline Trackdir ChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target)
|
||||
{
|
||||
if (target != NULL) target->tile = INVALID_TILE;
|
||||
|
||||
@@ -480,7 +480,7 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
FORCEINLINE bool CheckReverseTrain(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
|
||||
inline bool CheckReverseTrain(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
|
||||
{
|
||||
/* create pathfinder instance
|
||||
* set origin and destination nodes */
|
||||
|
@@ -51,7 +51,7 @@ protected:
|
||||
}
|
||||
|
||||
/** return one tile cost */
|
||||
FORCEINLINE int OneTileCost(TileIndex tile, Trackdir trackdir)
|
||||
inline int OneTileCost(TileIndex tile, Trackdir trackdir)
|
||||
{
|
||||
int cost = 0;
|
||||
/* set base cost */
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
* Calculates only the cost of given node, adds it to the parent node cost
|
||||
* and stores the result into Node::m_cost member
|
||||
*/
|
||||
FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf)
|
||||
inline bool PfCalcCost(Node& n, const TrackFollower *tf)
|
||||
{
|
||||
int segment_cost = 0;
|
||||
uint tiles = 0;
|
||||
@@ -181,13 +181,13 @@ public:
|
||||
}
|
||||
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
inline bool PfDetectDestination(Node& n)
|
||||
{
|
||||
bool bDest = IsRoadDepotTile(n.m_segment_last_tile);
|
||||
return bDest;
|
||||
}
|
||||
|
||||
FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
|
||||
inline bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
|
||||
{
|
||||
return IsRoadDepotTile(tile);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
* Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate
|
||||
*/
|
||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||
inline bool PfCalcEstimate(Node& n)
|
||||
{
|
||||
n.m_estimate = n.m_cost;
|
||||
return true;
|
||||
@@ -245,12 +245,12 @@ protected:
|
||||
|
||||
public:
|
||||
/** Called by YAPF to detect if node ends in the desired destination */
|
||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||
inline bool PfDetectDestination(Node& n)
|
||||
{
|
||||
return PfDetectDestinationTile(n.m_segment_last_tile, n.m_segment_last_td);
|
||||
}
|
||||
|
||||
FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
|
||||
inline bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
|
||||
{
|
||||
if (m_dest_station != INVALID_STATION) {
|
||||
return IsTileType(tile, MP_STATION) &&
|
||||
@@ -305,7 +305,7 @@ public:
|
||||
|
||||
protected:
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -326,7 +326,7 @@ public:
|
||||
}
|
||||
|
||||
/** return debug report character to identify the transportation type */
|
||||
FORCEINLINE char TransportTypeChar() const
|
||||
inline char TransportTypeChar() const
|
||||
{
|
||||
return 'r';
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public:
|
||||
return pf.ChooseRoadTrack(v, tile, enterdir, path_found);
|
||||
}
|
||||
|
||||
FORCEINLINE Trackdir ChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, bool &path_found)
|
||||
inline Trackdir ChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, bool &path_found)
|
||||
{
|
||||
/* Handle special case - when next tile is destination tile.
|
||||
* However, when going to a station the (initial) destination
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
return pf.DistanceToTile(v, tile);
|
||||
}
|
||||
|
||||
FORCEINLINE uint DistanceToTile(const RoadVehicle *v, TileIndex dst_tile)
|
||||
inline uint DistanceToTile(const RoadVehicle *v, TileIndex dst_tile)
|
||||
{
|
||||
/* handle special case - when current tile is the destination tile */
|
||||
if (dst_tile == v->tile) {
|
||||
@@ -414,7 +414,7 @@ public:
|
||||
}
|
||||
|
||||
/** Return true if the valid origin (tile/trackdir) was set from the current vehicle position. */
|
||||
FORCEINLINE bool SetOriginFromVehiclePos(const RoadVehicle *v)
|
||||
inline bool SetOriginFromVehiclePos(const RoadVehicle *v)
|
||||
{
|
||||
/* set origin (tile, trackdir) */
|
||||
TileIndex src_tile = v->tile;
|
||||
@@ -434,7 +434,7 @@ public:
|
||||
return pf.FindNearestDepot(v, tile, td, max_distance, depot_tile);
|
||||
}
|
||||
|
||||
FORCEINLINE bool FindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance, TileIndex *depot_tile)
|
||||
inline bool FindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance, TileIndex *depot_tile)
|
||||
{
|
||||
/* set origin and destination nodes */
|
||||
Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td));
|
||||
|
@@ -27,7 +27,7 @@ public:
|
||||
|
||||
protected:
|
||||
/** to access inherited path finder */
|
||||
FORCEINLINE Tpf& Yapf()
|
||||
inline Tpf& Yapf()
|
||||
{
|
||||
return *static_cast<Tpf*>(this);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
}
|
||||
|
||||
/** return debug report character to identify the transportation type */
|
||||
FORCEINLINE char TransportTypeChar() const
|
||||
inline char TransportTypeChar() const
|
||||
{
|
||||
return 'w';
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
* Calculates only the cost of given node, adds it to the parent node cost
|
||||
* and stores the result into Node::m_cost member
|
||||
*/
|
||||
FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf)
|
||||
inline bool PfCalcCost(Node& n, const TrackFollower *tf)
|
||||
{
|
||||
/* base tile cost depending on distance */
|
||||
int c = IsDiagonalTrackdir(n.GetTrackdir()) ? YAPF_TILE_LENGTH : YAPF_TILE_CORNER_LENGTH;
|
||||
|
Reference in New Issue
Block a user