aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_warp_level.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_warp_level.c')
-rw-r--r--src/ft_warp_level.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 56d4d67..a2b6006 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -23,41 +23,36 @@
static void
ft_del_map(t_map *ml)
{
- ft_memdel((void**)&ml->filename);
- ft_memdel((void**)&ml->no_tex_path);
- ft_memdel((void**)&ml->so_tex_path);
- ft_memdel((void**)&ml->ea_tex_path);
- ft_memdel((void**)&ml->we_tex_path);
- ft_memdel((void**)&ml->nl_tex_path);
- ft_memdel((void**)&ml->fl_tex_path);
- ft_memdel((void**)&ml->ce_tex_path);
- ft_memdel((void**)&ml->nlevel_path);
- ft_memdel((void**)&ml->skybox_path);
- ft_memdel((void**)&ml->traps_path);
- ft_memdel((void**)&ml->music_path);
- ft_memdel((void**)&ml->music_cmd);
- ft_memdel((void**)&ml->mapl);
+ ft_memdel((void*)&ml->filename);
+ ft_memdel((void*)&ml->no_tex_path);
+ ft_memdel((void*)&ml->so_tex_path);
+ ft_memdel((void*)&ml->ea_tex_path);
+ ft_memdel((void*)&ml->we_tex_path);
+ ft_memdel((void*)&ml->nl_tex_path);
+ ft_memdel((void*)&ml->fl_tex_path);
+ ft_memdel((void*)&ml->ce_tex_path);
+ ft_memdel((void*)&ml->nlevel_path);
+ ft_memdel((void*)&ml->skybox_path);
+ ft_memdel((void*)&ml->traps_path);
+ 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);
}
static void
ft_del_some(t_cub *cl)
{
- uint8_t i;
+ int8_t i;
cl->plist = ft_init_player();
cl->f_rgb = ft_init_rgb();
cl->c_rgb = ft_init_rgb();
cl->rlist = ft_init_s_ray();
- i = 0;
- while (i < 5)
- {
+ i = -1;
+ while (++i < 5)
mlx_destroy_image(cl->wlist.wlx, cl->tlist[i].img);
- cl->tlist[i].ptr = NULL;
- i++;
- }
if (cl->mlist.isnlvl && cl->tlist[5].img)
mlx_destroy_image(cl->wlist.wlx, cl->tlist[5].img);
if (cl->mlist.isftex && cl->tlist[6].img)
@@ -66,7 +61,15 @@ static void
mlx_destroy_image(cl->wlist.wlx, cl->tlist[7].img);
if (cl->mlist.istraps && cl->tlist[15].img)
mlx_destroy_image(cl->wlist.wlx, cl->tlist[15].img);
+ if (cl->tlist[16].img)
+ 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);
ft_del_extra_sprites(cl);
+ i = -1;
+ while (++i < 8)
+ ft_memdel((void*)&cl->sprites[i]);
+ ft_memdel((void*)&cl->sprites);
}
static void
@@ -74,15 +77,15 @@ static void
{
if (isoldmus && !cl->mlist.ismusic)
{
- kill(cl->mpid, SIGTERM);
- wait(&cl->mpid);
+ pthread_cancel(cl->mtid);
+ pthread_join(cl->mtid, NULL);
cl->isoldmus = 0;
}
else if (isoldmus && cl->mlist.ismusic
&& ft_strncmp(tmp_mup, cl->mlist.music_path, ft_strlen(tmp_mup) + 1))
{
- kill(cl->mpid, SIGTERM);
- wait(&cl->mpid);
+ pthread_cancel(cl->mtid);
+ pthread_join(cl->mtid, NULL);
ft_enable_music(cl);
}
else if (isoldmus && cl->mlist.ismusic
@@ -104,13 +107,15 @@ int8_t
tmp_mup = ft_strdup(cl->mlist.music_path);
ft_del_some(cl);
ft_del_map(&cl->mlist);
+ if (ft_init_sprites(&cl->sprites) < 0)
+ return (-1);
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_memdel((void*)&tmp_mup);
ft_wall_tex_init(cl);
- ft_memdel((void**)&next_path);
+ ft_memdel((void*)&next_path);
return (0);
}