aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d_structs.h1
-rw-r--r--src/ft_exit.c5
-rw-r--r--src/ft_init_lists.c1
-rw-r--r--src/ft_tex_init.c1
4 files changed, 6 insertions, 2 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index 46e4fe4..f6b42e6 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -131,6 +131,7 @@ typedef struct s_cub
{
uint8_t w_side;
uint8_t ishud;
+ uint8_t walltexgood;
uint16_t currlvl;
uint16_t i;
char errmsg[64];
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 4914803..b2efe2f 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -41,7 +41,7 @@ static void
int
ft_exit(uint8_t exit_code, t_cub *clist)
{
- if (clist->wlist->inited)
+ if (clist->walltexgood)
{
if (clist->tlist[0].img)
mlx_destroy_image(clist->wlist->wlx, clist->tlist[0].img);
@@ -55,8 +55,9 @@ int
mlx_destroy_image(clist->wlist->wlx, clist->tlist[4].img);
if (clist->mlist->isnlvl && clist->tlist[5].img)
mlx_destroy_image(clist->wlist->wlx, clist->tlist[5].img);
- mlx_destroy_window(clist->wlist->wlx, clist->wlist->winptr);
}
+ if (clist->wlist->inited)
+ mlx_destroy_window(clist->wlist->wlx, clist->wlist->winptr);
ft_free_lists(clist);
ft_printf("Exiting program\n");
exit(exit_code);
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index f451220..055fd98 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -86,6 +86,7 @@ static t_cub
clist->c_rgb = ft_init_rgb();
clist->rlist = ft_init_s_ray();
clist->currlvl = 0;
+ clist->walltexgood = 0;
clist->key_ptr[0] = ft_w_key;
clist->key_ptr[1] = ft_a_key;
clist->key_ptr[2] = ft_s_key;
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c
index 0e5cb69..6e12a56 100644
--- a/src/ft_tex_init.c
+++ b/src/ft_tex_init.c
@@ -58,4 +58,5 @@ void
&cl->tlist[4].bpp, &cl->tlist[4].sizeline, &cl->tlist[4].endian);
if (cl->mlist->isnlvl)
ft_get_nlvl_img(cl);
+ cl->walltexgood = 1;
}