-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct.c
More file actions
51 lines (47 loc) · 1.85 KB
/
Copy pathstruct.c
File metadata and controls
51 lines (47 loc) · 1.85 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* struct.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: devoma <devoma@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/18 12:18:59 by devoma #+# #+# */
/* Updated: 2023/05/18 17:23:00 by devoma ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
t_matrix *create_struct(char **map)
{
t_matrix *args;
char **temp_floor;
char **temp_ceiling;
args = malloc(sizeof(t_matrix));
args->north = get_arguments(map, 'N', 2);
args->south = get_arguments(map, 'S', 2);
args->west = get_arguments(map, 'W', 2);
args->east = get_arguments(map, 'E', 2);
args->floor = get_arguments(map, 'F', 1);
args->ceiling = get_arguments(map, 'C', 1);
temp_floor = ft_split(args->floor, ',');
args->f1 = ft_atoi(temp_floor[0]);
args->f2 = ft_atoi(temp_floor[1]);
args->f3 = ft_atoi(temp_floor[2]);
free_map(temp_floor);
temp_ceiling = ft_split(args->ceiling, ',');
args->c1 = ft_atoi(temp_ceiling[0]);
args->c2 = ft_atoi(temp_ceiling[1]);
args->c3 = ft_atoi(temp_ceiling[2]);
free_map(temp_ceiling);
args->map = get_map(map);
return (args);
}
void destroy_struct(t_matrix *args)
{
free(args->north);
free(args->south);
free(args->west);
free(args->east);
free(args->floor);
free(args->ceiling);
free_map(args->map);
}