From 402e5e5531306f298e7a153b05db0b4253dba92e Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Thu, 16 Apr 2026 23:08:25 +0300 Subject: Warn when start/goal is on a wall after resizing in map_editor() --- map.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'map.c') 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); -- cgit v1.2.3