aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_parse_map.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-01-27 20:36:43 +0100
committerRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-01-27 20:36:43 +0100
commitc72cf43c89fd216af50c8d209c64d8b6ff188a1c (patch)
tree0a7f58ae43eea281469543a5726ca7e31ad9713e /src/ft_parse_map.c
parentEven nicer (diff)
download42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.gz
42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.bz2
42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.xz
42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.zst
42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.zip
Okkokokokokok
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);
}