From c72cf43c89fd216af50c8d209c64d8b6ff188a1c Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Mon, 27 Jan 2020 20:36:43 +0100 Subject: Okkokokokokok --- src/ft_parse_map.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/ft_parse_map.c') 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); } -- cgit v1.2.3