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_get_map_redo.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 'src/ft_get_map_redo.c')
-rw-r--r-- | src/ft_get_map_redo.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/ft_get_map_redo.c b/src/ft_get_map_redo.c index 9b7793b..004dd3d 100644 --- a/src/ft_get_map_redo.c +++ b/src/ft_get_map_redo.c @@ -3,10 +3,58 @@ #include <stddef.h> #include <stdlib.h> +static int8_t +ft_check_line(char *line, uint8_t l, t_cub *clist) +{ + size_t i; + + i = 0; + while (line[i]) + { + if (l != 1) + { + if (!ft_ischarset("012NSEW ", line[i])) + return (-1); + if (ft_ischarset("NSEW", line[i])) + clist->nsew += 1; + if (clist->nsew > 1) + return (-1); + } + else + { + if (!ft_ischarset("1 ", line[i])) + return (-1); + } + i++; + } + if (line[0] != '1' || line[i - 1] != '1') + return (-1); + return (0); +} + +int +ft_get_first_line(char *line, t_cub *clist) +{ + if (!line[0]) + { + ft_memdel(line); + return (-1); + } + if (ft_check_line(line, 1, clist) < 0) + { + ft_memdel(line); + return (-1); + } + return (1); +} + int ft_get_map(int fd, t_cub *clist) { + int ret; + (void)fd; + (void)ret; (void)clist; return (0); } |