author | celestar |
Sat, 30 Dec 2006 12:49:54 +0000 | |
branch | custombridgeheads |
changeset 5600 | bac9ab186cab |
parent 4406 | 4ff711f834b9 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef PATHFIND_H |
4 |
#define PATHFIND_H |
|
5 |
||
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2493
diff
changeset
|
6 |
#include "direction.h" |
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2493
diff
changeset
|
7 |
|
4406
4ff711f834b9
(svn r6159) -Fix: FindClosestTrainDepot hardly ever found a depot with NPF off due to absence of distance-normalization (Rojer)
Darkvater
parents:
4000
diff
changeset
|
8 |
enum { |
4ff711f834b9
(svn r6159) -Fix: FindClosestTrainDepot hardly ever found a depot with NPF off due to absence of distance-normalization (Rojer)
Darkvater
parents:
4000
diff
changeset
|
9 |
STR_FACTOR = 2, |
4ff711f834b9
(svn r6159) -Fix: FindClosestTrainDepot hardly ever found a depot with NPF off due to absence of distance-normalization (Rojer)
Darkvater
parents:
4000
diff
changeset
|
10 |
DIAG_FACTOR = 3 |
4ff711f834b9
(svn r6159) -Fix: FindClosestTrainDepot hardly ever found a depot with NPF off due to absence of distance-normalization (Rojer)
Darkvater
parents:
4000
diff
changeset
|
11 |
}; |
4ff711f834b9
(svn r6159) -Fix: FindClosestTrainDepot hardly ever found a depot with NPF off due to absence of distance-normalization (Rojer)
Darkvater
parents:
4000
diff
changeset
|
12 |
|
1247 | 13 |
//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not |
14 |
//supported on all archs) |
|
15 |
||
0 | 16 |
typedef struct TrackPathFinder TrackPathFinder; |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1247
diff
changeset
|
17 |
typedef bool TPFEnumProc(TileIndex tile, void *data, int track, uint length, byte *state); |
0 | 18 |
typedef void TPFAfterProc(TrackPathFinder *tpf); |
19 |
||
2125
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
1977
diff
changeset
|
20 |
typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length); |
0 | 21 |
|
22 |
#define PATHFIND_GET_LINK_OFFS(tpf, link) ((byte*)(link) - (byte*)tpf->links) |
|
23 |
#define PATHFIND_GET_LINK_PTR(tpf, link_offs) (TrackPathFinderLink*)((byte*)tpf->links + (link_offs)) |
|
24 |
||
25 |
/* y7 y6 y5 y4 y3 y2 y1 y0 x7 x6 x5 x4 x3 x2 x1 x0 |
|
26 |
* y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 0 0 |
|
27 |
* 0 0 y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 |
|
28 |
* 0 0 0 0 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 |
|
29 |
*/ |
|
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
|
30 |
#define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5) |
0 | 31 |
|
32 |
typedef struct TrackPathFinderLink { |
|
33 |
TileIndex tile; |
|
34 |
uint16 flags; |
|
35 |
uint16 next; |
|
36 |
} TrackPathFinderLink; |
|
37 |
||
38 |
typedef struct RememberData { |
|
39 |
uint16 cur_length; |
|
40 |
byte depth; |
|
41 |
byte pft_var6; |
|
42 |
} RememberData; |
|
43 |
||
44 |
struct TrackPathFinder { |
|
45 |
int num_links_left; |
|
46 |
TrackPathFinderLink *new_link; |
|
47 |
||
48 |
TPFEnumProc *enum_proc; |
|
49 |
||
50 |
void *userdata; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
51 |
|
0 | 52 |
RememberData rd; |
53 |
||
54 |
int the_dir; |
|
55 |
||
56 |
byte tracktype; |
|
57 |
byte var2; |
|
58 |
bool disable_tile_hash; |
|
59 |
bool hasbit_13; |
|
60 |
||
61 |
uint16 hash_head[0x400]; |
|
62 |
TileIndex hash_tile[0x400]; /* stores the link index when multi link. */ |
|
63 |
||
64 |
TrackPathFinderLink links[0x400]; /* hopefully, this is enough. */ |
|
65 |
}; |
|
66 |
||
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2493
diff
changeset
|
67 |
void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data); |
0 | 68 |
|
69 |
typedef struct { |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1247
diff
changeset
|
70 |
TileIndex tile; |
0 | 71 |
int length; |
72 |
} FindLengthOfTunnelResult; |
|
3323
cfda77cb7fed
(svn r4089) CodeChange : Create Map Accessors Group in MS WorkSpace, arrange VCProject. Remove warning on FindLengthOfTunnel, uint is not DiagDirection
belugas
parents:
3153
diff
changeset
|
73 |
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, DiagDirection direction); |
0 | 74 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3323
diff
changeset
|
75 |
void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypeMask railtypes, DiagDirection direction, NTPEnumProc* enum_proc, void* data); |
0 | 76 |
|
77 |
#endif /* PATHFIND_H */ |