From 7acb059c2090036edfccc8298d0f514409a7c264 Mon Sep 17 00:00:00 2001 From: aortigos Date: Fri, 5 Dec 2025 16:30:53 +0100 Subject: [PATCH] Textures files created --- includes/cub3d.h | 59 +++++++++++++++--------- src/parsing/textures.c | 70 ++++++++++++++++++++++++++++ src/parsing/textures_utils.c | 88 ++++++++++++++++++++++++++++++++++++ src/parsing/valid_map.c | 13 ++++++ 4 files changed, 208 insertions(+), 22 deletions(-) create mode 100644 src/parsing/textures.c create mode 100644 src/parsing/textures_utils.c create mode 100644 src/parsing/valid_map.c diff --git a/includes/cub3d.h b/includes/cub3d.h index 5b3588e..8b1c0a4 100644 --- a/includes/cub3d.h +++ b/includes/cub3d.h @@ -6,7 +6,7 @@ /* By: aortigos 255 || ft_atoi(rgb[i]) < 0) + return (free2d(rgb), 0); + return (free2d(rgb), 1); +} + +void ft_process_rgb_color(t_turelist *tmp, t_data *m) +{ + if (!f_strncmp(tmp->name, "F", 2)) + m->ff = ft_split(tmp->value, ','); + else if(!ft_strncmp(tmp->name, "C", 2)) + m->cc = ft_split(tmp->value, ','); + return ; +} + +int color_ture(t_data *m, t_turelist *l_ture) +{ + t_turelist *tmp; + + m->cc = NULL; + m->ff = NULL; + tmp = l_ture; + while (tmp) + { + if (!ft_strncmp(tmp->name, "F", 1) || !ft_strncmp(tmp->name, "C", 1)) + { + if (!check_color_values(ft_split(tmp->value, ','))) + return (ft_putstr_fd(ERR_MAP_RGB, 2), 0); + ft_process_rgb_color(tmp, m); + } + tmp = tmp->next; + } + return (1); +} + +int check_color_textures(char *line) +{ + while (ft_isspace(*line)) + line++; + return ((!ft_strncmp(line, "EA", 2) || !ft_strncmp(line, "NO", 2) + || !ft_strncmp(line, "SO", 2) || !ft_strncmp(line, "WE", 2)) + || (!ft_strncmp(line, "F", 1) || !ft_strncmp(line, "C", 1))); +} + +int check_count_textures(t_data *m, int count) +{ + (void)m; + if (count != 6) + return (ft_putstr_fd(ERR_MAP_INV, 2), 0); + return (1); +} diff --git a/src/parsing/textures_utils.c b/src/parsing/textures_utils.c new file mode 100644 index 0000000..691ce99 --- /dev/null +++ b/src/parsing/textures_utils.c @@ -0,0 +1,88 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* textures_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: aortigos