From 0225570cb171f66a63a6c0120652fe7f6f343e55 Mon Sep 17 00:00:00 2001
From: JozanLeClerc <bousset.rudy@gmail.com>
Date: Tue, 24 Mar 2020 15:28:39 +0100
Subject: less threads

---
 src/ft_floor_cast.c | 128 ++++------------------------------------------------
 src/ft_raycasting.c |  12 +++--
 src/ft_wall_cast.c  |  78 +-------------------------------
 3 files changed, 18 insertions(+), 200 deletions(-)

diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index b00792e..f371359 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -69,8 +69,8 @@ void
 
 	cl = (t_cub *)vargp;
 	y = (cl->wlist.y_size / 2);
-	y += 0 * (cl->wlist.y_size / 2 / 8);
-	while (y < (cl->wlist.y_size / 2) + (1 * (cl->wlist.y_size / 2 / 8)))
+	y += 0 * (cl->wlist.y_size / 2 / 4);
+	while (y < (cl->wlist.y_size / 2) + (1 * (cl->wlist.y_size / 2 / 4)))
 	{
 		x = 0;
 		while (x < cl->wlist.x_size)
@@ -94,8 +94,8 @@ void
 
 	cl = (t_cub *)vargp;
 	y = (cl->wlist.y_size / 2);
-	y += 1 * (cl->wlist.y_size / 2 / 8);
-	while (y < (cl->wlist.y_size / 2) + (2 * (cl->wlist.y_size / 2 / 8)))
+	y += 1 * (cl->wlist.y_size / 2 / 4);
+	while (y < (cl->wlist.y_size / 2) + (2 * (cl->wlist.y_size / 2 / 4)))
 	{
 		x = 0;
 		while (x < cl->wlist.x_size)
@@ -119,8 +119,8 @@ void
 
 	cl = (t_cub *)vargp;
 	y =  (cl->wlist.y_size / 2);
-	y += (2 * (cl->wlist.y_size / 2 / 8));
-	while (y < (cl->wlist.y_size / 2) + (3 * (cl->wlist.y_size / 2 / 8)))
+	y += (2 * (cl->wlist.y_size / 2 / 4));
+	while (y < (cl->wlist.y_size / 2) + (3 * (cl->wlist.y_size / 2 / 4)))
 	{
 		x = 0;
 		while (x < cl->wlist.x_size)
@@ -144,108 +144,8 @@ void
 
 	cl = (t_cub *)vargp;
 	y =  (cl->wlist.y_size / 2);
-	y += (3 * (cl->wlist.y_size / 2 / 8));
-	while (y < (cl->wlist.y_size / 2) + (4 * (cl->wlist.y_size / 2 / 8)))
-	{
-		x = 0;
-		while (x < cl->wlist.x_size)
-		{
-			if (cl->rlist.wall_bz[x] <= y)
-				ft_floor_cast_loop(y, x, cl);
-			x++;
-		}
-		y++;
-	}
-	pthread_exit(0x0);
-	return (0x0);
-}
-
-void
-*ft_floor_five(void *vargp)
-{
-	uint16_t	x;
-	uint16_t	y;
-	t_cub		*cl;
-
-	cl = (t_cub *)vargp;
-	y =  (cl->wlist.y_size / 2);
-	y += (4 * (cl->wlist.y_size / 2 / 8));
-	while (y < (cl->wlist.y_size / 2) + (5 * (cl->wlist.y_size / 2 / 8)))
-	{
-		x = 0;
-		while (x < cl->wlist.x_size)
-		{
-			if (cl->rlist.wall_bz[x] <= y)
-				ft_floor_cast_loop(y, x, cl);
-			x++;
-		}
-		y++;
-	}
-	pthread_exit(0x0);
-	return (0x0);
-}
-
-void
-*ft_floor_six(void *vargp)
-{
-	uint16_t	x;
-	uint16_t	y;
-	t_cub		*cl;
-
-	cl = (t_cub *)vargp;
-	y =  (cl->wlist.y_size / 2);
-	y += (5 * (cl->wlist.y_size / 2 / 8));
-	while (y < (cl->wlist.y_size / 2) + (6 * (cl->wlist.y_size / 2 / 8)))
-	{
-		x = 0;
-		while (x < cl->wlist.x_size)
-		{
-			if (cl->rlist.wall_bz[x] <= y)
-				ft_floor_cast_loop(y, x, cl);
-			x++;
-		}
-		y++;
-	}
-	pthread_exit(0x0);
-	return (0x0);
-}
-
-void
-*ft_floor_seven(void *vargp)
-{
-	uint16_t	x;
-	uint16_t	y;
-	t_cub		*cl;
-
-	cl = (t_cub *)vargp;
-	y =  (cl->wlist.y_size / 2);
-	y += (6 * (cl->wlist.y_size / 2 / 8));
-	while (y < (cl->wlist.y_size / 2) + (7 * (cl->wlist.y_size / 2 / 8)))
-	{
-		x = 0;
-		while (x < cl->wlist.x_size)
-		{
-			if (cl->rlist.wall_bz[x] <= y)
-				ft_floor_cast_loop(y, x, cl);
-			x++;
-		}
-		y++;
-	}
-	pthread_exit(0x0);
-	return (0x0);
-}
-
-void
-*ft_floor_eight(void *vargp)
-{
-	uint16_t	x;
-	uint16_t	y;
-	t_cub		*cl;
-
-	cl = (t_cub *)vargp;
-	y =  (cl->wlist.y_size / 2);
-	y += (7 * (cl->wlist.y_size / 2 / 8));
-	while (y < (cl->wlist.y_size / 2) + (8 * (cl->wlist.y_size / 2 / 8)))
+	y += (3 * (cl->wlist.y_size / 2 / 4));
+	while (y < (cl->wlist.y_size / 2) + (4 * (cl->wlist.y_size / 2 / 4)))
 	{
 		x = 0;
 		while (x < cl->wlist.x_size)
@@ -263,7 +163,7 @@ void
 void
 	*ft_floor_cast(void *vargp)
 {
-	pthread_t	tid[8];
+	pthread_t	tid[4];
 	t_cub		*cl;
 
 	cl = (t_cub *)vargp;
@@ -271,18 +171,10 @@ void
 	pthread_create(&tid[1], 0x0, ft_floor_two, (void*)cl);
 	pthread_create(&tid[2], 0x0, ft_floor_three, (void*)cl);
 	pthread_create(&tid[3], 0x0, ft_floor_four, (void*)cl);
-	pthread_create(&tid[4], 0x0, ft_floor_five, (void*)cl);
-	pthread_create(&tid[5], 0x0, ft_floor_six, (void*)cl);
-	pthread_create(&tid[6], 0x0, ft_floor_seven, (void*)cl);
-	pthread_create(&tid[7], 0x0, ft_floor_eight, (void*)cl);
 	pthread_join(tid[0], 0x0);
 	pthread_join(tid[1], 0x0);
 	pthread_join(tid[2], 0x0);
 	pthread_join(tid[3], 0x0);
-	pthread_join(tid[4], 0x0);
-	pthread_join(tid[5], 0x0);
-	pthread_join(tid[6], 0x0);
-	pthread_join(tid[7], 0x0);
-	pthread_exit(0x0);
+	/* pthread_exit(0x0); */
 	return (0x0);
 }
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 1804118..ea27d29 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -104,7 +104,7 @@ static void
 void
 	ft_castray(t_cub *cl)
 {
-	pthread_t	tid[2];
+	/* pthread_t	tid[2]; */
 	uint16_t	y;
 	uint16_t	x;
 
@@ -173,10 +173,12 @@ void
 		cl->rlist.row_dist_tab[cl->wlist.y_size - y] = cl->rlist.row_dist;
 		y++;
 	}
-	pthread_create(&tid[0], 0x0, ft_wall_cast, (void*)cl);
-	pthread_create(&tid[1], 0x0, ft_floor_cast, (void*)cl);
-	pthread_join(tid[0], 0x0);
-	pthread_join(tid[1], 0x0);
+	ft_wall_cast(cl);
+	ft_floor_cast(cl);
+	/* pthread_create(&tid[0], 0x0, ft_wall_cast, (void*)cl); */
+	/* pthread_create(&tid[1], 0x0, ft_floor_cast, (void*)cl); */
+	/* pthread_join(tid[0], 0x0); */
+	/* pthread_join(tid[1], 0x0); */
 	x = 0;
 	while (x < 2)
 	{
diff --git a/src/ft_wall_cast.c b/src/ft_wall_cast.c
index 0a1a8ef..b8d4e3c 100644
--- a/src/ft_wall_cast.c
+++ b/src/ft_wall_cast.c
@@ -103,74 +103,6 @@ static void
 	return (0x0);
 }
 
-/* static void */
-/* *ft_wall_five(void *vargp) */
-/* { */
-/* 	t_cub		*cl; */
-/* 	uint16_t	i; */
-
-/* 	cl = (t_cub *)vargp; */
-/* 	i = 4 * (cl->wlist.x_size / 8); */
-/* 	while (i < 5 * (cl->wlist.x_size / 8)) */
-/* 	{ */
-/* 		ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_bz[i]); */
-/* 		i++; */
-/* 	} */
-/* 	pthread_exit(0x0); */
-/* 	return (0x0); */
-/* } */
-
-/* static void */
-/* *ft_wall_six(void *vargp) */
-/* { */
-/* 	t_cub		*cl; */
-/* 	uint16_t	i; */
-
-/* 	cl = (t_cub *)vargp; */
-/* 	i = 5 * (cl->wlist.x_size / 8); */
-/* 	while (i < 6 * (cl->wlist.x_size / 8)) */
-/* 	{ */
-/* 		ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_bz[i]); */
-/* 		i++; */
-/* 	} */
-/* 	pthread_exit(0x0); */
-/* 	return (0x0); */
-/* } */
-
-/* static void */
-/* *ft_wall_seven(void *vargp) */
-/* { */
-/* 	t_cub		*cl; */
-/* 	uint16_t	i; */
-
-/* 	cl = (t_cub *)vargp; */
-/* 	i = 6 * (cl->wlist.x_size / 8); */
-/* 	while (i < 7 * (cl->wlist.x_size / 8)) */
-/* 	{ */
-/* 		ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_bz[i]); */
-/* 		i++; */
-/* 	} */
-/* 	pthread_exit(0x0); */
-/* 	return (0x0); */
-/* } */
-
-/* static void */
-/* *ft_wall_eight(void *vargp) */
-/* { */
-/* 	t_cub		*cl; */
-/* 	uint16_t	i; */
-
-/* 	cl = (t_cub *)vargp; */
-/* 	i = 7 * (cl->wlist.x_size / 8); */
-/* 	while (i < cl->wlist.x_size) */
-/* 	{ */
-/* 		ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_bz[i]); */
-/* 		i++; */
-/* 	} */
-/* 	pthread_exit(0x0); */
-/* 	return (0x0); */
-/* } */
-
 void
 	*ft_wall_cast(void *vargp)
 {
@@ -182,18 +114,10 @@ void
 	pthread_create(&tid[1], 0x0, ft_wall_two, (void*)cl);
 	pthread_create(&tid[2], 0x0, ft_wall_three, (void*)cl);
 	pthread_create(&tid[3], 0x0, ft_wall_four, (void*)cl);
-	/* pthread_create(&tid[4], 0x0, ft_wall_five, (void*)cl); */
-	/* pthread_create(&tid[5], 0x0, ft_wall_six, (void*)cl); */
-	/* pthread_create(&tid[6], 0x0, ft_wall_seven, (void*)cl); */
-	/* pthread_create(&tid[7], 0x0, ft_wall_eight, (void*)cl); */
 	pthread_join(tid[0], 0x0);
 	pthread_join(tid[1], 0x0);
 	pthread_join(tid[2], 0x0);
 	pthread_join(tid[3], 0x0);
-	/* pthread_join(tid[4], 0x0); */
-	/* pthread_join(tid[5], 0x0); */
-	/* pthread_join(tid[6], 0x0); */
-	/* pthread_join(tid[7], 0x0); */
-	pthread_exit(0x0);
+	/* pthread_exit(0x0); */
 	return (0x0);
 }
-- 
cgit v1.2.3