aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_parse_map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_parse_map.c')
-rw-r--r--src/ft_parse_map.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index 1f31ca1..1911e5c 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -30,6 +30,24 @@ ft_check_cub(const char *map_path, t_cub *clist)
ft_free_words(words, NULL);
}
+static void
+ft_check_last_line(t_cub *clist)
+{
+ size_t i;
+ size_t j;
+
+ i = 0;
+ while (clist->map[i])
+ i++;
+ j = 0;
+ while (clist->map[i - 1][j])
+ {
+ if (clist->map[i - 1][j] != '1' && clist->map[i - 1][j] != '\0')
+ ft_map_error(11 + i - 1, clist);
+ j++;
+ }
+}
+
/*
** I can't close fd
*/
@@ -57,5 +75,7 @@ ft_parse_map(const char *map_path, t_cub *clist)
ft_check_empty_line(fd, 10, clist);
if (ft_get_map(fd, clist) < 0)
ft_map_error(11, clist);
+ ft_check_last_line(clist);
ft_print_list(clist);
+ close(fd);
}