blob: 8122cc3c82a5fb9dcb72ed15209ba4d80e3109d8 (
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_check_map_surrounds.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:28:34 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:28:37 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stddef.h>
#include <stdint.h>
static int8_t
ft_wall_check(size_t y, size_t x, char **map)
{
if (map[y + 1][x] == ' ' ||
map[y - 1][x] == ' ' ||
map[y][x + 1] == ' ' ||
map[y][x - 1] == ' ' ||
map[y + 1][x] == '\0' ||
map[y - 1][x] == '\0' ||
map[y][x + 1] == '\0' ||
map[y][x - 1] == '\0')
return (-1);
return (0);
}
void
ft_check_map_surrounds(t_map *ml, t_cub *cl)
{
size_t y;
size_t x;
y = 0;
x = 0;
while (ml->map[y])
{
while (ml->map[y][x])
{
if (ft_ischarset(FT_CHRST_MAP_NON_WALL, ml->map[y][x]))
{
if (ft_wall_check(y, x, ml->map) < 0)
ft_map_error(FT_ERR_MAP_WALLS, cl);
}
x++;
}
x = 0;
y++;
}
}
|