-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_validate_walls.c
52 lines (48 loc) · 1.57 KB
/
ft_validate_walls.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_validate_walls.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mrhyhorn <mrhyhorn@student.21-school.ru +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/31 21:18:48 by mrhyhorn #+# #+# */
/* Updated: 2022/04/05 15:51:45 by mrhyhorn ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static int ft_validate_side_walls(t_data *data, int len)
{
int h;
h = 1;
while (h < data->game->height)
{
if (data->game->map[h][0] != '1')
return (0);
else if (data->game->map[h][len - 1] != '1')
return (0);
h += 1;
}
return (1);
}
int ft_validate_walls(t_data *data, int *h, int *w, int len)
{
*w = 0;
while (data->game->map[0][*w] != '\n')
{
if (data->game->map[0][*w] != '1')
return (0);
*w += 1;
}
*w = 0;
*h = data->game->height - 1;
while (data->game->map[*h][*w] != '\n' &&
data->game->map[*h][*w] != '\0')
{
if (data->game->map[*h][*w] != '1')
return (0);
*w += 1;
}
if (!(ft_validate_side_walls(data, len)))
return (0);
return (1);
}