src/pathfind.h
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 5838 9c3129cb019b
child 6303 84c215fc8eb8
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
    12 };
    12 };
    13 
    13 
    14 //#define PF_BENCH // perform simple benchmarks on the train pathfinder (not
    14 //#define PF_BENCH // perform simple benchmarks on the train pathfinder (not
    15 //supported on all archs)
    15 //supported on all archs)
    16 
    16 
    17 typedef struct TrackPathFinder TrackPathFinder;
    17 struct TrackPathFinder;
    18 typedef bool TPFEnumProc(TileIndex tile, void *data, Trackdir trackdir, uint length, byte *state);
    18 typedef bool TPFEnumProc(TileIndex tile, void *data, Trackdir trackdir, uint length, byte *state);
    19 typedef void TPFAfterProc(TrackPathFinder *tpf);
    19 typedef void TPFAfterProc(TrackPathFinder *tpf);
    20 
    20 
    21 typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length);
    21 typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length);
    22 
    22 
    28  *  0  0 y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0  0
    28  *  0  0 y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0  0
    29  *  0  0  0  0 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0  0
    29  *  0  0  0  0 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0  0
    30  */
    30  */
    31 #define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5)
    31 #define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5)
    32 
    32 
    33 typedef struct TrackPathFinderLink {
    33 struct TrackPathFinderLink {
    34 	TileIndex tile;
    34 	TileIndex tile;
    35 	uint16 flags;
    35 	uint16 flags;
    36 	uint16 next;
    36 	uint16 next;
    37 } TrackPathFinderLink;
    37 };
    38 
    38 
    39 typedef struct RememberData {
    39 struct RememberData {
    40 	uint16 cur_length;
    40 	uint16 cur_length;
    41 	byte depth;
    41 	byte depth;
    42 	byte pft_var6;
    42 	byte pft_var6;
    43 } RememberData;
    43 };
    44 
    44 
    45 struct TrackPathFinder {
    45 struct TrackPathFinder {
    46 	int num_links_left;
    46 	int num_links_left;
    47 	TrackPathFinderLink *new_link;
    47 	TrackPathFinderLink *new_link;
    48 
    48 
    65 	TrackPathFinderLink links[0x400]; /* hopefully, this is enough. */
    65 	TrackPathFinderLink links[0x400]; /* hopefully, this is enough. */
    66 };
    66 };
    67 
    67 
    68 void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data);
    68 void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data);
    69 
    69 
    70 typedef struct {
    70 struct FindLengthOfTunnelResult {
    71 	TileIndex tile;
    71 	TileIndex tile;
    72 	int length;
    72 	int length;
    73 } FindLengthOfTunnelResult;
    73 };
    74 FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, DiagDirection direction);
    74 FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, DiagDirection direction);
    75 
    75 
    76 void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypeMask railtypes, DiagDirection direction, NTPEnumProc* enum_proc, void* data);
    76 void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypeMask railtypes, DiagDirection direction, NTPEnumProc* enum_proc, void* data);
    77 
    77 
    78 #endif /* PATHFIND_H */
    78 #endif /* PATHFIND_H */