/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_wall_threads.c                                  :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:22:23 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:23:42 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <cub3d.h>
#include <stdint.h>
#include <pthread.h>

void
	*ft_floor_one(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 = 0;
		while (x < 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_two(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 = 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);
			x++;
		}
		y++;
	}
	pthread_exit(0x0);
	return (0x0);
}

void
	*ft_floor_three(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 = 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);
			x++;
		}
		y++;
	}
	pthread_exit(0x0);
	return (0x0);
}

void
	*ft_floor_four(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 = 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);
			x++;
		}
		y++;
	}
	pthread_exit(0x0);
	return (0x0);
}