author | KUDr |
Sat, 21 Apr 2007 08:23:57 +0000 | |
branch | cpp_gui |
changeset 6308 | 646711c5feaa |
parent 6303 | 84c215fc8eb8 |
child 6719 | 4cc327ad39d5 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6303 | 3 |
/** @file pathfind.h */ |
4 |
||
0 | 5 |
#ifndef PATHFIND_H |
6 |
#define PATHFIND_H |
|
7 |
||
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2493
diff
changeset
|
8 |
#include "direction.h" |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
9 |
#include "openttd.h" |
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2493
diff
changeset
|
10 |
|
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
|
11 |
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
|
12 |
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
|
13 |
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
|
14 |
}; |
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
|
15 |
|
1247 | 16 |
//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not |
17 |
//supported on all archs) |
|
18 |
||
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
5838
diff
changeset
|
19 |
struct TrackPathFinder; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
20 |
typedef bool TPFEnumProc(TileIndex tile, void *data, Trackdir trackdir, uint length, byte *state); |
0 | 21 |
typedef void TPFAfterProc(TrackPathFinder *tpf); |
22 |
||
2125
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
1977
diff
changeset
|
23 |
typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length); |
0 | 24 |
|
25 |
#define PATHFIND_GET_LINK_OFFS(tpf, link) ((byte*)(link) - (byte*)tpf->links) |
|
26 |
#define PATHFIND_GET_LINK_PTR(tpf, link_offs) (TrackPathFinderLink*)((byte*)tpf->links + (link_offs)) |
|
27 |
||
28 |
/* y7 y6 y5 y4 y3 y2 y1 y0 x7 x6 x5 x4 x3 x2 x1 x0 |
|
29 |
* y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 0 0 |
|
30 |
* 0 0 y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 |
|
31 |
* 0 0 0 0 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 |
|
32 |
*/ |
|
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
|
33 |
#define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5) |
0 | 34 |
|
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
5838
diff
changeset
|
35 |
struct TrackPathFinderLink { |
0 | 36 |
TileIndex tile; |
37 |
uint16 flags; |
|
38 |
uint16 next; |
|
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
5838
diff
changeset
|
39 |
}; |
0 | 40 |
|
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
5838
diff
changeset
|
41 |
struct RememberData { |
0 | 42 |
uint16 cur_length; |
43 |
byte depth; |
|
44 |
byte pft_var6; |
|
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
5838
diff
changeset
|
45 |
}; |
0 | 46 |
|
47 |
struct TrackPathFinder { |
|
48 |
int num_links_left; |
|
49 |
TrackPathFinderLink *new_link; |
|
50 |
||
51 |
TPFEnumProc *enum_proc; |
|
52 |
||
53 |
void *userdata; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
54 |
|
0 | 55 |
RememberData rd; |
56 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
57 |
TrackdirByte the_dir; |
0 | 58 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
59 |
TransportTypeByte tracktype; |
0 | 60 |
byte var2; |
61 |
bool disable_tile_hash; |
|
62 |
bool hasbit_13; |
|
63 |
||
64 |
uint16 hash_head[0x400]; |
|
6303 | 65 |
TileIndex hash_tile[0x400]; ///< stores the link index when multi link. |
0 | 66 |
|
6303 | 67 |
TrackPathFinderLink links[0x400]; ///< hopefully, this is enough. |
0 | 68 |
}; |
69 |
||
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
2493
diff
changeset
|
70 |
void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data); |
0 | 71 |
|
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
5838
diff
changeset
|
72 |
struct FindLengthOfTunnelResult { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1247
diff
changeset
|
73 |
TileIndex tile; |
0 | 74 |
int length; |
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
5838
diff
changeset
|
75 |
}; |
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
|
76 |
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, DiagDirection direction); |
0 | 77 |
|
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
|
78 |
void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypeMask railtypes, DiagDirection direction, NTPEnumProc* enum_proc, void* data); |
0 | 79 |
|
80 |
#endif /* PATHFIND_H */ |