blob: a53c9c87539b8d183570502acf24fd0cb6893a29 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_check_map_line.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2020/02/02 17:19:10 by rbousset #+# ## ## #+# */
/* Updated: 2020/02/02 17:19:11 by rbousset ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stddef.h>
#include <stdint.h>
size_t
ft_get_line_len(char *line)
{
size_t i;
size_t j;
i = 0;
j = 0;
while (line[i])
{
if (line[i] == ' ')
j++;
i++;
}
return (i - j);
}
int8_t
ft_check_map_line(char *line, uint8_t l, t_cub *clist)
{
size_t i;
i = 0;
while (line[i])
{
if (l != 1)
{
if (!ft_ischarset("012NSEW ", line[i]))
return (-1);
if (ft_ischarset("NSEW", line[i]))
clist->mlist->isspawn += 1;
if (clist->mlist->isspawn > 1)
return (-1);
}
else
{
if (!ft_ischarset("1 ", line[i]))
return (-1);
}
i++;
}
if (line[0] != '1' || line[i - 1] != '1'
|| ft_get_line_len(line) != clist->mlist->map_w)
return (-1);
return (0);
}
|