-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
64 lines (58 loc) · 1.05 KB
/
main.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
#include "cub3d.h"
#include "raycast.h"
int go_again(t_map *map, char **av)
{
init_all(map);
parse_input(av[1], map);
parse_map(av[1], map);
check_map_validity(map);
check_input_validity(map);
check_input_validity2(map);
return (0);
}
int input_check(t_map *map, char **av)
{
if (parse_input(av[1], map) == 1)
return (1);
if (parse_map(av[1], map) == 1)
return (2);
if (check_map_validity(map) == 1)
return (3);
if (check_input_validity(map) == 1)
return (4);
if (check_input_validity2(map) == 1)
return (5);
return (0);
}
int cub_check(char *file)
{
int i;
int len;
i = 0;
len = ft_strlen(file);
if (len < 5)
return (1);
while (file[i] != '.')
i++;
if (ft_strncmp(&file[i], ".cub\0", 5) != 0)
return (1);
return (0);
}
int main(int ac, char **av)
{
t_map map;
if (ac != 2 || cub_check(av[1]) != 0)
{
printf("Usage: ./cub3d map_of_your_choice.cub\n");
return (1);
}
init_all(&map);
if (input_check(&map, av) != 0)
{
free_all(&map);
return (1);
}
while (raycaster(&map) == 1)
go_again(&map, av);
return (0);
}