v1.0.1 - masked trailing global to singleton and deleted trailing files from repo

This commit is contained in:
B.Goulard 2024-12-16 15:29:18 +01:00
parent 3f43074d05
commit e14340f124
23 changed files with 68 additions and 1650 deletions

View file

@ -6,10 +6,11 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */
/* Updated: 2024/12/16 14:37:11 by bgoulard ### ########.fr */
/* Updated: 2024/12/16 15:17:33 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d_struct.h"
#include "ft_string.h"
#include "cub3d.h"
@ -17,30 +18,37 @@
#include <unistd.h>
static const char *g_error_message[] = {
"no error",
"unknown error",
"could not open file",
"could not read file",
"bad file extension",
"invalid file name",
"missing file",
"malloc error",
"parse error",
"map open error",
"bad format for background color",
"variable was set multiple times",
"cli error",
"mlx error",
"texture format error",
"not implemented",
};
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",
};
return (error_messages);
}
void c3_perror(t_info *info)
{
const char **errs_msg = get_error_message();
if (info->last_error == NO_ERROR)
return ;
print_error(g_error_message[info->last_error], info->errno_state);
print_error(errs_msg[info->last_error], info->errno_state);
}
void print_error(const char *msg, int state)

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 16:30:03 by rparodi #+# #+# */
/* Updated: 2024/12/16 09:38:44 by bgoulard ### ########.fr */
/* Updated: 2024/12/16 15:20:34 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,8 +25,8 @@ void check_err(t_info *info)
{
if (info->cli_ctx.file == NULL)
return (info->last_error = ERROR_MISSING_FILE, (void)0);
else if (ft_strlen(info->cli_ctx.file) < 5)
return (info->last_error = ERROR_NAME_FILE, (void)0);
else if (ft_strlen(info->cli_ctx.file) < ft_strlen(FILE_EXTENSION))
return (info->last_error = ERROR_EXTENSION_FILE, (void)0);
else if (ft_strend_with(info->cli_ctx.file, FILE_EXTENSION) == false)
return (info->last_error = ERROR_EXTENSION_FILE, (void)0);
info->map.fd = open(info->cli_ctx.file, O_RDONLY);
@ -38,12 +38,12 @@ void check_err(t_info *info)
void run_cub3d(t_info *info)
{
if (init_mlx_env(info) != NO_ERROR)
return ;
return (c3_perror(info));
parse_map(info);
if (info->cli_ctx.debug)
ft_putstr_fd("no debug mod on production run", STDERR_FILENO);
if (info->last_error != NO_ERROR)
return ;
return (c3_perror(info));
if (info->cli_ctx.no_graphics == true)
return ;
info->camera.screen_buff = mlx_new_image(info->mlx_ptr, info->screen_size.x,