From d1097088999c538601158805cf77250d51513f98 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 5 Feb 2020 13:32:40 +0100 Subject: Don't mess with me boy --- src/ft_get_res.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/ft_get_res.c') 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 #include -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); } -- cgit v1.2.3