-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboarders.c
More file actions
74 lines (66 loc) · 1.92 KB
/
boarders.c
File metadata and controls
74 lines (66 loc) · 1.92 KB
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
65
66
67
68
69
70
71
72
73
74
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* boarders.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dhuss <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/17 13:02:56 by dhuss #+# #+# */
/* Updated: 2024/09/18 10:12:08 by dhuss ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static void top_and_bottom(char **map, t_point size)
{
size_t x;
x = 0;
while (map[0][x] != '\0')
{
if (map[0][x] != '1')
{
ft_putstr_fd("Error\n", 1);
ft_putstr_fd("Map is not enclosed by Walls!\n", 1);
free_double_exit(map);
}
x++;
}
x = 0;
while (map[size.y - 1][x] != '\0')
{
if (map[size.y - 1][x] != '1')
{
ft_putstr_fd("Error\n", 1);
ft_putstr_fd("Map is not enclosed by Walls!\n", 1);
free_double_exit(map);
}
x++;
}
}
static void sides(char **map, t_point size)
{
size_t y;
y = 0;
while (map[y] != NULL)
{
if ((map[y][0] != '1') || (map[y][size.x - 2] != '1'))
{
ft_putstr_fd("Error\n", 1);
ft_putstr_fd("Map is not enclosed by Walls!\n", 1);
free_double_exit(map);
}
y++;
}
}
void check_boarders(char **map, t_point size)
{
top_and_bottom(map, size);
sides(map, size);
}
void check_paths(t_game_state *game)
{
char **map_dup;
map_dup = copy_map(game->map, game->size);
flood_fill(map_dup, game);
other_than_one(map_dup, game->map);
free_double_array(map_dup);
}