From 065abf63fd79397552347c8f2d587cd99426a309 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Thu, 26 Mar 2026 13:50:12 +0300 Subject: Add ppq_insert() return codes + fix breadth_first_search_4dir() --- path.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'path.c') 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; } } -- cgit v1.2.3