diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 18:12:33 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 18:12:33 +0100 |
commit | fe802c525db1ffa07f5cd6c6f0957566ed5ffdb0 (patch) | |
tree | e4219af8ed215dd9b8879ebae7623183c2274e26 /src/ft_parse_map.c | |
parent | Better error management (diff) | |
download | 42-cub3d-fe802c525db1ffa07f5cd6c6f0957566ed5ffdb0.tar.gz 42-cub3d-fe802c525db1ffa07f5cd6c6f0957566ed5ffdb0.tar.bz2 42-cub3d-fe802c525db1ffa07f5cd6c6f0957566ed5ffdb0.tar.xz 42-cub3d-fe802c525db1ffa07f5cd6c6f0957566ed5ffdb0.tar.zst 42-cub3d-fe802c525db1ffa07f5cd6c6f0957566ed5ffdb0.zip |
dur dur
Diffstat (limited to '')
-rw-r--r-- | src/ft_parse_map.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 0be76bc..af11e2f 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -48,14 +48,17 @@ ft_check_cub(const char *map_path, t_cub *clist) /* } */ /* } */ -static int +static int8_t ft_parse_it(int fd, t_cub *clist) { char *line; char **words; + int ret; clist->line_chk += 1; - if (get_next_line(fd, &line) <= 0) + if ((ret = get_next_line(fd, &line)) < 0) + return (ft_map_error(clist)); + if (ret == 0) { ft_memdel(line); return (ft_map_error(clist)); @@ -70,15 +73,22 @@ ft_parse_it(int fd, t_cub *clist) ft_memdel(line); return (ft_map_error(clist)); } + ft_printf("%s\n", line); + if ((ret = ft_select_get(words, clist)) == 12) + { + if (ft_get_first_line(line, clist) < 0) + return (-1); + return (12); + } ft_memdel(line); - return (ft_select_get(words, clist)); + return (ret); } void ft_parse_map(const char *map_path, t_cub *clist) { int fd; - uint8_t ret; + int8_t ret; ft_check_cub(map_path, clist); fd = open(map_path, O_RDONLY); @@ -89,11 +99,14 @@ ft_parse_map(const char *map_path, t_cub *clist) ft_exit(2, clist); } ret = 1; - while (ret != 12) + while (ret != 12 && ret != -1) ret = ft_parse_it(fd, clist); - ft_check_missing(clist); + if (ret == -1) + ft_map_error(clist); + clist->nsew = 0; if (ft_get_map(fd, clist) < 0) ft_map_error(clist); + ft_check_missing(clist); /* if (ft_get_tex(fd, clist) < 0) */ /* return ; */ /* ft_check_empty_line(fd, 6, clist); */ |