summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2015-08-08 13:19:38 +0000
committeralberth <alberth@openttd.org>2015-08-08 13:19:38 +0000
commit1105b4d2c99e99750f42b7a39443bb03b40f4afa (patch)
treea936197f608b155036ffd2c553065cc8cbabc014 /src
parentb885d79f506bde93b4ab278b3f84b8ca6254f3b9 (diff)
downloadopenttd-1105b4d2c99e99750f42b7a39443bb03b40f4afa.tar.xz
(svn r27363) -Codechange: Fix codestyle of one-line methods and header codestyle of derived structs.
Diffstat (limited to 'src')
-rw-r--r--src/misc/array.hpp35
-rw-r--r--src/misc/binaryheap.hpp20
-rw-r--r--src/misc/blob.hpp24
-rw-r--r--src/misc/countedptr.hpp92
-rw-r--r--src/misc/fixedsizearray.hpp68
-rw-r--r--src/misc/hashtable.hpp20
-rw-r--r--src/pathfinder/yapf/nodelist.hpp48
-rw-r--r--src/pathfinder/yapf/yapf_costcache.hpp8
-rw-r--r--src/pathfinder/yapf/yapf_costrail.hpp9
-rw-r--r--src/pathfinder/yapf/yapf_destrail.hpp15
-rw-r--r--src/pathfinder/yapf/yapf_node.hpp69
-rw-r--r--src/pathfinder/yapf/yapf_node_road.hpp8
-rw-r--r--src/pathfinder/yapf/yapf_node_ship.hpp7
13 files changed, 302 insertions, 121 deletions
diff --git a/src/misc/array.hpp b/src/misc/array.hpp
index 9796f18ea..c49f2afc4 100644
--- a/src/misc/array.hpp
+++ b/src/misc/array.hpp
@@ -42,9 +42,16 @@ protected:
public:
/** implicit constructor */
- inline SmallArray() { }
+ inline SmallArray()
+ {
+ }
+
/** Clear (destroy) all items */
- inline void Clear() {data.Clear();}
+ inline void Clear()
+ {
+ data.Clear();
+ }
+
/** Return actual number of items */
inline uint Length() const
{
@@ -54,13 +61,29 @@ public:
return (super_size - 1) * B + sub_size;
}
/** return true if array is empty */
- inline bool IsEmpty() { return data.IsEmpty(); }
+ inline bool IsEmpty()
+ {
+ return data.IsEmpty();
+ }
+
/** return true if array is full */
- inline bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); }
+ inline bool IsFull()
+ {
+ return data.IsFull() && data[N - 1].IsFull();
+ }
+
/** allocate but not construct new item */
- inline T *Append() { return FirstFreeSubArray().Append(); }
+ inline T *Append()
+ {
+ return FirstFreeSubArray().Append();
+ }
+
/** allocate and construct new item */
- inline T *AppendC() { return FirstFreeSubArray().AppendC(); }
+ inline T *AppendC()
+ {
+ return FirstFreeSubArray().AppendC();
+ }
+
/** indexed access (non-const) */
inline T& operator[](uint index)
{
diff --git a/src/misc/binaryheap.hpp b/src/misc/binaryheap.hpp
index 092ab720b..5bd2b794a 100644
--- a/src/misc/binaryheap.hpp
+++ b/src/misc/binaryheap.hpp
@@ -157,21 +157,30 @@ public:
*
* @return The number of items in the queue
*/
- inline uint Length() const { return this->items; }
+ inline uint Length() const
+ {
+ return this->items;
+ }
/**
* Test if the priority queue is empty.
*
* @return True if empty
*/
- inline bool IsEmpty() const { return this->items == 0; }
+ inline bool IsEmpty() const
+ {
+ return this->items == 0;
+ }
/**
* Test if the priority queue is full.
*
* @return True if full.
*/
- inline bool IsFull() const { return this->items >= this->capacity; }
+ inline bool IsFull() const
+ {
+ return this->items >= this->capacity;
+ }
/**
* Get the smallest item in the binary tree.
@@ -287,7 +296,10 @@ public:
* Make the priority queue empty.
* All remaining items will remain untouched.
*/
- inline void Clear() { this->items = 0; }
+ inline void Clear()
+ {
+ this->items = 0;
+ }
};
#endif /* BINARYHEAP_HPP */
diff --git a/src/misc/blob.hpp b/src/misc/blob.hpp
index bf936934b..b1a5b667d 100644
--- a/src/misc/blob.hpp
+++ b/src/misc/blob.hpp
@@ -71,7 +71,10 @@ public:
static const size_t header_size = sizeof(BlobHeader);
/** default constructor - initializes empty blob */
- inline ByteBlob() { InitEmpty(); }
+ inline ByteBlob()
+ {
+ InitEmpty();
+ }
/** copy constructor */
inline ByteBlob(const ByteBlob &src)
@@ -311,9 +314,22 @@ public:
struct OnTransfer {
typename base::BlobHeader *header;
- OnTransfer(const OnTransfer& src) : header(src.header) {assert(src.header != NULL); *const_cast<typename base::BlobHeader**>(&src.header) = NULL;}
- OnTransfer(CBlobT& src) : header(src.header) {src.InitEmpty();}
- ~OnTransfer() {assert(header == NULL);}
+
+ OnTransfer(const OnTransfer& src) : header(src.header)
+ {
+ assert(src.header != NULL);
+ *const_cast<typename base::BlobHeader**>(&src.header) = NULL;
+ }
+
+ OnTransfer(CBlobT& src) : header(src.header)
+ {
+ src.InitEmpty();
+ }
+
+ ~OnTransfer()
+ {
+ assert(header == NULL);
+ }
};
/** Default constructor - makes new Blob ready to accept any data */
diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp
index 1a783cf3e..e7b28a626 100644
--- a/src/misc/countedptr.hpp
+++ b/src/misc/countedptr.hpp
@@ -35,48 +35,97 @@ protected:
public:
/** default (NULL) construct or construct from a raw pointer */
- inline CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();}
+ inline CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj)
+ {
+ AddRef();
+ }
/** copy constructor (invoked also when initializing from another smart ptr) */
- inline CCountedPtr(const CCountedPtr &src) : m_pT(src.m_pT) {AddRef();}
+ inline CCountedPtr(const CCountedPtr &src) : m_pT(src.m_pT)
+ {
+ AddRef();
+ }
/** destructor releasing the reference */
- inline ~CCountedPtr() {Release();}
+ inline ~CCountedPtr()
+ {
+ Release();
+ }
protected:
/** add one ref to the underlaying object */
- inline void AddRef() {if (m_pT != NULL) m_pT->AddRef();}
+ inline void AddRef()
+ {
+ if (m_pT != NULL) m_pT->AddRef();
+ }
public:
/** release smart pointer (and decrement ref count) if not null */
- inline void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}}
+ inline void Release()
+ {
+ if (m_pT != NULL) {
+ Tcls *pT = m_pT;
+ m_pT = NULL;
+ pT->Release();
+ }
+ }
/** dereference of smart pointer - const way */
- inline const Tcls *operator->() const {assert(m_pT != NULL); return m_pT;}
+ inline const Tcls *operator->() const
+ {
+ assert(m_pT != NULL);
+ return m_pT;
+ }
/** dereference of smart pointer - non const way */
- inline Tcls *operator->() {assert(m_pT != NULL); return m_pT;}
+ inline Tcls *operator->()
+ {
+ assert(m_pT != NULL);
+ return m_pT;
+ }
/** raw pointer casting operator - const way */
- inline operator const Tcls*() const {assert(m_pT == NULL); return m_pT;}
+ inline operator const Tcls*() const
+ {
+ assert(m_pT == NULL);
+ return m_pT;
+ }
/** raw pointer casting operator - non-const way */
- inline operator Tcls*() {return m_pT;}
+ inline operator Tcls*()
+ {
+ return m_pT;
+ }
/** operator & to support output arguments */
- inline Tcls** operator&() {assert(m_pT == NULL); return &m_pT;}
+ inline Tcls** operator&()
+ {
+ assert(m_pT == NULL);
+ return &m_pT;
+ }
/** assignment operator from raw ptr */
- inline CCountedPtr& operator=(Tcls *pT) {Assign(pT); return *this;}
+ inline CCountedPtr& operator=(Tcls *pT)
+ {
+ Assign(pT);
+ return *this;
+ }
/** assignment operator from another smart ptr */
- inline CCountedPtr& operator=(const CCountedPtr &src) {Assign(src.m_pT); return *this;}
+ inline CCountedPtr& operator=(const CCountedPtr &src)
+ {
+ Assign(src.m_pT);
+ return *this;
+ }
/** assignment operator helper */
inline void Assign(Tcls *pT);
/** one way how to test for NULL value */
- inline bool IsNull() const {return m_pT == NULL;}
+ inline bool IsNull() const
+ {
+ return m_pT == NULL;
+ }
/** another way how to test for NULL value */
//inline bool operator == (const CCountedPtr &sp) const {return m_pT == sp.m_pT;}
@@ -85,10 +134,19 @@ public:
//inline bool operator != (const CCountedPtr &sp) const {return m_pT != sp.m_pT;}
/** assign pointer w/o incrementing ref count */
- inline void Attach(Tcls *pT) {Release(); m_pT = pT;}
+ inline void Attach(Tcls *pT)
+ {
+ Release();
+ m_pT = pT;
+ }
/** detach pointer w/o decrementing ref count */
- inline Tcls *Detach() {Tcls *pT = m_pT; m_pT = NULL; return pT;}
+ inline Tcls *Detach()
+ {
+ Tcls *pT = m_pT;
+ m_pT = NULL;
+ return pT;
+ }
};
template <class Tcls_>
@@ -136,7 +194,6 @@ template <class T> struct AdaptT {
}
};
-
/**
* Simple counted object. Use it as base of your struct/class if you want to use
* basic reference counting. Your struct/class will destroy and free itself when
@@ -161,7 +218,4 @@ struct SimpleCountedObject {
virtual void FinalRelease() {};
};
-
-
-
#endif /* COUNTEDPTR_HPP */
diff --git a/src/misc/fixedsizearray.hpp b/src/misc/fixedsizearray.hpp
index bf0f3acdd..c694ff7a1 100644
--- a/src/misc/fixedsizearray.hpp
+++ b/src/misc/fixedsizearray.hpp
@@ -41,13 +41,28 @@ protected:
T *data;
/** return reference to the array header (non-const) */
- inline ArrayHeader& Hdr() { return *(ArrayHeader*)(((byte*)data) - HeaderSize); }
+ inline ArrayHeader& Hdr()
+ {
+ return *(ArrayHeader*)(((byte*)data) - HeaderSize);
+ }
+
/** return reference to the array header (const) */
- inline const ArrayHeader& Hdr() const { return *(ArrayHeader*)(((byte*)data) - HeaderSize); }
+ inline const ArrayHeader& Hdr() const
+ {
+ return *(ArrayHeader*)(((byte*)data) - HeaderSize);
+ }
+
/** return reference to the block reference counter */
- inline uint& RefCnt() { return Hdr().reference_count; }
+ inline uint& RefCnt()
+ {
+ return Hdr().reference_count;
+ }
+
/** return reference to number of used items */
- inline uint& SizeRef() { return Hdr().items; }
+ inline uint& SizeRef()
+ {
+ return Hdr().items;
+ }
public:
/** Default constructor. Preallocate space for items and header, then initialize header. */
@@ -96,19 +111,50 @@ public:
}
/** return number of used items */
- inline uint Length() const { return Hdr().items; }
+ inline uint Length() const
+ {
+ return Hdr().items;
+ }
+
/** return true if array is full */
- inline bool IsFull() const { return Length() >= C; }
+ inline bool IsFull() const
+ {
+ return Length() >= C;
+ }
+
/** return true if array is empty */
- inline bool IsEmpty() const { return Length() <= 0; }
+ inline bool IsEmpty() const
+ {
+ return Length() <= 0;
+ }
+
/** add (allocate), but don't construct item */
- inline T *Append() { assert(!IsFull()); return &data[SizeRef()++]; }
+ inline T *Append()
+ {
+ assert(!IsFull());
+ return &data[SizeRef()++];
+ }
+
/** add and construct item using default constructor */
- inline T *AppendC() { T *item = Append(); new(item)T; return item; }
+ inline T *AppendC()
+ {
+ T *item = Append();
+ new(item)T;
+ return item;
+ }
/** return item by index (non-const version) */
- inline T& operator[](uint index) { assert(index < Length()); return data[index]; }
+ inline T& operator[](uint index)
+ {
+ assert(index < Length());
+ return data[index];
+ }
+
/** return item by index (const version) */
- inline const T& operator[](uint index) const { assert(index < Length()); return data[index]; }
+ inline const T& operator[](uint index) const
+ {
+ assert(index < Length());
+ return data[index];
+ }
};
#endif /* FIXEDSIZEARRAY_HPP */
diff --git a/src/misc/hashtable.hpp b/src/misc/hashtable.hpp
index e754a7d7b..1afe58cac 100644
--- a/src/misc/hashtable.hpp
+++ b/src/misc/hashtable.hpp
@@ -24,7 +24,10 @@ struct CHashTableSlotT
inline CHashTableSlotT() : m_pFirst(NULL) {}
/** hash table slot helper - clears the slot by simple forgetting its items */
- inline void Clear() {m_pFirst = NULL;}
+ inline void Clear()
+ {
+ m_pFirst = NULL;
+ }
/** hash table slot helper - linear search for item with given key through the given blob - const version */
inline const Titem_ *Find(const Key &key) const
@@ -168,14 +171,23 @@ protected:
}
/** static helper - return hash for the given item modulo number of slots */
- inline static int CalcHash(const Titem_ &item) {return CalcHash(item.GetKey());}
+ inline static int CalcHash(const Titem_ &item)
+ {
+ return CalcHash(item.GetKey());
+ }
public:
/** item count */
- inline int Count() const {return m_num_items;}
+ inline int Count() const
+ {
+ return m_num_items;
+ }
/** simple clear - forget all items - used by CSegmentCostCacheT.Flush() */
- inline void Clear() {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();}
+ inline void Clear()
+ {
+ for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();
+ }
/** const item search */
const Titem_ *Find(const Tkey &key) const
diff --git a/src/pathfinder/yapf/nodelist.hpp b/src/pathfinder/yapf/nodelist.hpp
index ce0a7ba90..e82f869f1 100644
--- a/src/pathfinder/yapf/nodelist.hpp
+++ b/src/pathfinder/yapf/nodelist.hpp
@@ -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
diff --git a/src/pathfinder/yapf/yapf_costcache.hpp b/src/pathfinder/yapf/yapf_costcache.hpp
index a3e40d13e..f16d4054c 100644
--- a/src/pathfinder/yapf/yapf_costcache.hpp
+++ b/src/pathfinder/yapf/yapf_costcache.hpp
@@ -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)
diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp
index 80cbd529d..64cf96380 100644
--- a/src/pathfinder/yapf/yapf_costrail.hpp
+++ b/src/pathfinder/yapf/yapf_costrail.hpp
@@ -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;
diff --git a/src/pathfinder/yapf/yapf_destrail.hpp b/src/pathfinder/yapf/yapf_destrail.hpp
index 37525bfa2..681034a2f 100644
--- a/src/pathfinder/yapf/yapf_destrail.hpp
+++ b/src/pathfinder/yapf/yapf_destrail.hpp
@@ -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
diff --git a/src/pathfinder/yapf/yapf_node.hpp b/src/pathfinder/yapf/yapf_node.hpp
index c305fd996..b3021096b 100644
--- a/src/pathfinder/yapf/yapf_node.hpp
+++ b/src/pathfinder/yapf/yapf_node.hpp
@@ -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
{
diff --git a/src/pathfinder/yapf/yapf_node_road.hpp b/src/pathfinder/yapf/yapf_node_road.hpp
index 5cc2d5539..9a392f088 100644
--- a/src/pathfinder/yapf/yapf_node_road.hpp
+++ b/src/pathfinder/yapf/yapf_node_road.hpp
@@ -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)
{
diff --git a/src/pathfinder/yapf/yapf_node_ship.hpp b/src/pathfinder/yapf/yapf_node_ship.hpp
index 7a1358af6..df4254fd9 100644
--- a/src/pathfinder/yapf/yapf_node_ship.hpp
+++ b/src/pathfinder/yapf/yapf_node_ship.hpp
@@ -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 */