-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker_map.c
67 lines (61 loc) · 1.68 KB
/
checker_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
59
60
61
62
63
64
65
66
67
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* checker_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wboutzou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/17 20:33:07 by wboutzou #+# #+# */
/* Updated: 2022/06/25 22:06:49 by wboutzou ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int checkarg(int argc, char *argv)
{
char *ft;
int fd;
if (argc == 2)
{
fd = open(argv, O_RDONLY);
if (fd < 0)
{
printf("the map file not found :)");
return (0);
}
ft = strrchr(argv, '.');
if (ft != NULL)
{
if (!strcmp(ft, ".ber"))
return (fd);
else
printf("the map format is .ber :)");
}
else
ft_printf("Error \n");
}
else
printf("you missing something (map) :) ");
return (0);
}
int checker_map(t_game *game)
{
if (!check_size(game) || !check_wall(game))
return (0);
if (!checkalpha(game))
return (0);
return (1);
}
void matrix(int fd, t_game *game)
{
char *read;
int i;
i = 0;
read = get_next_line(fd);
if (read == NULL)
return ;
if (!check_read(read))
return ;
game->map = ft_split(read, '\n');
if (game->map == NULL)
return ;
}