diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_res.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/ft_get_res.c b/src/ft_get_res.c index 86a3186..e51a66f 100644 --- a/src/ft_get_res.c +++ b/src/ft_get_res.c @@ -14,7 +14,7 @@ #include <cub3d.h> static int8_t - ft_checkdigit(const char *word) + ft_checkdigit(const char *word, t_cub *clist) { size_t i; @@ -22,7 +22,11 @@ static int8_t while (ft_isdigit(word[i])) i++; if (i != ft_strlen(word)) + { + ft_strlcpy(clist->errmsg, FT_ERR_RES_ALPHA, + ft_strlen(FT_ERR_RES_ALPHA) + 1); return (-1); + } return (0); } @@ -34,20 +38,23 @@ int8_t wlist = clist->wlist; if (!(*words + 0) || !(*(words + 1)) || !(*(words + 2)) || (*(words + 3))) + { + ft_strlcpy(clist->errmsg, FT_ERR_ARGS, ft_strlen(FT_ERR_ARGS) + 1); return (-1); - if ((ft_checkdigit(words[1]) < 0) || - (ft_checkdigit(words[2]) < 0)) + } + if ((ft_checkdigit(words[1], clist) < 0) || + (ft_checkdigit(words[2], clist) < 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) + if (wlist->x_size <= 1 + || wlist->y_size <= 1) + { + ft_strlcpy(clist->errmsg, FT_ERR_RES_SMALL, + ft_strlen(FT_ERR_RES_SMALL) + 1); return (-1); + } 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); } |