aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_select_get.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_select_get.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index 4b82430..c246d25 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -18,19 +18,20 @@
static int8_t
ft_check_exists(const int8_t ret, t_cub *clist)
{
- if (ret == 12)
- return (12);
- if (ret == 0 && (clist->wlist->x_size != 0 || clist->wlist->y_size != 0))
+ if (ret == FT_PARSE_END_RET)
+ return (FT_PARSE_END_RET);
+ if (ret == 0 && clist->currlvl == 0 &&
+ (clist->wlist.x_size != 0 || clist->wlist.y_size != 0))
return (-1);
- else if (ret == 1 && (clist->mlist->no_tex_path[0]))
+ else if (ret == 1 && (clist->mlist.no_tex_path[0]))
return (-1);
- else if (ret == 2 && (clist->mlist->so_tex_path[0]))
+ else if (ret == 2 && (clist->mlist.so_tex_path[0]))
return (-1);
- else if (ret == 3 && (clist->mlist->ea_tex_path[0]))
+ else if (ret == 3 && (clist->mlist.ea_tex_path[0]))
return (-1);
- else if (ret == 4 && (clist->mlist->we_tex_path[0]))
+ else if (ret == 4 && (clist->mlist.we_tex_path[0]))
return (-1);
- else if (ret == 5 && (clist->mlist->sprite_path[0]))
+ else if (ret == 5 && (clist->mlist.sprite_path[0]))
return (-1);
else if (ret == 6 && ((clist->f_rgb.r != -1) || (clist->f_rgb.g != -1)
|| (clist->f_rgb.b != -1)))
@@ -42,48 +43,47 @@ static int8_t
}
static int8_t
+ ft_check_exists_two(const int8_t ret, t_cub *clist)
+{
+ if (ret == FT_PARSE_END_RET)
+ return (FT_PARSE_END_RET);
+ if (ret == 8 && (clist->mlist.nlevel_path[0]))
+ return (-1);
+ if (ret == 9 && (clist->mlist.nl_tex_path[0]))
+ return (-1);
+ if (ret == 10 && (clist->mlist.music_path[0]))
+ return (-1);
+ return (ret);
+}
+
+static int8_t
ft_get_id(char **words, t_cub *clist)
{
int8_t ret;
- char ref[9][3];
- ft_memcpy(ref[0], "R\0", 3);
- ft_memcpy(ref[1], "NO", 3);
- ft_memcpy(ref[2], "SO", 3);
- ft_memcpy(ref[3], "EA", 3);
- ft_memcpy(ref[4], "WE", 3);
- ft_memcpy(ref[5], "S\0", 3);
- ft_memcpy(ref[6], "F\0", 3);
- ft_memcpy(ref[7], "C\0", 3);
- ft_memcpy(ref[8], "", 1);
+ if (words[0][0] == ' ' || words[0][0] == '1')
+ return (FT_PARSE_END_RET);
ret = 0;
- while (ft_strncmp(words[0], ref[ret], 3) && ref[ret][0])
+ while (ft_strncmp(words[0], clist->ref[ret], 3) && clist->ref[ret][0])
ret++;
- if (ret == 8)
- ret = 12;
- return (ret = ft_check_exists(ret, clist));
+ if (ret == 12)
+ ret = FT_PARSE_END_RET;
+ ret = ft_check_exists(ret, clist);
+ ret = ft_check_exists_two(ret, clist);
+ return (ret);
}
int8_t
ft_select_get(char **words, t_cub *clist)
{
- int8_t (*fun_ptr[8])(char**, t_cub*);
int8_t id;
- fun_ptr[0] = ft_get_res;
- fun_ptr[1] = ft_get_tex_no;
- fun_ptr[2] = ft_get_tex_so;
- fun_ptr[3] = ft_get_tex_ea;
- fun_ptr[4] = ft_get_tex_we;
- fun_ptr[5] = ft_get_sprite;
- fun_ptr[6] = ft_get_f_color;
- fun_ptr[7] = ft_get_c_color;
- if ((id = ft_get_id(words, clist)) == 12)
+ if ((id = ft_get_id(words, clist)) == FT_PARSE_END_RET)
{
ft_free_words(words);
- return (12);
+ return (FT_PARSE_END_RET);
}
- if (id < 0 || (*fun_ptr[id])(words, clist) < 0)
+ if (id < 0 || clist->get_ptr[id](words, clist) < 0)
{
ft_free_words(words);
return ((id < 0) ? (-2) : (-1));