aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_select_get.c
blob: 25320d789ca6c762c7ff886d70650ce4c8b1a3e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>

static uint8_t
ft_get_id(char **words)
{
	if (!ft_strcmp(words[0], "R"))
		return (0);
	if (!ft_strcmp(words[0], "NO"))
		return (1);
	return (12);
}

uint8_t
ft_select_get(char **words, t_cub *clist)
{
	int		(*fun_ptr[4])(char**, t_cub*);
	uint8_t	id;

	fun_ptr[0] = ft_get_res;
	fun_ptr[1] = ft_get_tex;
	if ((id = ft_get_id(words)) == 12)
		return (12);
	if ((*fun_ptr[id])(words, clist) < 0)
	{
		ft_free_words(words);
		return (ft_map_error(clist));
	}
	return (id);
}