From 073aca54bf8e3a20eba04cb4c26dc35ec43785e7 Mon Sep 17 00:00:00 2001
From: Rudy Bousset <rbousset@z2r5p1.le-101.fr>
Date: Wed, 4 Mar 2020 20:27:51 +0100
Subject: Music on macOS is half bav

---
 src/ft_check_map_surrounds.c | 10 +---------
 src/ft_exit.c                |  6 +++++-
 src/ft_parse_map.c           |  2 +-
 src/ft_warp_level.c          | 11 +++++++++--
 4 files changed, 16 insertions(+), 13 deletions(-)

(limited to 'src')

diff --git a/src/ft_check_map_surrounds.c b/src/ft_check_map_surrounds.c
index fbe2ff8..4b3f236 100644
--- a/src/ft_check_map_surrounds.c
+++ b/src/ft_check_map_surrounds.c
@@ -22,18 +22,10 @@ static int8_t
 		map[y - 1][x] == ' ' ||
 		map[y][x + 1] == ' ' ||
 		map[y][x - 1] == ' ' ||
-		map[y + 1][x + 1] == ' ' ||
-		map[y - 1][x + 1] == ' ' ||
-		map[y + 1][x - 1] == ' ' ||
-		map[y - 1][x - 1] == ' ' ||
 		map[y + 1][x] == '\0' ||
 		map[y - 1][x] == '\0' ||
 		map[y][x + 1] == '\0' ||
-		map[y][x - 1] == '\0' ||
-		map[y + 1][x + 1] == '\0' ||
-		map[y - 1][x + 1] == '\0' ||
-		map[y + 1][x - 1] == '\0' ||
-		map[y - 1][x - 1] == '\0')
+		map[y][x - 1] == '\0')
 		return (-1);
 	return (0);
 }
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 23cd466..92da2a6 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -16,6 +16,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <signal.h>
 #include <pthread.h>
 
 static void
@@ -63,7 +64,10 @@ int
 	if (clist->isoldmus && clist->wlist.inited)
 	{
 		pthread_cancel(clist->tid);
-		pthread_join(clist->tid, NULL);
+		if (FT_OS == 1)
+			pthread_kill(clist->tid, SIGTERM);
+		else
+			pthread_join(clist->tid, NULL);
 	}
 	ft_free_lists(clist);
 	ft_printf("Exiting program\n");
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index 6a9c5af..3c1fd9c 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -77,7 +77,7 @@ static int8_t
 void
 	ft_save_name(const char *map_path, t_map *mlist, t_cub *clist)
 {
-	ft_memdel((void**)mlist->filename);
+	ft_memdel((void**)&mlist->filename);
 	if (!(mlist->filename =
 		(char*)malloc((ft_strlen(map_path) + 1) * sizeof(char))))
 		ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist);
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index b122e46..a93184c 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -16,6 +16,7 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <mlx.h>
+#include <signal.h>
 #include <pthread.h>
 
 static void
@@ -66,14 +67,20 @@ static void
 	if (isoldmus && !cl->mlist.ismusic)
 	{
 		pthread_cancel(cl->tid);
-		pthread_join(cl->tid, NULL);
+		if (FT_OS == 1)
+			pthread_kill(cl->tid, SIGTERM);
+		else
+			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);
+		if (FT_OS == 1)
+			pthread_kill(cl->tid, SIGTERM);
+		else
+			pthread_join(cl->tid, NULL);
 		pthread_create(&cl->tid, NULL, ft_music_thread, cl);
 	}
 	else if (isoldmus && cl->mlist.ismusic
-- 
cgit v1.2.3