diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-19 14:05:44 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-19 14:05:44 +0100 |
commit | 21e2dbe87e9d95ceac06e34ab5d80bbe6d6d7635 (patch) | |
tree | ee15ce26a61bacb41f685bdbe160f1879d996ee5 | |
parent | Correct init and frees (diff) | |
download | 42-cub3d-21e2dbe87e9d95ceac06e34ab5d80bbe6d6d7635.tar.gz 42-cub3d-21e2dbe87e9d95ceac06e34ab5d80bbe6d6d7635.tar.bz2 42-cub3d-21e2dbe87e9d95ceac06e34ab5d80bbe6d6d7635.tar.xz 42-cub3d-21e2dbe87e9d95ceac06e34ab5d80bbe6d6d7635.tar.zst 42-cub3d-21e2dbe87e9d95ceac06e34ab5d80bbe6d6d7635.zip |
Okok
-rw-r--r-- | inc/cub3d_defines.h | 2 | ||||
-rw-r--r-- | src/ft_check_map_line.c | 24 | ||||
-rw-r--r-- | src/ft_exit.c | 8 | ||||
-rw-r--r-- | src/ft_tex_weap_init.c | 8 |
4 files changed, 23 insertions, 19 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index a4f93c1..25f24cd 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -199,6 +199,8 @@ enum # define FT_ERR_WR_BMP "could not export to bmp" # define FT_ERR_TOO_MUCH_HEALS "too much heal packs, limit is 64" # define FT_ERR_TOO_MUCH_TRAPS "too much traps, limit is 512" +# define FT_ERR_TOO_MUCH_W_ONE "too much weapon one, limit is 1" +# define FT_ERR_TOO_MUCH_W_TWO "too much weapon two, limit is 1" /* ** ====== MISSING ERROR MSG ====== diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c index 50464a9..9419ab2 100644 --- a/src/ft_check_map_line.c +++ b/src/ft_check_map_line.c @@ -16,30 +16,32 @@ #include <stdint.h> static int8_t - ft_first_checks(char *line, size_t i, t_cub *clist) + ft_first_checks(char *line, size_t i, t_cub *cl) { if (!ft_ischarset(FT_CHRST_MAP_ENTRY, line[i])) { - ft_sprintf(clist->errmsg, FT_ERR_ILL_MAP); + ft_sprintf(cl->errmsg, FT_ERR_ILL_MAP); return (-1); } if (ft_ischarset(FT_CHRST_SPAWN, line[i])) - clist->mlist.isspawn += 1; - if (clist->mlist.isspawn > 1) + cl->mlist.isspawn += 1; + if (cl->mlist.isspawn > 1) { - ft_sprintf(clist->errmsg, FT_ERR_MULT_SPAWN); + ft_sprintf(cl->errmsg, FT_ERR_MULT_SPAWN); return (-1); } if (line[i] == 'L') - clist->mlist.isnlvl += 1; - if (clist->mlist.isnlvl > 1) + cl->mlist.isnlvl += 1; + if (cl->mlist.isnlvl > 1) { - ft_sprintf(clist->errmsg, FT_ERR_MULT_NLVL); + ft_sprintf(cl->errmsg, FT_ERR_MULT_NLVL); return (-1); } - clist->mlist.istraps = (line[i] == 'T') ? (1) : (clist->mlist.istraps); - clist->mlist.isheals = (line[i] == '+') ? (1) : (clist->mlist.isheals); - ft_get_topsp(line[i], clist); + cl->mlist.istraps = (line[i] == 'T') ? (1) : (cl->mlist.istraps); + cl->mlist.isheals = (line[i] == '+') ? (1) : (cl->mlist.isheals); + cl->mlist.isweapon[0] = (line[i] == '!') ? (1) : (cl->mlist.isweapon[0]); + cl->mlist.isweapon[1] = (line[i] == '@') ? (1) : (cl->mlist.isweapon[1]); + ft_get_topsp(line[i], cl); return (0); } diff --git a/src/ft_exit.c b/src/ft_exit.c index f0a25e0..1f47f02 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -92,6 +92,14 @@ static void 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); + 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(clist); } diff --git a/src/ft_tex_weap_init.c b/src/ft_tex_weap_init.c index b17255a..ac78de9 100644 --- a/src/ft_tex_weap_init.c +++ b/src/ft_tex_weap_init.c @@ -43,12 +43,4 @@ 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); } |