-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpars_file.c
69 lines (63 loc) · 2.09 KB
/
pars_file.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pars_file.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbrandy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/16 13:05:41 by lbrandy #+# #+# */
/* Updated: 2021/04/03 11:59:59 by lbrandy ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
static void check_letter(char *str, t_textures *t)
{
if (str)
{
if (ft_strncmp("R ", str, 2) == 0)
pars_res(str + 2, t, 0);
else if (ft_strncmp("NO ", str, 3) == 0)
pars_textures(t, 1, str + 3);
else if (ft_strncmp("SO ", str, 3) == 0)
pars_textures(t, 2, str + 3);
else if (ft_strncmp("WE ", str, 3) == 0)
pars_textures(t, 3, str + 3);
else if (ft_strncmp("EA ", str, 3) == 0)
pars_textures(t, 4, str + 3);
else if (ft_strncmp("S ", str, 2) == 0)
pars_textures(t, 5, str + 2);
else if (ft_strncmp("F ", str, 2) == 0)
pars_colors(t, 0, str + 2);
else if (ft_strncmp("C ", str, 2) == 0)
pars_colors(t, 1, str + 2);
else
check_trash_str(str, t);
}
}
t_list *pars_struct(t_textures *t, t_list **list)
{
t_list *tmp;
tmp = *list;
init_struct(t);
while (tmp)
{
if (!check_full_struct(t))
{
check_letter(tmp->content, t);
tmp = tmp->next;
}
else
break ;
}
return (tmp);
}
void pars_file(t_list **list, t_all *all)
{
t_list *tmp;
all->textures = (t_textures *)malloc(sizeof(t_textures));
if (!all->textures)
error_handler("malloc error\n");
tmp = pars_struct(all->textures, list);
all->pos = pars_map(tmp, all);
ft_lstclear(list, ft_lstfree_cont);
}