diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-15 20:29:21 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-15 20:29:21 +0100 |
commit | 030fe8c3316d1e1f5f3dea81c3fffd8e00c16afa (patch) | |
tree | aa661716c5ffdd844e41bccb9be833637eaaa3b8 /src/ft_check_map_line.c | |
parent | In progress (diff) | |
download | 42-cub3d-030fe8c3316d1e1f5f3dea81c3fffd8e00c16afa.tar.gz 42-cub3d-030fe8c3316d1e1f5f3dea81c3fffd8e00c16afa.tar.bz2 42-cub3d-030fe8c3316d1e1f5f3dea81c3fffd8e00c16afa.tar.xz 42-cub3d-030fe8c3316d1e1f5f3dea81c3fffd8e00c16afa.tar.zst 42-cub3d-030fe8c3316d1e1f5f3dea81c3fffd8e00c16afa.zip |
Work in progress, res now
Diffstat (limited to '')
-rw-r--r-- | src/ft_check_map_line.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c index 9e4e484..b41d052 100644 --- a/src/ft_check_map_line.c +++ b/src/ft_check_map_line.c @@ -15,6 +15,38 @@ #include <stddef.h> #include <stdint.h> +static int8_t + ft_first_checks(char *line, size_t i, t_cub *clist) +{ + if (!ft_ischarset("012NSEW ", line[i])) + { + ft_strlcpy(clist->errmsg, FT_ERR_ILL_MAP, + ft_strlen(FT_ERR_ILL_MAP) + 1); + return (-1); + } + if (ft_ischarset("NSEW", line[i])) + clist->mlist->isspawn += 1; + if (clist->mlist->isspawn > 1) + { + ft_strlcpy(clist->errmsg, FT_ERR_MULT_SPAWN, + ft_strlen(FT_ERR_MULT_SPAWN) + 1); + return (-1); + } + return (0); +} + +static int8_t + ft_second_checks(char *line, size_t i, t_cub *clist) +{ + if (!ft_ischarset("1 ", line[i])) + { + ft_strlcpy(clist->errmsg, FT_ERR_ILL_MAP, + ft_strlen(FT_ERR_ILL_MAP) + 1); + return (-1); + } + return (0); +} + size_t ft_get_line_len(char *line) { @@ -42,16 +74,12 @@ int8_t { if (l != 1) { - if (!ft_ischarset("012NSEW ", line[i])) - return (-1); - if (ft_ischarset("NSEW", line[i])) - clist->mlist->isspawn += 1; - if (clist->mlist->isspawn > 1) + if (ft_first_checks(line, i, clist) < 0) return (-1); } else { - if (!ft_ischarset("1 ", line[i])) + if (ft_second_checks(line, i, clist) < 0) return (-1); } i++; |