summaryrefslogtreecommitdiff
path: root/src/pathfind.h
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/pathfind.h
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/pathfind.h')
-rw-r--r--src/pathfind.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/pathfind.h b/src/pathfind.h
new file mode 100644
index 000000000..432d7ea88
--- /dev/null
+++ b/src/pathfind.h
@@ -0,0 +1,77 @@
+/* $Id$ */
+
+#ifndef PATHFIND_H
+#define PATHFIND_H
+
+#include "direction.h"
+
+enum {
+ STR_FACTOR = 2,
+ DIAG_FACTOR = 3
+};
+
+//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not
+//supported on all archs)
+
+typedef struct TrackPathFinder TrackPathFinder;
+typedef bool TPFEnumProc(TileIndex tile, void *data, int track, uint length, byte *state);
+typedef void TPFAfterProc(TrackPathFinder *tpf);
+
+typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length);
+
+#define PATHFIND_GET_LINK_OFFS(tpf, link) ((byte*)(link) - (byte*)tpf->links)
+#define PATHFIND_GET_LINK_PTR(tpf, link_offs) (TrackPathFinderLink*)((byte*)tpf->links + (link_offs))
+
+/* y7 y6 y5 y4 y3 y2 y1 y0 x7 x6 x5 x4 x3 x2 x1 x0
+ * y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 0 0
+ * 0 0 y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0
+ * 0 0 0 0 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0
+ */
+#define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5)
+
+typedef struct TrackPathFinderLink {
+ TileIndex tile;
+ uint16 flags;
+ uint16 next;
+} TrackPathFinderLink;
+
+typedef struct RememberData {
+ uint16 cur_length;
+ byte depth;
+ byte pft_var6;
+} RememberData;
+
+struct TrackPathFinder {
+ int num_links_left;
+ TrackPathFinderLink *new_link;
+
+ TPFEnumProc *enum_proc;
+
+ void *userdata;
+
+ RememberData rd;
+
+ int the_dir;
+
+ byte tracktype;
+ byte var2;
+ bool disable_tile_hash;
+ bool hasbit_13;
+
+ uint16 hash_head[0x400];
+ TileIndex hash_tile[0x400]; /* stores the link index when multi link. */
+
+ TrackPathFinderLink links[0x400]; /* hopefully, this is enough. */
+};
+
+void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data);
+
+typedef struct {
+ TileIndex tile;
+ int length;
+} FindLengthOfTunnelResult;
+FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, DiagDirection direction);
+
+void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypeMask railtypes, DiagDirection direction, NTPEnumProc* enum_proc, void* data);
+
+#endif /* PATHFIND_H */