MCPcopy Create free account
hub / github.com/diasurgical/devilution / path_get_path

Function path_get_path

Source/path.cpp:172–189  ·  view source on GitHub ↗

* @brief perform a single step of A* bread-first search by trying to step in every possible direction from pPath with goal (x,y). Check each step with PosOk * * @return FALSE if we ran out of preallocated nodes to use, else TRUE */

Source from the content-addressed store, hash-verified

170 * @return FALSE if we ran out of preallocated nodes to use, else TRUE
171 */
172BOOL path_get_path(BOOL (*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y)
173{
174 int dx, dy;
175 int i;
176 BOOL ok;
177
178 for (i = 0; i < 8; i++) {
179 dx = pPath->x + pathxdir[i];
180 dy = pPath->y + pathydir[i];
181 ok = PosOk(PosOkArg, dx, dy);
182 if (ok && path_solid_pieces(pPath, dx, dy) || !ok && dx == x && dy == y) {
183 if (!path_parent_path(pPath, dx, dy, x, y))
184 return FALSE;
185 }
186 }
187
188 return TRUE;
189}
190
191/**
192 * @brief add a step from pPath to (dx,dy), return 1 if successful, and update the frontier/visited nodes accordingly

Callers 1

FindPathFunction · 0.85

Calls 2

path_solid_piecesFunction · 0.85
path_parent_pathFunction · 0.85

Tested by

no test coverage detected