Devilution
Diablo devolved - magic behind the 1996 computer game
path.h
Go to the documentation of this file.
1 
6 #ifndef __PATH_H__
7 #define __PATH_H__
8 
10 extern int gdwCurPathStep;
11 extern int gdwCurNodes;
12 extern int pnode_vals[MAX_PATH_LENGTH];
13 extern PATHNODE *pnode_ptr;
15 extern PATHNODE *path_2_nodes;
17 
18 int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path);
19 int path_get_h_cost(int sx, int sy, int dx, int dy);
20 int path_check_equal(PATHNODE *pPath, int dx, int dy);
22 BOOL path_solid_pieces(PATHNODE *pPath, int dx, int dy);
23 BOOL path_get_path(BOOL (*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y);
24 BOOL path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy);
25 PATHNODE *path_get_node1(int dx, int dy);
26 PATHNODE *path_get_node2(int dx, int dy);
27 void path_next_node(PATHNODE *pPath);
28 void path_set_coords(PATHNODE *pPath);
29 void path_push_active_step(PATHNODE *pPath);
32 
33 /* rdata */
34 
35 extern const char pathxdir[8];
36 extern const char pathydir[8];
37 
38 /* data */
39 extern char path_directions[9];
40 
41 #endif /* __PATH_H__ */
MAXPATHNODES
#define MAXPATHNODES
Definition: defs.h:72
pnode_tblptr
PATHNODE * pnode_tblptr[MAXPATHNODES]
A stack for recursively searching nodes.
Definition: path.cpp:24
gdwCurPathStep
int gdwCurPathStep
size of the pnode_tblptr stack
Definition: path.cpp:13
GetNextPath
PATHNODE * GetNextPath()
get the next node on the A* frontier to explore (estimated to be closest to the goal),...
Definition: path.cpp:128
path_next_node
void path_next_node(PATHNODE *pPath)
insert pPath into the frontier (keeping the frontier sorted by total distance)
Definition: path.cpp:293
path_solid_pieces
BOOL path_solid_pieces(PATHNODE *pPath, int dx, int dy)
check if stepping from pPath to (dx,dy) cuts a corner.
Definition: path.cpp:153
path_get_path
BOOL path_get_path(BOOL(*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y)
perform a single step of A* bread-first search by trying to step in every possible direction from pPa...
Definition: path.cpp:178
path_get_h_cost
int path_get_h_cost(int sx, int sy, int dx, int dy)
heuristic, estimated cost from (sx,sy) to (dx,dy)
Definition: path.cpp:98
path_push_active_step
void path_push_active_step(PATHNODE *pPath)
push pPath onto the pnode_tblptr stack
Definition: path.cpp:346
path_pop_active_step
PATHNODE * path_pop_active_step()
pop and return a node from the pnode_tblptr stack
Definition: path.cpp:356
pnode_vals
int pnode_vals[MAX_PATH_LENGTH]
for reconstructing the path after the A* search is done.
Definition: path.cpp:20
MAX_PATH_LENGTH
#define MAX_PATH_LENGTH
Definition: defs.h:74
path_set_coords
void path_set_coords(PATHNODE *pPath)
update all path costs using depth-first search starting at pPath
Definition: path.cpp:317
path_directions
char path_directions[9]
each step direction is assigned a number like this: dx -1 0 1 +--— -1|5 1 6 dy 0|2 0 3 1|8 4 7
Definition: path.cpp:44
PATHNODE
Definition: structs.h:1422
pathxdir
const char pathxdir[8]
For iterating over the 8 possible movement directions.
Definition: path.cpp:30
path_unusednodes
PATHNODE path_unusednodes[MAXPATHNODES]
Definition: path.cpp:27
path_get_node2
PATHNODE * path_get_node2(int dx, int dy)
return a node for (dx,dy) if it was visited, or NULL if not found
Definition: path.cpp:282
path_new_step
PATHNODE * path_new_step()
zero one of the preallocated nodes and return a pointer to it, or NULL if none are available
Definition: path.cpp:365
pathydir
const char pathydir[8]
Definition: path.cpp:31
pnode_ptr
PATHNODE * pnode_ptr
A linked list of all visited nodes.
Definition: path.cpp:22
path_get_node1
PATHNODE * path_get_node1(int dx, int dy)
return a node for (dx,dy) on the frontier, or NULL if not found
Definition: path.cpp:271
path_check_equal
int path_check_equal(PATHNODE *pPath, int dx, int dy)
return 2 if pPath is horizontally/vertically aligned with (dx,dy), else 3
Definition: path.cpp:117
FindPath
int FindPath(BOOL(*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path)
find the shortest path from (sx,sy) to (dx,dy), using PosOk(PosOkArg,x,y) to check that each step is ...
Definition: path.cpp:51
path_2_nodes
PATHNODE * path_2_nodes
A linked list of the A* frontier, sorted by distance.
Definition: path.cpp:26
gdwCurNodes
int gdwCurNodes
the number of in-use nodes in path_nodes
Definition: path.cpp:15
path_parent_path
BOOL path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy)
add a step from pPath to (dx,dy), return 1 if successful, and update the frontier/visited nodes accor...
Definition: path.cpp:202
path_nodes
PATHNODE path_nodes[MAXPATHNODES]
Notes visisted by the path finding algorithm.
Definition: path.cpp:11