diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_res.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/ft_get_res.c b/src/ft_get_res.c index 5b48688..25f87fd 100644 --- a/src/ft_get_res.c +++ b/src/ft_get_res.c @@ -14,8 +14,8 @@ #include <libft.h> #include <cub3d.h> -static void - ft_checkdigit(const char *word, t_cub *clist) +static int8_t + ft_checkdigit(const char *word) { size_t i; @@ -23,21 +23,30 @@ static void while (ft_isdigit(word[i])) i++; if (i != ft_strlen(word)) - ft_map_error(clist); + return (-1); + return (0); } int ft_get_res(char **words, t_cub *clist) { - if (!(*words + 0) || !(*(words + 1)) - || !(*(words + 2)) || (*(words + 3))) + t_win *wlist = clist->wlist; + if (!(*words + 0) || !(*(words + 1)) || + !(*(words + 2)) || (*(words + 3))) + return (-1); + if ((ft_checkdigit(words[1]) < 0) || + (ft_checkdigit(words[2]) < 0)) + return (-1); + wlist->x_size = ft_atoi(words[1]); + wlist->y_size = ft_atoi(words[2]); + if (wlist->x_size < 1 + || wlist->y_size < 1) return (-1); - ft_checkdigit(words[1], clist); - ft_checkdigit(words[2], clist); - clist->wlist->x_size = ft_atoi(words[1]); - clist->wlist->y_size = ft_atoi(words[2]); - if (clist->wlist->x_size < 10 - || clist->wlist->y_size < 10) + if (ft_get_screen_size(wlist) < 0) return (-1); + if (wlist->x_size > wlist->x_max_size) + wlist->x_size = wlist->x_max_size; + if (wlist->y_size > wlist->y_max_size) + wlist->y_size = wlist->y_max_size; return (0); } |