author | miham |
Wed, 17 Aug 2005 12:30:07 +0000 | |
changeset 2349 | df02d0ffb588 |
parent 2186 | 461a2aff3486 |
child 2493 | d834d0c1502a |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef PATHFIND_H |
4 |
#define PATHFIND_H |
|
5 |
||
1247 | 6 |
//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not |
7 |
//supported on all archs) |
|
8 |
||
0 | 9 |
typedef struct TrackPathFinder TrackPathFinder; |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1247
diff
changeset
|
10 |
typedef bool TPFEnumProc(TileIndex tile, void *data, int track, uint length, byte *state); |
0 | 11 |
typedef void TPFAfterProc(TrackPathFinder *tpf); |
12 |
||
2125
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
1977
diff
changeset
|
13 |
typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length); |
0 | 14 |
|
15 |
#define PATHFIND_GET_LINK_OFFS(tpf, link) ((byte*)(link) - (byte*)tpf->links) |
|
16 |
#define PATHFIND_GET_LINK_PTR(tpf, link_offs) (TrackPathFinderLink*)((byte*)tpf->links + (link_offs)) |
|
17 |
||
18 |
/* y7 y6 y5 y4 y3 y2 y1 y0 x7 x6 x5 x4 x3 x2 x1 x0 |
|
19 |
* y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 0 0 |
|
20 |
* 0 0 y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 |
|
21 |
* 0 0 0 0 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 |
|
22 |
*/ |
|
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
201
diff
changeset
|
23 |
#define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5) |
0 | 24 |
|
25 |
typedef struct TrackPathFinderLink { |
|
26 |
TileIndex tile; |
|
27 |
uint16 flags; |
|
28 |
uint16 next; |
|
29 |
} TrackPathFinderLink; |
|
30 |
||
31 |
typedef struct RememberData { |
|
32 |
uint16 cur_length; |
|
33 |
byte depth; |
|
34 |
byte pft_var6; |
|
35 |
} RememberData; |
|
36 |
||
37 |
struct TrackPathFinder { |
|
38 |
||
39 |
int num_links_left; |
|
40 |
TrackPathFinderLink *new_link; |
|
41 |
||
42 |
TPFEnumProc *enum_proc; |
|
43 |
||
44 |
void *userdata; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
45 |
|
0 | 46 |
RememberData rd; |
47 |
||
48 |
int the_dir; |
|
49 |
||
50 |
byte tracktype; |
|
51 |
byte var2; |
|
52 |
bool disable_tile_hash; |
|
53 |
bool hasbit_13; |
|
54 |
||
55 |
uint16 hash_head[0x400]; |
|
56 |
TileIndex hash_tile[0x400]; /* stores the link index when multi link. */ |
|
57 |
||
58 |
TrackPathFinderLink links[0x400]; /* hopefully, this is enough. */ |
|
59 |
}; |
|
60 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1247
diff
changeset
|
61 |
void FollowTrack(TileIndex tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data); |
0 | 62 |
|
63 |
typedef struct { |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1247
diff
changeset
|
64 |
TileIndex tile; |
0 | 65 |
int length; |
66 |
} FindLengthOfTunnelResult; |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1247
diff
changeset
|
67 |
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, int direction); |
0 | 68 |
|
2125
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
1977
diff
changeset
|
69 |
void NewTrainPathfind(TileIndex tile, TileIndex dest, byte direction, NTPEnumProc *enum_proc, void *data); |
0 | 70 |
|
71 |
#endif /* PATHFIND_H */ |