diff --git a/includes/cub3d_struct.h b/includes/cub3d_struct.h index 130df45..674695d 100644 --- a/includes/cub3d_struct.h +++ b/includes/cub3d_struct.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/28 13:53:54 by bgoulard #+# #+# */ -/* Updated: 2024/12/16 14:15:43 by bgoulard ### ########.fr */ +/* Updated: 2024/12/17 16:52:53 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -138,6 +138,7 @@ typedef enum e_error ERROR_CLI, ERROR_MLX, ERROR_TEXTURE_FORMAT, + ERROR_TEXTURE_MISSING, ERROR_IMPLEM, } t_error; diff --git a/parsing/load_textures.c b/parsing/load_textures.c index ae608ec..26703dc 100644 --- a/parsing/load_textures.c +++ b/parsing/load_textures.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/01 17:46:52 by bgoulard #+# #+# */ -/* Updated: 2024/12/16 14:25:52 by bgoulard ### ########.fr */ +/* Updated: 2024/12/17 16:58:30 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -68,5 +68,13 @@ void *load_textures(void *data) return (NULL); i++; } + i = 0; + errno = 0; + while (i < sizeof(info->map.texture_) / sizeof(info->map.texture_[0])) + { + if (info->map.texture_[i].img == NULL || info->map.texture[i] == NULL) + return (sv_errno(info, ERROR_TEXTURE_MISSING), NULL); + i++; + } return (info); } diff --git a/sources/error.c b/sources/error.c index a417867..5d48182 100644 --- a/sources/error.c +++ b/sources/error.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */ -/* Updated: 2024/12/16 15:17:33 by bgoulard ### ########.fr */ +/* Updated: 2024/12/17 17:06:42 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,22 +21,23 @@ const char **get_error_message(void) { static const char *error_messages[] = { - [NO_ERROR] = "no error", - [ERROR_UNKNOWN] = "unknown error", - [ERROR_OPEN_FILE] = "could not open file", - [ERROR_READ_FILE] = "could not read file", - [ERROR_EXTENSION_FILE] = "bad file extension", - [ERROR_NAME_FILE] = "invalid file name", - [ERROR_MISSING_FILE] = "missing file", - [ERROR_MALLOC] = "malloc error", - [ERROR_PARSE] = "parse error", - [ERROR_MAP_OPEN] = "map open error", - [ERROR_PARSE_BG_COLOR_FORMAT] = "bad format for background color", - [ERROR_PARSE_ALREADY_SET] = "variable was set multiple times", - [ERROR_CLI] = "cli error", - [ERROR_MLX] = "mlx error", - [ERROR_TEXTURE_FORMAT] = "texture format error", - [ERROR_IMPLEM] = "not implemented", + [NO_ERROR] = "no error", + [ERROR_UNKNOWN] = "unknown error", + [ERROR_OPEN_FILE] = "could not open file", + [ERROR_READ_FILE] = "could not read file", + [ERROR_EXTENSION_FILE] = "bad file extension", + [ERROR_NAME_FILE] = "invalid file name", + [ERROR_MISSING_FILE] = "missing file", + [ERROR_MALLOC] = "malloc error", + [ERROR_PARSE] = "parse error", + [ERROR_MAP_OPEN] = "map open error", + [ERROR_PARSE_BG_COLOR_FORMAT] = "bad format for background color", + [ERROR_PARSE_ALREADY_SET] = "variable was set multiple times", + [ERROR_CLI] = "cli error", + [ERROR_MLX] = "mlx error", + [ERROR_TEXTURE_FORMAT] = "texture format error", + [ERROR_IMPLEM] = "not implemented", + [ERROR_TEXTURE_MISSING] = "texture missing", }; return (error_messages); @@ -44,7 +45,7 @@ const char **get_error_message(void) void c3_perror(t_info *info) { - const char **errs_msg = get_error_message(); + const char **errs_msg = get_error_message(); if (info->last_error == NO_ERROR) return ; diff --git a/sources/main.c b/sources/main.c index e8e3e01..c6388e0 100644 --- a/sources/main.c +++ b/sources/main.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/30 16:30:03 by rparodi #+# #+# */ -/* Updated: 2024/12/16 15:20:34 by bgoulard ### ########.fr */ +/* Updated: 2024/12/17 16:55:25 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,7 +43,7 @@ void run_cub3d(t_info *info) if (info->cli_ctx.debug) ft_putstr_fd("no debug mod on production run", STDERR_FILENO); if (info->last_error != NO_ERROR) - return (c3_perror(info)); + return ; if (info->cli_ctx.no_graphics == true) return ; info->camera.screen_buff = mlx_new_image(info->mlx_ptr, info->screen_size.x,