mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
fix: correct error exit code when texture has error
This commit is contained in:
parent
a4d85c3cbb
commit
a46fdff49a
4 changed files with 6 additions and 6 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue