diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_get_darkness.c | 30 | ||||
-rw-r--r-- | src/ft_init_map.c | 1 | ||||
-rw-r--r-- | src/ft_select_get.c | 2 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/ft_get_darkness.c b/src/ft_get_darkness.c index e9c3966..7f1bc00 100644 --- a/src/ft_get_darkness.c +++ b/src/ft_get_darkness.c @@ -10,10 +10,40 @@ /* */ /* ************************************************************************** */ +#include <libft.h> #include <cub3d.h> +static int8_t + ft_checkdigit(const char *word, t_cub *clist) +{ + size_t i; + + i = 0; + while (ft_isdigit(word[i])) + i++; + if (i != ft_strlen(word)) + { + ft_sprintf(clist->errmsg, FT_ERR_SH_ALPHA); + return (-1); + } + return (0); +} + int8_t ft_get_darkness(char **words, t_cub *clist) { + if (!(*words) || !words[1] || words[2]) + { + ft_sprintf(clist->errmsg, FT_ERR_ARGS); + return (-1); + } + if (ft_checkdigit(words[1], clist)) + return (-1); + if (ft_atoi(words[1]) < 0 || ft_atoi(words[1]) > 10) + { + ft_sprintf(clist->errmsg, FT_ERR_SH_RANGE); + return (-1); + } + clist->mlist.darklvl = ft_atoi(words[1]); return (0); } diff --git a/src/ft_init_map.c b/src/ft_init_map.c index 3daa3b7..68a3b6d 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -58,6 +58,7 @@ int8_t mlist->isctex = 0; mlist->isnlvl = 0; mlist->ismusic = 0; + mlist->darklvl = 0; mlist->scale = 0; mlist->nlx = 0; mlist->nly = 0; diff --git a/src/ft_select_get.c b/src/ft_select_get.c index 64ba14b..2ed439c 100644 --- a/src/ft_select_get.c +++ b/src/ft_select_get.c @@ -80,7 +80,7 @@ static int8_t ret = 0; while (ft_strncmp(words[0], ref[ret], 3) && ref[ret][0]) ret++; - if (ret == 11) + if (ret == 12) ret = FT_PARSE_END_RET; ret = ft_check_exists(ret, clist); ret = ft_check_exists_two(ret, clist); |