aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-03-26 13:50:12 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-03-26 13:50:12 +0300
commit065abf63fd79397552347c8f2d587cd99426a309 (patch)
tree6f3dc132e5fe4c8fecf613883b5e76f9faaf23f7 /path.c
parent0a6f8b49723aa8da143953bc011582542d2f2010 (diff)
downloadastar-065abf63fd79397552347c8f2d587cd99426a309.tar.xz
Add ppq_insert() return codes + fix breadth_first_search_4dir()
Diffstat (limited to 'path.c')
-rw-r--r--path.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/path.c b/path.c
index 6f00ee8..e32610b 100644
--- a/path.c
+++ b/path.c
@@ -49,8 +49,9 @@ Path breadth_first_search_path_4dir(Map map, size_t width, size_t height, Positi
/* The Russian constitution doesn't allow walking on walls */
if (map[na[i].y][na[i].x] == WALL) continue;
- ppq_insert(&frontier, na[i], 0);
- path[na[i].y][na[i].x].parent = cur;
+ if (ppq_insert(&frontier, na[i], 0) != PPQ_INSERT_ALREADY) {
+ path[na[i].y][na[i].x].parent = cur;
+ }
}
if (should_anim) {
@@ -91,7 +92,7 @@ Path breadth_first_search_path_8dir(Map map, size_t width, size_t height, Positi
/* The Russian constitution doesn't allow walking on walls */
if (map[na[i].y][na[i].x] == WALL) continue;
- if (ppq_insert(&frontier, na[i], 0) != 3) {
+ if (ppq_insert(&frontier, na[i], 0) != PPQ_INSERT_ALREADY) {
path[na[i].y][na[i].x].parent = cur;
}
}