From 9f35e7fab50809cd74e3bfffff67a81023abc837 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 15 Mar 2020 01:02:32 +0100 Subject: I need a macOS --- src/ft_exit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/ft_exit.c') diff --git a/src/ft_exit.c b/src/ft_exit.c index f1da643..60e950a 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -38,7 +38,6 @@ static void ft_memdel((void**)&clist->mlist.music_cmd); ft_memdel((void**)&clist->mlist.mapl); ft_free_words(clist->mlist.map); - ft_free_words(clist->mlist.mcmd_words); ft_free_words(clist->sfx.death); ft_free_words(clist->sfx.pain_one); ft_free_words(clist->sfx.pain_two); @@ -77,9 +76,11 @@ static void { pid_t tmp; - if (!(tmp = waitpid(clist->mpid, NULL, WNOHANG))) - kill(clist->mpid, SIGTERM); - wait(&clist->mpid); + if (clist->isoldmus && clist->wlist.inited) + { + pthread_cancel(clist->mtid); + pthread_join(clist->mtid, NULL); + } if (!(tmp = waitpid(clist->sfx.death_pid, NULL, WNOHANG))) kill(clist->sfx.death_pid, SIGTERM); wait(&clist->sfx.death_pid); -- cgit v1.2.3 From b992ca41965edf663f99bae19a95d59f2fd1ed97 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 15 Mar 2020 02:15:01 +0100 Subject: okok --- src/ft_exit.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/ft_exit.c') diff --git a/src/ft_exit.c b/src/ft_exit.c index 60e950a..3cd933a 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -39,8 +39,8 @@ static void ft_memdel((void**)&clist->mlist.mapl); ft_free_words(clist->mlist.map); ft_free_words(clist->sfx.death); - ft_free_words(clist->sfx.pain_one); - ft_free_words(clist->sfx.pain_two); + ft_memdel((void**)&clist->sfx.pain_one); + ft_memdel((void**)&clist->sfx.pain_two); ft_free_words(clist->sfx.trap); ft_free_sprites(clist->mlist.sprite_path); if (!clist->wlist.inited) @@ -81,15 +81,13 @@ static void pthread_cancel(clist->mtid); pthread_join(clist->mtid, NULL); } + pthread_cancel(clist->sfx.pain_tid); if (!(tmp = waitpid(clist->sfx.death_pid, NULL, WNOHANG))) kill(clist->sfx.death_pid, SIGTERM); wait(&clist->sfx.death_pid); if (!(tmp = waitpid(clist->sfx.new_lvl_pid, NULL, WNOHANG))) kill(clist->sfx.new_lvl_pid, SIGTERM); wait(&clist->sfx.new_lvl_pid); - if (!(tmp = waitpid(clist->sfx.pain_pid, NULL, WNOHANG))) - kill(clist->sfx.pain_pid, SIGTERM); - wait(&clist->sfx.pain_pid); if (!(tmp = waitpid(clist->sfx.trap_pid, NULL, WNOHANG))) kill(clist->sfx.trap_pid, SIGTERM); wait(&clist->sfx.trap_pid); -- cgit v1.2.3 From bcbe3db5345f86fcacb039039382f3130c933eea Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 15 Mar 2020 14:26:29 +0100 Subject: Sounds have been threaded --- src/ft_exit.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/ft_exit.c') diff --git a/src/ft_exit.c b/src/ft_exit.c index 3cd933a..625f86b 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -38,10 +38,10 @@ static void ft_memdel((void**)&clist->mlist.music_cmd); ft_memdel((void**)&clist->mlist.mapl); ft_free_words(clist->mlist.map); - ft_free_words(clist->sfx.death); + ft_memdel((void**)&clist->sfx.death); ft_memdel((void**)&clist->sfx.pain_one); ft_memdel((void**)&clist->sfx.pain_two); - ft_free_words(clist->sfx.trap); + ft_memdel((void**)&clist->sfx.trap); ft_free_sprites(clist->mlist.sprite_path); if (!clist->wlist.inited) ft_memdel((void**)&clist->wlist.winptr); @@ -74,23 +74,23 @@ static void static void ft_kill_forks(t_cub *clist) { - pid_t tmp; - if (clist->isoldmus && clist->wlist.inited) { pthread_cancel(clist->mtid); pthread_join(clist->mtid, NULL); } + pthread_mutex_unlock(&clist->sfx.death_mutex); + pthread_cancel(clist->sfx.death_tid); + pthread_join(clist->sfx.death_tid, NULL); + pthread_mutex_unlock(&clist->sfx.pain_mutex); pthread_cancel(clist->sfx.pain_tid); - if (!(tmp = waitpid(clist->sfx.death_pid, NULL, WNOHANG))) - kill(clist->sfx.death_pid, SIGTERM); - wait(&clist->sfx.death_pid); - if (!(tmp = waitpid(clist->sfx.new_lvl_pid, NULL, WNOHANG))) - kill(clist->sfx.new_lvl_pid, SIGTERM); - wait(&clist->sfx.new_lvl_pid); - if (!(tmp = waitpid(clist->sfx.trap_pid, NULL, WNOHANG))) - kill(clist->sfx.trap_pid, SIGTERM); - wait(&clist->sfx.trap_pid); + pthread_join(clist->sfx.pain_tid, NULL); + pthread_mutex_unlock(&clist->sfx.new_lvl_mutex); + pthread_cancel(clist->sfx.new_lvl_tid); + pthread_join(clist->sfx.new_lvl_tid, NULL); + pthread_mutex_unlock(&clist->sfx.trap_mutex); + pthread_cancel(clist->sfx.trap_tid); + pthread_join(clist->sfx.trap_tid, NULL); } int -- cgit v1.2.3 From 163bed0c8988ff020b746bf96dc01dd2058dc4f9 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 15 Mar 2020 15:09:59 +0100 Subject: Footsteps are bav --- src/ft_exit.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/ft_exit.c') diff --git a/src/ft_exit.c b/src/ft_exit.c index 625f86b..c3b5ebf 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -15,10 +15,8 @@ #include #include #include -#include -#include -#include #include +#include static void ft_free_lists(t_cub *clist) @@ -39,6 +37,9 @@ static void ft_memdel((void**)&clist->mlist.mapl); ft_free_words(clist->mlist.map); ft_memdel((void**)&clist->sfx.death); + ft_memdel((void**)&clist->sfx.footstep_one); + ft_memdel((void**)&clist->sfx.footstep_two); + ft_memdel((void**)&clist->sfx.new_lvl); ft_memdel((void**)&clist->sfx.pain_one); ft_memdel((void**)&clist->sfx.pain_two); ft_memdel((void**)&clist->sfx.trap); @@ -72,7 +73,7 @@ static void } static void - ft_kill_forks(t_cub *clist) + ft_cancel_threads(t_cub *clist) { if (clist->isoldmus && clist->wlist.inited) { @@ -82,12 +83,15 @@ static void pthread_mutex_unlock(&clist->sfx.death_mutex); pthread_cancel(clist->sfx.death_tid); pthread_join(clist->sfx.death_tid, NULL); - pthread_mutex_unlock(&clist->sfx.pain_mutex); - pthread_cancel(clist->sfx.pain_tid); - pthread_join(clist->sfx.pain_tid, NULL); + pthread_mutex_unlock(&clist->sfx.footstep_mutex); + pthread_cancel(clist->sfx.footstep_tid); + pthread_join(clist->sfx.footstep_tid, NULL); pthread_mutex_unlock(&clist->sfx.new_lvl_mutex); pthread_cancel(clist->sfx.new_lvl_tid); pthread_join(clist->sfx.new_lvl_tid, NULL); + pthread_mutex_unlock(&clist->sfx.pain_mutex); + pthread_cancel(clist->sfx.pain_tid); + pthread_join(clist->sfx.pain_tid, NULL); pthread_mutex_unlock(&clist->sfx.trap_mutex); pthread_cancel(clist->sfx.trap_tid); pthread_join(clist->sfx.trap_tid, NULL); @@ -105,7 +109,7 @@ int mlx_destroy_window(clist->wlist.wlx, clist->wlist.winptr); clist->wlist.winptr = NULL; } - ft_kill_forks(clist); + ft_cancel_threads(clist); ft_free_lists(clist); ft_printf("Exiting program\n"); exit(exit_code); -- cgit v1.2.3