-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_errors_map_utils.c
96 lines (88 loc) · 1.94 KB
/
check_errors_map_utils.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "cub3d.h"
int start_map(char **save)
{
int counter;
int x;
counter = 0;
x = 0;
while (!save[x][0])
{
counter++;
x++;
}
return (counter);
}
int counter_map(char **save, int first, int size)
{
int counter;
int x;
counter = 0;
x = first + 1;
while (x < size)
{
if (!save[x][0])
counter = counter + 1;
x++;
}
return (counter);
}
int help_checker(char **save, int x, int y, int first)
{
int z;
if (x == first || y == 0)
{
if (ft_iswall(save[x][y]) == 0)
return (-1);
if (save[x][y] == ' ')
{
z = 0;
while (save[x][z] == ' ')
z++;
if (save[x][z] != '1')
return (-1);
}
}
return (0);
}
int check_what_it_is(char **save, int x, int y, int control)
{
if (control == 1)
{
if ((save[x][y] == '0' || save[x][y] == '2')
&& (save[x + 1][y] != '1' && save[x + 1][y] != '0'
&& save[x + 1][y] != '2' && save[x + 1][y] != 'W'
&& save[x + 1][y] != 'N' && save[x + 1][y] != 'S'
&& save[x + 1][y] != 'E' && !save[x + 1]))
return (-1);
}
else if (control == 2)
{
if ((save[x][y] == '0' || save[x][y] == '2')
&& (save[x - 1][y] != '1' && save[x - 1][y] != '0'
&& save[x - 1][y] != '2' && save[x - 1][y] != 'W'
&& save[x - 1][y] != 'N' && save[x - 1][y] != 'S'
&& save[x - 1][y] != 'E' && !save[x - 1]))
return (-1);
}
return (0);
}
int check_other_things(char **save, int x, int y)
{
if (save[x][y] == ' ' && save[x + 1][y] != '1')
return (-1);
if (save[x][y] == ' ' && save[x - 1][y] != '1')
return (-1);
if (save[x][y] == ' ' && save[x][y + 1] != '1')
return (-1);
if (save[x][y] == ' ' && save[x][y - 1] != '1')
return (-1);
if ((save[x][y] == '0' || save[x][y] == '2') && save[x + 1][y] == ' ')
return (-1);
if ((save[x][y] == '0' || save[x][y] == '2') && save[x - 1][y] == ' ')
return (-1);
if ((save[x][y] == '0' || save[x][y] == '2') && !save[x + 1][y])
return (-1);
if ((save[x][y] == '0' || save[x][y] == '2') && !save[x - 1][y])
return (-1);
return (0);
}