diff --git a/a.out b/a.out index 91644eb..94d7a64 100755 Binary files a/a.out and b/a.out differ diff --git a/maps_reader.c b/maps_reader.c index b2b5977..7f73656 100644 --- a/maps_reader.c +++ b/maps_reader.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/12 05:19:39 by adjoly #+# #+# */ -/* Updated: 2024/01/04 16:22:01 by adjoly ### ########.fr */ +/* Updated: 2024/01/06 08:18:22 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,21 +32,6 @@ void ft_free(void **map) free(map); } -t_map ft_split_height_color(char *tmp) -{ - t_map height_color; - int i; - - height_color.y = ft_atoi(tmp); - while (tmp[i] && tmp[i] != ',') - i++; - if (tmp[i] == ',') - height_color.color = ft_strdup(&tmp[i + 1]); - else - height_color.color = ft_strdup("0xFFFFFF"); - return (height_color); -} - size_t ft_countline_fd(int fd) { size_t i; @@ -72,44 +57,6 @@ size_t ft_countline_fd(int fd) return (count); } -size_t ft_countline(char **map) -{ - size_t i; - - i = 0; - while (map[i]) - i++; - return (i); -} - -t_map **ft_parse_map(char **mapfile, size_t line_count) -{ - int z; - int x; - char **tmp; - t_map **parsed_map; - size_t i; - - z = 0; - parsed_map = ft_calloc(sizeof(t_map *), line_count); - while (mapfile[z]) - { - tmp = ft_split(mapfile[z], 32); - i = ft_countline(tmp); - parsed_map[z] = ft_calloc(i, sizeof(t_map *)); - x = 0; - while (tmp[x]) - { - parsed_map[z][x] = ft_split_height_color(tmp[x]); - x++; - } - parsed_map[z][x] = NULL; - z++; - } - parsed_map[z] = NULL; - return (parsed_map); -} - char **ft_read_map(int fd, size_t map_size) { size_t i; @@ -127,44 +74,23 @@ char **ft_read_map(int fd, size_t map_size) return (map); } -t_map **ft_getmap(char *file) +t_map **ft_get_map(char *file) { - t_map **map_parsed; - char **map; + t_map **parsed_map; + char **map_read; int fd; - size_t line_nb; + int map_size; fd = open(file, O_RDONLY); - line_nb = ft_countline_fd(fd); - close(fd); + map_size = ft_countline_fd(fd); + close (fd); fd = open(file, O_RDONLY); - map = ft_read_map(fd, line_nb); - close(fd); - map_parsed = ft_parse_map(map, line_nb); - ft_free((void **)map); - return (map_parsed); + map_read = ft_read_map(fd, map_size); + close (fd); + return (parsed_map); } int main(int ac, char **av) { - t_map **map; - int i = 0; - char *file_name; - - file_name = ft_strdup(av[1]); - map = ft_getmap(file_name); - (void)ac; - ft_putstr("map read\n"); - while (map[i]) - { - ft_printf("%s", map[i]->color); - ft_putchar('\n'); - ft_putnbr(map[i]->y); - ft_putchar('\n'); - i++; - } - ft_free((void **)map); - return(0); + return (0); } - -//cc maps_reader.c fdf.h get_next_line/get_next_line.c get_next_line/get_next_line.h get_next_line/get_next_line_utils.c libft/libft.a \ No newline at end of file diff --git a/pyramide.fdf b/pyramide.fdf index 4750db0..e1f0cf0 100644 --- a/pyramide.fdf +++ b/pyramide.fdf @@ -1,4 +1,4 @@ -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0xFFAAAA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0