#include "fdf.h"

void	free_tab(char **tab)
{
	while (*tab)
		free(*tab++);
	free(*tab);
}

void	quit(t_FDF *FDF)
{
	if (FDF && FDF->mw->mlx && FDF->mw->win)
		mlx_destroy_window(FDF->mw->mlx, FDF->mw->win);
	exit(0);
}

void	swap_init(t_swap *s)
{
	s->swap_coord = 0;
	s->swap_x = 1;
	s->swap_z = 0;

}

void	print_help(void)
{
	ft_putstr(
			"Usage: "
			"fdf [OPTIONS] MAP_PATH"
			"\n\n"
			"Opitons:\n"
			"--heatmap \"R,G,B - R,G,B\""
			"\toptional parameter for specifying color range of\n"
			"\t\t\t\theatmap in RGB format. Each color component\n"
			"\t\t\t\tshould be between 0 and 255.\n"
			"\t\t\t\tPlease, put range in double quotes, for example:\n\n"
			"\t\t\t\tfdf --heatmap \"125,255,6 - 250,41,1\" ~/maps/42.fdf\n\n");
}

int 	tab_length(char **tab)
{
	int 	len;

	len = 0;
	if (tab)
		while (*tab)
		{
			tab++;
			len++;
		}
	return (len);
}