fix: correct error exit code when texture has error

This commit is contained in:
Khaïs COLIN 2025-08-05 15:10:12 +02:00
parent a4d85c3cbb
commit a46fdff49a
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 6 additions and 6 deletions

View file

@ -58,7 +58,7 @@ void free_map(t_mapdata *map)
free(map);
}
int destroy(t_cub3d_data *data)
int destroy(t_cub3d_data *data, int exit_code)
{
free_map(data->map);
if (data->mlx_win)
@ -82,7 +82,7 @@ int destroy(t_cub3d_data *data)
mlx_destroy_display(data->mlx);
free(data->mlx);
free(data->screen_matrix);
exit(0);
exit(exit_code);
return (0);
}

View file

@ -16,7 +16,7 @@
# include "../cub3d_data.h"
void gnl_exhaust(int fd);
int destroy(t_cub3d_data *data);
int destroy(t_cub3d_data *data, int exit_code);
void free_tab(char **tab);
void free_tab_length(char **tab, int length);
void free_map(t_mapdata *map);

View file

@ -22,7 +22,7 @@
int keypress_handler(int keycode, t_cub3d_data *data)
{
if (keycode == XK_Escape)
destroy(data);
destroy(data, 0);
if (keycode == XK_w)
data->keypresses.is_w_pressed = true;
if (keycode == XK_a)

View file

@ -28,12 +28,12 @@ t_img_data *load_single_texture(t_cub3d_data *data, char *path)
if (img == NULL)
{
ft_printf("Error: failed to open image at %s\n", path);
destroy(data);
destroy(data, 1);
}
if (width != height || width != TEXTURE_SIZE)
{
ft_printf("Error: textures are not the right size\n");
destroy(data);
destroy(data, 1);
}
ft_printf("image: %p\n", img);
img_data = ft_calloc(sizeof(t_img_data), 1);