* @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 */
| 170 | * @return FALSE if we ran out of preallocated nodes to use, else TRUE |
| 171 | */ |
| 172 | BOOL 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 |
no test coverage detected