-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpars_textures.c
74 lines (68 loc) · 2.17 KB
/
pars_textures.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pars_textures.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbrandy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/13 16:08:50 by lbrandy #+# #+# */
/* Updated: 2021/04/03 12:04:51 by lbrandy ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void check_textures(t_textures *tex, int side)
{
if (side == 1)
if (tex->no_texture != NULL)
error_handler("duplicate data\n");
if (side == 2)
if (tex->so_texture != NULL)
error_handler("duplicate data\n");
if (side == 3)
if (tex->we_texture != NULL)
error_handler("duplicate data\n");
if (side == 4)
if (tex->ea_texture != NULL)
error_handler("duplicate data\n");
if (side == 5)
if (tex->s_texture != NULL)
error_handler("duplicate data\n");
}
void check_xpm(char *s)
{
int i;
i = 0;
while (s[i] && s[i] != ' ')
i++;
if (i < 5)
error_handler("not correct path or extension of file\n");
if (ft_strncmp(".xpm", &s[i - 4], 4) != 0)
error_handler("not correct path or extension of file\n");
}
void pars_textures(t_textures *text, int side, char *s)
{
int i;
i = 0;
check_textures(text, side);
skip_spaces(&s);
check_xpm(s);
while (s[i] && s[i] != ' ')
i++;
if (side == 1)
text->no_texture = ft_substr(s, 0, i);
if (side == 2)
text->so_texture = ft_substr(s, 0, i);
if (side == 3)
text->we_texture = ft_substr(s, 0, i);
if (side == 4)
text->ea_texture = ft_substr(s, 0, i);
if (side == 5)
text->s_texture = ft_substr(s, 0, i);
while (s[i])
{
if (s[i] == ' ')
i++;
else
error_handler("not correct path or extension of file\n");
}
}