-
Notifications
You must be signed in to change notification settings - Fork 0
/
cub3d_parse_map_file.c
executable file
·42 lines (39 loc) · 1.58 KB
/
cub3d_parse_map_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d_parse_map_file.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mg <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/04 13:36:59 by mg #+# #+# */
/* Updated: 2020/10/07 22:33:52 by mg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int c3d_parse_map_file(t_param *cub3d)
{
char *line;
if ((cub3d->map.fd = open(cub3d->map.file, O_RDONLY)) == -1)
c3d_print_error_sys(cub3d, cub3d->map.file);
while (get_next_line(cub3d->map.fd, &line) > 0)
{
if (c3d_map_file_is_resolution(line))
c3d_parse_map_resolution(line, cub3d);
else if (c3d_map_file_is_texture(line))
c3d_parse_map_file_texture(line, cub3d);
else if (c3d_map_file_is_floor_or_ceiling(line))
c3d_parse_map_floor_or_ceiling(line, cub3d);
else if (*line == '\0')
;
else
{
if ((int)ft_strlen(line) > cub3d->map.column)
cub3d->map.column = ft_strlen(line);
cub3d->map.row++;
}
free(line);
}
free(line);
close(cub3d->map.fd);
return (1);
}