diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-19 14:00:59 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-19 14:00:59 +0100 |
commit | 1bd6b6e64b02ce70e193bb108843bc0ee5c051c3 (patch) | |
tree | 394788b4dc6f1248f44894798fc708e87f1bd8a1 | |
parent | Loaded weapon images needs to memory (diff) | |
download | 42-cub3d-1bd6b6e64b02ce70e193bb108843bc0ee5c051c3.tar.gz 42-cub3d-1bd6b6e64b02ce70e193bb108843bc0ee5c051c3.tar.bz2 42-cub3d-1bd6b6e64b02ce70e193bb108843bc0ee5c051c3.tar.xz 42-cub3d-1bd6b6e64b02ce70e193bb108843bc0ee5c051c3.tar.zst 42-cub3d-1bd6b6e64b02ce70e193bb108843bc0ee5c051c3.zip |
Correct init and frees
-rw-r--r-- | inc/cub3d_defines.h | 6 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 4 | ||||
-rw-r--r-- | src/ft_exit.c | 4 | ||||
-rw-r--r-- | src/ft_init_map.c | 7 | ||||
-rw-r--r-- | src/ft_tex_weap_init.c | 8 | ||||
-rw-r--r-- | src/ft_warp_level.c | 12 |
6 files changed, 37 insertions, 4 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index 8a435f2..a4f93c1 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -140,13 +140,13 @@ enum */ # define FT_CHRST_VALID_PARSE "RNSEWFCLMT" -# define FT_CHRST_MAP_ENTRY "0123456789NSEWLT+ " +# define FT_CHRST_MAP_ENTRY "0123456789NSEWLT!@+ " # define FT_CHRST_SPRITES "23456789" # define FT_CHRST_SPAWN "NSEW" -# define FT_CHRST_MAP_NON_WALL "023456789NESWLT+" +# define FT_CHRST_MAP_NON_WALL "023456789NESWLT!@+" # define FT_CHRST_COLLISION "123456789 " # define FT_CHRST_DETECT "1L" -# define FT_CHRST_ITEM "+!@" +# define FT_CHRST_ITEM "!@+" /* ** ====== BMP ====== diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 332ced4..174493d 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -207,8 +207,10 @@ typedef struct s_map int32_t sprite_order[8][4096]; int32_t traps_nbr; int32_t heals_nbr; + int32_t weaps_nbr[2]; int32_t traps_order[512]; int32_t heals_order[64]; + int32_t weaps_order[2][1]; size_t line_chk; size_t map_start; uint8_t isspawn; @@ -219,6 +221,7 @@ typedef struct s_map uint8_t isskybox; uint8_t istraps; uint8_t isheals; + uint8_t isweapon[2]; uint8_t darklvl; uint8_t scale; int8_t topsp; @@ -258,6 +261,7 @@ typedef struct s_cub struct s_sprite **sprites; struct s_sprite traps[512]; struct s_sprite heals[64]; + struct s_sprite weaps[2][1]; struct s_sfx sfx; } t_cub; diff --git a/src/ft_exit.c b/src/ft_exit.c index 390f234..f0a25e0 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -88,6 +88,10 @@ static void mlx_destroy_image(clist->wlist.wlx, clist->tlist[16].img); if (clist->mlist.isheals && clist->tlist[17].img) mlx_destroy_image(clist->wlist.wlx, clist->tlist[17].img); + if (clist->mlist.isweapon[0] && clist->tlist[18].img) + mlx_destroy_image(clist->wlist.wlx, clist->tlist[18].img); + if (clist->mlist.isweapon[1] && clist->tlist[19].img) + mlx_destroy_image(clist->wlist.wlx, clist->tlist[19].img); ft_del_extra_sprites(clist); } diff --git a/src/ft_init_map.c b/src/ft_init_map.c index 37fc858..f740fd8 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -57,6 +57,7 @@ static int8_t int8_t ft_init_map_norme(t_map *mlist) { + mlist->darklvl = 0; mlist->scale = 0; mlist->nlx = 0; mlist->nly = 0; @@ -65,6 +66,9 @@ int8_t ft_bzero(mlist->sprite_nbr, 4096); ft_bzero(mlist->sprite_order, 4096); ft_bzero(mlist->traps_order, 512); + ft_bzero(mlist->heals_order, 64); + ft_bzero(mlist->weaps_nbr, 2); + ft_bzero(mlist->weaps_order, 2); return (0); } @@ -91,8 +95,9 @@ int8_t mlist->isskybox = 0; mlist->istraps = 0; mlist->isheals = 0; + mlist->isweapon[0] = 0; + mlist->isweapon[1] = 0; mlist->traps_nbr = 0; mlist->heals_nbr = 0; - mlist->darklvl = 0; return (ft_init_map_norme(mlist)); } diff --git a/src/ft_tex_weap_init.c b/src/ft_tex_weap_init.c index ac78de9..b17255a 100644 --- a/src/ft_tex_weap_init.c +++ b/src/ft_tex_weap_init.c @@ -43,4 +43,12 @@ void FT_WEAPON_TWO_FIRE_PATH, &cl->tweap[3].img_w, &cl->tweap[3].img_h); cl->tweap[3].ptr = mlx_get_data_addr(cl->tweap[3].img, &cl->tweap[3].bpp, &cl->tweap[3].sizeline, &cl->tweap[3].endian); + if (cl->tweap[0].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[0].img); + if (cl->tweap[1].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[1].img); + if (cl->tweap[2].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[2].img); + if (cl->tweap[3].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[3].img); } diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 09f0322..d6a3d7f 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -65,6 +65,18 @@ static void mlx_destroy_image(cl->wlist.wlx, cl->tlist[16].img); if (cl->mlist.isheals && cl->tlist[17].img) mlx_destroy_image(cl->wlist.wlx, cl->tlist[17].img); + if (cl->mlist.isweapon[0] && cl->tlist[18].img) + mlx_destroy_image(cl->wlist.wlx, cl->tlist[18].img); + if (cl->mlist.isweapon[1] && cl->tlist[19].img) + mlx_destroy_image(cl->wlist.wlx, cl->tlist[19].img); + if (cl->tweap[0].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[0].img); + if (cl->tweap[1].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[1].img); + if (cl->tweap[2].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[2].img); + if (cl->tweap[3].img) + mlx_destroy_image(cl->wlist.wlx, cl->tweap[3].img); ft_del_extra_sprites(cl); i = -1; while (++i < 8) |