diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-27 15:44:12 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-27 15:44:33 +0100 |
commit | a4342816383dd39666bb6007210eb38b6819469a (patch) | |
tree | 7f7f07dd5e4777bcea1720f91377ff239f7aa80b /src | |
parent | test map update (diff) | |
download | 42-cub3d-a4342816383dd39666bb6007210eb38b6819469a.tar.gz 42-cub3d-a4342816383dd39666bb6007210eb38b6819469a.tar.bz2 42-cub3d-a4342816383dd39666bb6007210eb38b6819469a.tar.xz 42-cub3d-a4342816383dd39666bb6007210eb38b6819469a.tar.zst 42-cub3d-a4342816383dd39666bb6007210eb38b6819469a.zip |
Five threads for compat
Diffstat (limited to '')
-rw-r--r-- | src/ft_floor_cast.c | 10 | ||||
-rw-r--r-- | src/ft_floor_threads.c | 38 | ||||
-rw-r--r-- | src/ft_wall_cast.c | 10 | ||||
-rw-r--r-- | src/ft_wall_threads.c | 44 |
4 files changed, 76 insertions, 26 deletions
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c index 3962431..874a398 100644 --- a/src/ft_floor_cast.c +++ b/src/ft_floor_cast.c @@ -63,7 +63,7 @@ void void *ft_floor_cast(void *vargp) { - pthread_t tid[4]; + pthread_t tid[5]; t_cub *cl; cl = (t_cub *)vargp; @@ -71,10 +71,12 @@ 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_join(tid[0], 0x0); - pthread_join(tid[1], 0x0); - pthread_join(tid[2], 0x0); + pthread_create(&tid[4], 0x0, ft_floor_five, (void*)cl); + pthread_join(tid[4], 0x0); pthread_join(tid[3], 0x0); + pthread_join(tid[2], 0x0); + pthread_join(tid[1], 0x0); + pthread_join(tid[0], 0x0); pthread_exit(0x0); return (0x0); } diff --git a/src/ft_floor_threads.c b/src/ft_floor_threads.c index 476bd8e..05f75aa 100644 --- a/src/ft_floor_threads.c +++ b/src/ft_floor_threads.c @@ -26,7 +26,7 @@ void while (y < (cl->wlist.y_size)) { x = 0; - while (x < cl->wlist.x_size / 4) + while (x < cl->wlist.x_size / 5) { if (cl->rlist.wall_b_tab[x] <= y) ft_floor_cast_loop(y, x, cl); @@ -49,8 +49,8 @@ void y = (cl->wlist.y_size / 2); while (y < (cl->wlist.y_size)) { - x = cl->wlist.x_size / 4; - while (x < 2 * (cl->wlist.x_size / 4)) + x = cl->wlist.x_size / 5; + while (x < 2 * (cl->wlist.x_size / 5)) { if (cl->rlist.wall_b_tab[x] <= y) ft_floor_cast_loop(y, x, cl); @@ -73,8 +73,8 @@ void y = (cl->wlist.y_size / 2); while (y < (cl->wlist.y_size)) { - x = 2 * (cl->wlist.x_size / 4); - while (x < 3 * (cl->wlist.x_size / 4)) + x = 2 * (cl->wlist.x_size / 5); + while (x < 3 * (cl->wlist.x_size / 5)) { if (cl->rlist.wall_b_tab[x] <= y) ft_floor_cast_loop(y, x, cl); @@ -97,8 +97,32 @@ void y = (cl->wlist.y_size / 2); while (y < (cl->wlist.y_size)) { - x = 3 * (cl->wlist.x_size / 4); - while (x < 4 * (cl->wlist.x_size / 4)) + x = 3 * (cl->wlist.x_size / 5); + while (x < 4 * (cl->wlist.x_size / 5)) + { + if (cl->rlist.wall_b_tab[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); + while (y < (cl->wlist.y_size)) + { + x = 4 * (cl->wlist.x_size / 5); + while (x < 5 * (cl->wlist.x_size / 5)) { if (cl->rlist.wall_b_tab[x] <= y) ft_floor_cast_loop(y, x, cl); diff --git a/src/ft_wall_cast.c b/src/ft_wall_cast.c index 7610df6..0585f94 100644 --- a/src/ft_wall_cast.c +++ b/src/ft_wall_cast.c @@ -38,7 +38,7 @@ void void *ft_wall_cast(void *vargp) { - pthread_t tid[8]; + pthread_t tid[5]; t_cub *cl; cl = (t_cub *)vargp; @@ -46,10 +46,12 @@ 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_join(tid[0], 0x0); - pthread_join(tid[1], 0x0); - pthread_join(tid[2], 0x0); + pthread_create(&tid[4], 0x0, ft_wall_five, (void*)cl); + pthread_join(tid[4], 0x0); pthread_join(tid[3], 0x0); + pthread_join(tid[2], 0x0); + pthread_join(tid[1], 0x0); + pthread_join(tid[0], 0x0); pthread_exit(0x0); return (0x0); } diff --git a/src/ft_wall_threads.c b/src/ft_wall_threads.c index 30aa3b9..4855da6 100644 --- a/src/ft_wall_threads.c +++ b/src/ft_wall_threads.c @@ -22,9 +22,10 @@ void cl = (t_cub *)vargp; i = 0; - while (i < cl->wlist.x_size / 4) + while (i < cl->wlist.x_size / 5) { - ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); + ft_draw_verline(cl, i, + cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); i++; } pthread_exit(0x0); @@ -38,10 +39,11 @@ void uint16_t i; cl = (t_cub *)vargp; - i = cl->wlist.x_size / 4; - while (i < 2 * (cl->wlist.x_size / 4)) + i = cl->wlist.x_size / 5; + while (i < 2 * (cl->wlist.x_size / 5)) { - ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); + ft_draw_verline(cl, i, + cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); i++; } pthread_exit(0x0); @@ -55,10 +57,11 @@ void uint16_t i; cl = (t_cub *)vargp; - i = 2 * (cl->wlist.x_size / 4); - while (i < 3 * (cl->wlist.x_size / 4)) + i = 2 * (cl->wlist.x_size / 5); + while (i < 3 * (cl->wlist.x_size / 5)) { - ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); + ft_draw_verline(cl, i, + cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); i++; } pthread_exit(0x0); @@ -72,10 +75,29 @@ void uint16_t i; cl = (t_cub *)vargp; - i = 3 * (cl->wlist.x_size / 4); - while (i < 4 * (cl->wlist.x_size / 4)) + i = 3 * (cl->wlist.x_size / 5); + while (i < 4 * (cl->wlist.x_size / 5)) { - ft_draw_verline(cl, i, cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); + ft_draw_verline(cl, i, + cl->rlist.wall_t_tab[i], cl->rlist.wall_b_tab[i]); + i++; + } + pthread_exit(0x0); + return (0x0); +} + +void + *ft_wall_five(void *vargp) +{ + t_cub *cl; + uint16_t i; + + cl = (t_cub *)vargp; + i = 4 * (cl->wlist.x_size / 5); + while (i < 5 * (cl->wlist.x_size / 5)) + { + ft_draw_verline(cl, i, + cl->rlist.wall_t_tab[i],cl->rlist.wall_b_tab[i]); i++; } pthread_exit(0x0); |