-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_all_map.c
58 lines (52 loc) · 1.62 KB
/
check_all_map.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
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_all_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: deleusis <deleusis@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/23 18:03:05 by deleusis #+# #+# */
/* Updated: 2022/03/03 18:05:36 by deleusis ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void check_map_rectangular(t_prog *prog)
{
int i;
i = 1;
prog->width = ft_strlen(prog->map[0]);
while (prog->map[i])
{
if (ft_strlen(prog->map[i]) != prog->width)
error("Error\nMap is not rectangular\n");
i++;
}
}
void check_walls(t_prog *prog)
{
int i;
int x;
int y;
prog->height = i;
x = 0;
while (x < prog->width)
{
if (prog->map[0][x] != '1' || prog->map[prog->height - 1][x] != '1')
error("Error\nWalls error\n");
x++;
}
y = 0;
while (y < prog->height)
{
if (prog->map[y][0] != '1' || prog->map[y][prog->width - 1] != '1')
error("Error\nWalls error\n");
y++;
}
}
void check_all_map(t_prog *prog)
{
check_map_rectangular(prog);
check_walls(prog);
check_symbols(prog);
set_values(prog);
}