diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-16 23:08:25 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-16 23:08:25 +0300 |
| commit | 402e5e5531306f298e7a153b05db0b4253dba92e (patch) | |
| tree | eb43ddf7031f9e5437972b7c083c7a6e65206cb3 /map.c | |
| parent | 22b285ffc4345bee05772509a60fb77fb90d16a0 (diff) | |
| download | astar-402e5e5531306f298e7a153b05db0b4253dba92e.tar.xz | |
Warn when start/goal is on a wall after resizing in map_editor()
Diffstat (limited to 'map.c')
| -rw-r--r-- | map.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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); |
