2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef PATHFIND_H
|
|
|
|
#define PATHFIND_H
|
|
|
|
|
2006-03-06 20:28:28 +00:00
|
|
|
#include "direction.h"
|
|
|
|
|
2005-01-31 11:23:10 +00:00
|
|
|
//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not
|
|
|
|
//supported on all archs)
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
typedef struct TrackPathFinder TrackPathFinder;
|
2005-06-24 12:38:35 +00:00
|
|
|
typedef bool TPFEnumProc(TileIndex tile, void *data, int track, uint length, byte *state);
|
2004-08-09 17:04:08 +00:00
|
|
|
typedef void TPFAfterProc(TrackPathFinder *tpf);
|
|
|
|
|
2005-07-19 11:42:40 +00:00
|
|
|
typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
*/
|
2005-01-07 17:02:43 +00:00
|
|
|
#define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5)
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
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;
|
2004-09-11 09:55:19 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
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. */
|
|
|
|
};
|
|
|
|
|
2006-03-06 20:28:28 +00:00
|
|
|
void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2005-06-24 12:38:35 +00:00
|
|
|
TileIndex tile;
|
2004-08-09 17:04:08 +00:00
|
|
|
int length;
|
|
|
|
} FindLengthOfTunnelResult;
|
2005-10-05 07:20:26 +00:00
|
|
|
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, uint direction);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-03-06 20:28:28 +00:00
|
|
|
void NewTrainPathfind(TileIndex tile, TileIndex dest, DiagDirection direction, NTPEnumProc* enum_proc, void* data);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
#endif /* PATHFIND_H */
|