(svn r27363) -Codechange: Fix codestyle of one-line methods and header codestyle of derived structs.
This commit is contained in:
@@ -24,34 +24,23 @@
|
||||
template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
|
||||
class CNodeList_HashTableT {
|
||||
public:
|
||||
/** make Titem_ visible from outside of class */
|
||||
typedef Titem_ Titem;
|
||||
/** make Titem_::Key a property of HashTable */
|
||||
typedef typename Titem_::Key Key;
|
||||
/** type that we will use as item container */
|
||||
typedef SmallArray<Titem_, 65536, 256> CItemArray;
|
||||
/** how pointers to open nodes will be stored */
|
||||
typedef CHashTableT<Titem_, Thash_bits_open_ > COpenList;
|
||||
/** how pointers to closed nodes will be stored */
|
||||
typedef CHashTableT<Titem_, Thash_bits_closed_> CClosedList;
|
||||
/** how the priority queue will be managed */
|
||||
typedef CBinaryHeapT<Titem_> CPriorityQueue;
|
||||
typedef Titem_ Titem; ///< Make #Titem_ visible from outside of class.
|
||||
typedef typename Titem_::Key Key; ///< Make Titem_::Key a property of #HashTable.
|
||||
typedef SmallArray<Titem_, 65536, 256> CItemArray; ///< Type that we will use as item container.
|
||||
typedef CHashTableT<Titem_, Thash_bits_open_ > COpenList; ///< How pointers to open nodes will be stored.
|
||||
typedef CHashTableT<Titem_, Thash_bits_closed_> CClosedList; ///< How pointers to closed nodes will be stored.
|
||||
typedef CBinaryHeapT<Titem_> CPriorityQueue; ///< How the priority queue will be managed.
|
||||
|
||||
protected:
|
||||
/** here we store full item data (Titem_) */
|
||||
CItemArray m_arr;
|
||||
/** hash table of pointers to open item data */
|
||||
COpenList m_open;
|
||||
/** hash table of pointers to closed item data */
|
||||
CClosedList m_closed;
|
||||
/** priority queue of pointers to open item data */
|
||||
CPriorityQueue m_open_queue;
|
||||
/** new open node under construction */
|
||||
Titem *m_new_node;
|
||||
CItemArray m_arr; ///< Here we store full item data (Titem_).
|
||||
COpenList m_open; ///< Hash table of pointers to open item data.
|
||||
CClosedList m_closed; ///< Hash table of pointers to closed item data.
|
||||
CPriorityQueue m_open_queue; ///< Priority queue of pointers to open item data.
|
||||
Titem *m_new_node; ///< New open node under construction.
|
||||
|
||||
public:
|
||||
/** default constructor */
|
||||
CNodeList_HashTableT()
|
||||
: m_open_queue(2048)
|
||||
CNodeList_HashTableT() : m_open_queue(2048)
|
||||
{
|
||||
m_new_node = NULL;
|
||||
}
|
||||
@@ -152,9 +141,16 @@ public:
|
||||
}
|
||||
|
||||
/** The number of items. */
|
||||
inline int TotalCount() {return m_arr.Length();}
|
||||
inline int TotalCount()
|
||||
{
|
||||
return m_arr.Length();
|
||||
}
|
||||
|
||||
/** Get a particular item. */
|
||||
inline 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
|
||||
|
@@ -121,9 +121,7 @@ struct CSegmentCostCacheBase
|
||||
* Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example
|
||||
*/
|
||||
template <class Tsegment>
|
||||
struct CSegmentCostCacheT
|
||||
: public CSegmentCostCacheBase
|
||||
{
|
||||
struct CSegmentCostCacheT : public CSegmentCostCacheBase {
|
||||
static const int C_HASH_BITS = 14;
|
||||
|
||||
typedef CHashTableT<Tsegment, C_HASH_BITS> HashTable;
|
||||
@@ -162,9 +160,7 @@ struct CSegmentCostCacheT
|
||||
* segment cost caching services for your Nodes.
|
||||
*/
|
||||
template <class Types>
|
||||
class CYapfSegmentCostCacheGlobalT
|
||||
: public CYapfSegmentCostCacheLocalT<Types>
|
||||
{
|
||||
class CYapfSegmentCostCacheGlobalT : public CYapfSegmentCostCacheLocalT<Types> {
|
||||
public:
|
||||
typedef CYapfSegmentCostCacheLocalT<Types> Tlocal;
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
|
@@ -15,9 +15,7 @@
|
||||
#include "../../pbs.h"
|
||||
|
||||
template <class Types>
|
||||
class CYapfCostRailT
|
||||
: public CYapfCostBase
|
||||
{
|
||||
class CYapfCostRailT : public CYapfCostBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::TrackFollower TrackFollower;
|
||||
@@ -74,10 +72,7 @@ protected:
|
||||
|
||||
static const int s_max_segment_cost = 10000;
|
||||
|
||||
CYapfCostRailT()
|
||||
: m_max_cost(0)
|
||||
, m_disable_cache(false)
|
||||
, m_stopped_on_first_two_way_signal(false)
|
||||
CYapfCostRailT() : m_max_cost(0), m_disable_cache(false), m_stopped_on_first_two_way_signal(false)
|
||||
{
|
||||
/* pre-compute look-ahead penalties into array */
|
||||
int p0 = Yapf().PfGetSettings().rail_look_ahead_signal_p0;
|
||||
|
@@ -12,8 +12,7 @@
|
||||
#ifndef YAPF_DESTRAIL_HPP
|
||||
#define YAPF_DESTRAIL_HPP
|
||||
|
||||
class CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationRailBase {
|
||||
protected:
|
||||
RailTypes m_compatible_railtypes;
|
||||
|
||||
@@ -36,9 +35,7 @@ public:
|
||||
};
|
||||
|
||||
template <class Types>
|
||||
class CYapfDestinationAnyDepotRailT
|
||||
: public CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationAnyDepotRailT : public CYapfDestinationRailBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
||||
@@ -75,9 +72,7 @@ public:
|
||||
};
|
||||
|
||||
template <class Types>
|
||||
class CYapfDestinationAnySafeTileRailT
|
||||
: public CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationAnySafeTileRailT : public CYapfDestinationRailBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
||||
@@ -115,9 +110,7 @@ public:
|
||||
};
|
||||
|
||||
template <class Types>
|
||||
class CYapfDestinationTileOrStationRailT
|
||||
: public CYapfDestinationRailBase
|
||||
{
|
||||
class CYapfDestinationTileOrStationRailT : public CYapfDestinationRailBase {
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
||||
|
@@ -25,8 +25,15 @@ struct CYapfNodeKeyExitDir {
|
||||
m_exitdir = (m_td == INVALID_TRACKDIR) ? INVALID_DIAGDIR : TrackdirToExitdir(m_td);
|
||||
}
|
||||
|
||||
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);}
|
||||
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 +45,15 @@ struct CYapfNodeKeyExitDir {
|
||||
|
||||
struct CYapfNodeKeyTrackDir : public CYapfNodeKeyExitDir
|
||||
{
|
||||
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);}
|
||||
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 */
|
||||
@@ -63,14 +77,45 @@ struct CYapfNodeT {
|
||||
m_estimate = 0;
|
||||
}
|
||||
|
||||
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;}
|
||||
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
|
||||
{
|
||||
|
@@ -14,13 +14,11 @@
|
||||
|
||||
/** Yapf Node for road YAPF */
|
||||
template <class Tkey_>
|
||||
struct CYapfRoadNodeT
|
||||
: CYapfNodeT<Tkey_, CYapfRoadNodeT<Tkey_> >
|
||||
{
|
||||
struct CYapfRoadNodeT : CYapfNodeT<Tkey_, CYapfRoadNodeT<Tkey_> > {
|
||||
typedef CYapfNodeT<Tkey_, CYapfRoadNodeT<Tkey_> > base;
|
||||
|
||||
TileIndex m_segment_last_tile;
|
||||
Trackdir m_segment_last_td;
|
||||
TileIndex m_segment_last_tile;
|
||||
Trackdir m_segment_last_td;
|
||||
|
||||
void Set(CYapfRoadNodeT *parent, TileIndex tile, Trackdir td, bool is_choice)
|
||||
{
|
||||
|
@@ -14,11 +14,7 @@
|
||||
|
||||
/** Yapf Node for ships */
|
||||
template <class Tkey_>
|
||||
struct CYapfShipNodeT
|
||||
: CYapfNodeT<Tkey_, CYapfShipNodeT<Tkey_> >
|
||||
{
|
||||
|
||||
};
|
||||
struct CYapfShipNodeT : CYapfNodeT<Tkey_, CYapfShipNodeT<Tkey_> > { };
|
||||
|
||||
/* now define two major node types (that differ by key type) */
|
||||
typedef CYapfShipNodeT<CYapfNodeKeyExitDir> CYapfShipNodeExitDir;
|
||||
@@ -28,5 +24,4 @@ typedef CYapfShipNodeT<CYapfNodeKeyTrackDir> CYapfShipNodeTrackDir;
|
||||
typedef CNodeList_HashTableT<CYapfShipNodeExitDir , 10, 12> CShipNodeListExitDir;
|
||||
typedef CNodeList_HashTableT<CYapfShipNodeTrackDir, 10, 12> CShipNodeListTrackDir;
|
||||
|
||||
|
||||
#endif /* YAPF_NODE_SHIP_HPP */
|
||||
|
Reference in New Issue
Block a user