-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_vars_parse_functions2.c
93 lines (88 loc) · 2.89 KB
/
map_vars_parse_functions2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_vars_parse_functions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marza-ga <marza-ga-@student.42barcelo +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/04 21:59:00 by marza-ga #+# #+# */
/* Updated: 2022/03/04 22:17:00 by marza-ga ### ########.fr */
/* */
/* ************************************************************************** */
#include "../cub3D.h"
int parse_var_ft(char *map_info, int index, t_mlx *mlx)
{
index += 2;
if (map_info[index] != ' ')
return (0);
while (map_info[index] && map_info[index] == ' ')
index++;
if (map_info[index] == '\n' || map_info[index] == '\0')
return (0);
while (map_info[index] != '\n' && map_info[index] != '\0'
&& map_info[index] != ' ')
{
mlx->mapvars.ft = ft_strjoin_char(mlx->mapvars.ft, map_info[index]);
index++;
}
if (map_info[index] == '\n' || map_info[index] == '\0')
return (index);
return (0);
}
int parse_var_ct(char *map_info, int index, t_mlx *mlx)
{
index += 2;
if (map_info[index] != ' ')
return (0);
while (map_info[index] && map_info[index] == ' ')
index++;
if (map_info[index] == '\n' || map_info[index] == '\0')
return (0);
while (map_info[index] != '\n' && map_info[index] != '\0'
&& map_info[index] != ' ')
{
mlx->mapvars.ct = ft_strjoin_char(mlx->mapvars.ct, map_info[index]);
index++;
}
if (map_info[index] == '\n' || map_info[index] == '\0')
return (index);
return (0);
}
int parse_var_f(char *map_info, int index, t_mlx *mlx)
{
index += 1;
if (map_info[index] != ' ')
return (0);
while (map_info[index] && map_info[index] == ' ')
index++;
if (map_info[index] == '\n' || map_info[index] == '\0')
return (0);
while (map_info[index] != '\n' && map_info[index] != '\0'
&& map_info[index] != ' ')
{
mlx->mapvars.f = ft_strjoin_char(mlx->mapvars.f, map_info[index]);
index++;
}
if (map_info[index] == '\n' || map_info[index] == '\0')
return (index);
return (0);
}
int parse_var_c(char *map_info, int index, t_mlx *mlx)
{
index += 1;
if (map_info[index] != ' ')
return (0);
while (map_info[index] && map_info[index] == ' ')
index++;
if (map_info[index] == '\n' || map_info[index] == '\0')
return (0);
while (map_info[index] != '\n' && map_info[index] != '\0'
&& map_info[index] != ' ')
{
mlx->mapvars.c = ft_strjoin_char(mlx->mapvars.c, map_info[index]);
index++;
}
if (map_info[index] == '\n' || map_info[index] == '\0')
return (index);
return (0);
}