blob: 5b48688ab8f2018b6ce71828379a4462b726c8be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_get_res.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2020/02/02 17:19:27 by rbousset #+# ## ## #+# */
/* Updated: 2020/02/02 17:19:27 by rbousset ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
static void
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_map_error(clist);
}
int
ft_get_res(char **words, t_cub *clist)
{
if (!(*words + 0) || !(*(words + 1))
|| !(*(words + 2)) || (*(words + 3)))
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)
return (-1);
return (0);
}
|