aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-21 22:06:14 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-21 22:06:14 +0100
commitd669957a4917d5928ca1a10d635409891ec19ed0 (patch)
treed405206f4d9f9d97280be3c97d814535cea44499
parentfixed most valgrind bullshit (diff)
download42-cub3d-d669957a4917d5928ca1a10d635409891ec19ed0.tar.gz
42-cub3d-d669957a4917d5928ca1a10d635409891ec19ed0.tar.bz2
42-cub3d-d669957a4917d5928ca1a10d635409891ec19ed0.tar.xz
42-cub3d-d669957a4917d5928ca1a10d635409891ec19ed0.tar.zst
42-cub3d-d669957a4917d5928ca1a10d635409891ec19ed0.zip
Few fixes
Diffstat (limited to '')
-rw-r--r--inc/cub3d_defines.h22
-rw-r--r--map/map_three.cub2
-rw-r--r--src/ft_exit.c29
-rw-r--r--src/ft_init_lists.c2
-rw-r--r--src/ft_init_winlx.c1
5 files changed, 31 insertions, 25 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 5e7a143..6148cd2 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -15,16 +15,18 @@
/*
** ====== RETURN VALUES ======
-*/
-
-/*
+**
** ret vals:
+** ---------
** 1: no argv[1]
-** 2: failed structs init
-** 3: failed mlx init
-** 4: map error
-** 5: no map
-** 6: read error
+** 2: allocation error
+** 3: failed structs init
+** 4: failed mlx init
+** 5: map error
+** 6: no map
+** 7: read error
+** 8: bmp related error
+** 9: missing some media files
*/
enum
@@ -43,9 +45,7 @@ enum
/*
** ====== OS ======
-*/
-
-/*
+**
** 1: Darwin
** 2: Linux
*/
diff --git a/map/map_three.cub b/map/map_three.cub
index 5b84682..18f3854 100644
--- a/map/map_three.cub
+++ b/map/map_three.cub
@@ -21,7 +21,7 @@ SH 4
120001
120001
120001
-1111111111111111001
+ 111001
1111111111111111001
1E00000000000000001
1111111111111111111
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 4c89bc6..8bf79ce 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -29,21 +29,24 @@ static void
ft_memdel((void*)&clist->sprites[i]);
i++;
}
- i = 0;
- while (i < 4)
- {
- if (clist->tweap[i].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tweap[i].img);
- i++;
- }
- i = 0;
- while (i < 2)
+ ft_memdel((void*)&clist->sprites);
+ if (clist->wlist.inited)
{
- if (clist->tlist[i + 18].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[i + 18].img);
- i++;
+ i = 0;
+ while (i < 4)
+ {
+ if (clist->tweap[i].img)
+ mlx_destroy_image(clist->wlist.wlx, clist->tweap[i].img);
+ i++;
+ }
+ i = 0;
+ while (i < 2)
+ {
+ if (clist->tlist[i + 18].img)
+ mlx_destroy_image(clist->wlist.wlx, clist->tlist[i + 18].img);
+ i++;
+ }
}
- ft_memdel((void*)&clist->sprites);
if (!clist->wlist.inited)
{
ft_memdel((void*)&clist->wlist.winptr);
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index 29771a5..e94e688 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -61,6 +61,8 @@ t_player
static int8_t
ft_init_win(t_win *wl)
{
+ if (!(wl->wlx = malloc(1)))
+ return (-1);
if (!(wl->winptr = malloc(1)))
return (-1);
wl->inited = 0;
diff --git a/src/ft_init_winlx.c b/src/ft_init_winlx.c
index 59d0b58..40c57df 100644
--- a/src/ft_init_winlx.c
+++ b/src/ft_init_winlx.c
@@ -18,6 +18,7 @@
int
ft_init_winlx(t_cub *clist)
{
+ ft_memdel((void*)&clist->wlist.wlx);
if (!(clist->wlist.wlx = mlx_init()))
return (-1);
return (0);