summaryrefslogtreecommitdiff
path: root/src/yapf/yapf_node.hpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
committerrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
commit66bbf336c6af7353ef0aeed58002c46543b30635 (patch)
treead4a63860df2626b22f77e7dac712e958bea54cb /src/yapf/yapf_node.hpp
parentccc0a3f4dbf58c005b22341ac8874252924690cd (diff)
downloadopenttd-66bbf336c6af7353ef0aeed58002c46543b30635.tar.xz
(svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make. - Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies. - A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC. - Proper support for OSX universal binaries. - Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files. - Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files. Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
Diffstat (limited to 'src/yapf/yapf_node.hpp')
-rw-r--r--src/yapf/yapf_node.hpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/yapf/yapf_node.hpp b/src/yapf/yapf_node.hpp
new file mode 100644
index 000000000..2fa82a6a6
--- /dev/null
+++ b/src/yapf/yapf_node.hpp
@@ -0,0 +1,77 @@
+/* $Id$ */
+
+#ifndef YAPF_NODE_HPP
+#define YAPF_NODE_HPP
+
+/** Yapf Node Key that evaluates hash from (and compares) tile & exit dir. */
+struct CYapfNodeKeyExitDir {
+ TileIndex m_tile;
+ Trackdir m_td;
+ DiagDirection m_exitdir;
+
+ FORCEINLINE 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);}
+};
+
+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);}
+};
+
+/** Yapf Node base */
+template <class Tkey_, class Tnode>
+struct CYapfNodeT {
+ typedef Tkey_ Key;
+ typedef Tnode Node;
+
+ Tkey_ m_key;
+ Node *m_hash_next;
+ Node *m_parent;
+ int m_cost;
+ int m_estimate;
+
+ FORCEINLINE void Set(Node *parent, TileIndex tile, Trackdir td, bool is_choice)
+ {
+ m_key.Set(tile, td);
+ m_hash_next = NULL;
+ m_parent = parent;
+ m_cost = 0;
+ 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() {return m_cost;}
+ FORCEINLINE int GetCostEstimate() {return m_estimate;}
+ FORCEINLINE bool operator < (const Node& other) const {return m_estimate < other.m_estimate;}
+};
+
+/** Yapf Node for ships */
+template <class Tkey_>
+struct CYapfShipNodeT
+ : CYapfNodeT<Tkey_, CYapfShipNodeT<Tkey_> >
+{
+
+};
+
+// now define two major node types (that differ by key type)
+typedef CYapfShipNodeT<CYapfNodeKeyExitDir> CYapfShipNodeExitDir;
+typedef CYapfShipNodeT<CYapfNodeKeyTrackDir> CYapfShipNodeTrackDir;
+
+// Default NodeList types
+typedef CNodeList_HashTableT<CYapfShipNodeExitDir , 14, 16> CShipNodeListExitDir;
+typedef CNodeList_HashTableT<CYapfShipNodeTrackDir, 16, 20> CShipNodeListTrackDir;
+
+
+#endif /* YAPF_NODE_HPP */