diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-02 19:44:47 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-02 19:44:47 +0100 |
commit | 888e9d30cbf4efde17ee337b9b97f1960bbd74a2 (patch) | |
tree | 68790739652458a8242074983d28c846ceb3cb77 /src/ft_warp_level.c | |
parent | Multilvl image leaks, rest is okok (diff) | |
download | 42-cub3d-888e9d30cbf4efde17ee337b9b97f1960bbd74a2.tar.gz 42-cub3d-888e9d30cbf4efde17ee337b9b97f1960bbd74a2.tar.bz2 42-cub3d-888e9d30cbf4efde17ee337b9b97f1960bbd74a2.tar.xz 42-cub3d-888e9d30cbf4efde17ee337b9b97f1960bbd74a2.tar.zst 42-cub3d-888e9d30cbf4efde17ee337b9b97f1960bbd74a2.zip |
Music is pretty bav
Diffstat (limited to 'src/ft_warp_level.c')
-rw-r--r-- | src/ft_warp_level.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 41d1a45..de87187 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -53,23 +53,41 @@ static void cl->c_rgb = ft_init_rgb(); cl->rlist = ft_init_s_ray(); i = 0; - while (i < 5) + while (i <= 5) { mlx_destroy_image(cl->wlist->wlx, cl->tlist[i].img); cl->tlist[i].img = NULL; i++; } - if (cl->mlist->ismusic) +} + +static void + ft_treat_music(uint8_t isoldmus, char *tmp_mup, t_cub *cl) +{ + if (isoldmus && !cl->mlist->ismusic) + { + pthread_cancel(cl->tid); + pthread_join(cl->tid, NULL); + cl->isoldmus = 0; + } + else if (isoldmus && cl->mlist->ismusic + && ft_strncmp(tmp_mup, cl->mlist->music_path, ft_strlen(tmp_mup) + 1)) { pthread_cancel(cl->tid); pthread_join(cl->tid, NULL); + pthread_create(&cl->tid, NULL, ft_music_thread, cl); } + else if (isoldmus && cl->mlist->ismusic + && !ft_strncmp(tmp_mup, cl->mlist->music_path, ft_strlen(tmp_mup) + 1)) + return ; } int8_t ft_warp_level(t_cub *cl) { char *next_path; + char *tmp_mup; + uint8_t isoldmus; if ((uint32_t)cl->plist->pos_x == cl->mlist->nlx && (uint32_t)cl->plist->pos_y == cl->mlist->nly) @@ -78,11 +96,17 @@ int8_t cl->mlist->nlevel_path) + 1) * sizeof(char)))) return (-1); ft_sprintf(next_path, "%s", cl->mlist->nlevel_path); + isoldmus = cl->mlist->ismusic; + if (isoldmus) + tmp_mup = ft_strdup(cl->mlist->music_path); ft_del_some(cl); ft_del_map(cl->mlist); if (!(cl->mlist = ft_init_map())) 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); } |