diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-03-12 18:56:59 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-03-12 18:56:59 +0100 |
commit | 141fb4d33f73cac99b1b19e475f83fb755f208a2 (patch) | |
tree | e93c2d490440caee29f2c85d86c9dc9bd8512a28 /src/ft_warp_level.c | |
parent | kk (diff) | |
download | 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.gz 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.bz2 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.xz 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.tar.zst 42-cub3d-141fb4d33f73cac99b1b19e475f83fb755f208a2.zip |
good
Diffstat (limited to 'src/ft_warp_level.c')
-rw-r--r-- | src/ft_warp_level.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 5b1a821..7a04dc9 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -28,7 +28,6 @@ static void ft_memdel((void**)&ml->so_tex_path); ft_memdel((void**)&ml->ea_tex_path); ft_memdel((void**)&ml->we_tex_path); - ft_free_words(ml->sprite_path); ft_memdel((void**)&ml->nl_tex_path); ft_memdel((void**)&ml->fl_tex_path); ft_memdel((void**)&ml->ce_tex_path); @@ -38,6 +37,7 @@ static void ft_memdel((void**)&ml->music_path); ft_memdel((void**)&ml->music_cmd); ft_memdel((void**)&ml->mapl); + ft_free_sprites(ml->sprite_path); ft_free_words(ml->map); ft_free_words(ml->mcmd_words); } @@ -52,11 +52,16 @@ static void cl->c_rgb = ft_init_rgb(); cl->rlist = ft_init_s_ray(); i = -1; - while (++i <= 5) + while (++i < 5) { mlx_destroy_image(cl->wlist.wlx, cl->tlist[i].img); cl->tlist[i].img = NULL; } + if (cl->mlist.isnlvl && cl->tlist[5].img) + { + mlx_destroy_image(cl->wlist.wlx, cl->tlist[5].img); + cl->tlist[5].img = NULL; + } if (cl->mlist.isftex && cl->tlist[6].img) mlx_destroy_image(cl->wlist.wlx, cl->tlist[6].img); if (cl->mlist.isctex && cl->tlist[7].img) @@ -87,27 +92,26 @@ static void } int8_t - ft_warp_level(t_cub *cl) + ft_warp_level(char *path, t_cub *cl) { char *next_path; char *tmp_mup; uint8_t isoldmus; - if (!(next_path = (char *)malloc((ft_strlen( - cl->mlist.nlevel_path) + 1) * sizeof(char)))) - return (-1); - ft_sprintf(next_path, "%s", cl->mlist.nlevel_path); - if ((isoldmus = cl->mlist.ismusic)) - tmp_mup = ft_strdup(cl->mlist.music_path); - ft_del_some(cl); - ft_del_map(&cl->mlist); - if (ft_init_map(&cl->mlist) < 0) - return (-1); - ft_parse_map(next_path, cl); - ft_treat_music(isoldmus, tmp_mup, cl); - if (isoldmus) - ft_memdel((void**)&tmp_mup); - ft_wall_tex_init(cl); - ft_memdel((void**)&next_path); + if (!(next_path = (char *)malloc((ft_strlen(path) + 1) * sizeof(char)))) + return (-1); + ft_sprintf(next_path, "%s", path); + if ((isoldmus = cl->mlist.ismusic)) + tmp_mup = ft_strdup(cl->mlist.music_path); + ft_del_some(cl); + ft_del_map(&cl->mlist); + if (ft_init_map(&cl->mlist) < 0) + return (-1); + ft_parse_map(next_path, cl); + ft_treat_music(isoldmus, tmp_mup, cl); + if (isoldmus) + ft_memdel((void**)&tmp_mup); + ft_wall_tex_init(cl); + ft_memdel((void**)&next_path); return (0); } |