aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-04-16 23:08:25 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-04-16 23:08:25 +0300
commit402e5e5531306f298e7a153b05db0b4253dba92e (patch)
treeeb43ddf7031f9e5437972b7c083c7a6e65206cb3
parent22b285ffc4345bee05772509a60fb77fb90d16a0 (diff)
downloadastar-402e5e5531306f298e7a153b05db0b4253dba92e.tar.xz
Warn when start/goal is on a wall after resizing in map_editor()
-rw-r--r--map.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/map.c b/map.c
index 9917f5f..ff1ab7d 100644
--- a/map.c
+++ b/map.c
@@ -655,13 +655,16 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
*map = new_map;
/* Make sure start and goal aren't outside of the map */
- /* FIXME: they can get stuck in walls */
if (start->y >= *height) {
start->y = *height - 1;
}
if (goal->y >= *height) {
goal->y = *height - 1;
}
+ if ((*map)[goal->y][goal->x] == WALL || (*map)[start->y][start->x] == WALL) {
+ set_message("WARNING: start or goal is on a wall");
+ print_message(*height);
+ }
if (should_pathfind) {
visited = visited_new(*width, *height);
@@ -709,6 +712,10 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
if (goal->x >= *width) {
goal->x = *width - 1;
}
+ if ((*map)[goal->y][goal->x] == WALL || (*map)[start->y][start->x] == WALL) {
+ set_message("WARNING: start or goal is on a wall");
+ print_message(*height);
+ }
if (should_pathfind) {
visited = visited_new(*width, *height);