aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_get_traps.c42
-rw-r--r--src/ft_init_funptr.c4
-rw-r--r--src/ft_select_get.c2
3 files changed, 46 insertions, 2 deletions
diff --git a/src/ft_get_traps.c b/src/ft_get_traps.c
new file mode 100644
index 0000000..cdc05de
--- /dev/null
+++ b/src/ft_get_traps.c
@@ -0,0 +1,42 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_get_tex_nl.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/28 18:24:52 by rbousset #+# #+# */
+/* Updated: 2020/02/28 18:24:56 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+
+int8_t
+ ft_get_traps(char **words, t_cub *clist)
+{
+ if (!(*words) || !(*(words + 1)) || (*(words + 2)))
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS);
+ return (-1);
+ }
+ if (ft_check_ext(*(words + 1), ".xpm") < 0)
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM);
+ return (-1);
+ }
+ ft_memdel((void**)&clist->mlist.traps_path);
+ if (!(clist->mlist.traps_path = ft_strdup(*(words + 1))))
+ {
+ ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
+ return (-1);
+ }
+ if (ft_check_not_found(clist->mlist.traps_path) < 0)
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_RD_TRAP);
+ return (-1);
+ }
+ return (0);
+}
diff --git a/src/ft_init_funptr.c b/src/ft_init_funptr.c
index 6bfa3f7..c74b2c8 100644
--- a/src/ft_init_funptr.c
+++ b/src/ft_init_funptr.c
@@ -29,7 +29,8 @@ void
ft_sprintf(clist->ref[10], "MU");
ft_sprintf(clist->ref[11], "SH");
ft_sprintf(clist->ref[12], "SB");
- ft_bzero(clist->ref[13], 3);
+ ft_sprintf(clist->ref[13], "T");
+ ft_bzero(clist->ref[14], 3);
}
void
@@ -54,4 +55,5 @@ void
clist->get_ptr[10] = ft_get_music;
clist->get_ptr[11] = ft_get_darkness;
clist->get_ptr[12] = ft_get_skybox;
+ clist->get_ptr[14] = ft_get_traps;
}
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index fe6bb3e..2a95309 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -66,7 +66,7 @@ static int8_t
ret = 0;
while (ft_strncmp(words[0], clist->ref[ret], 3) && clist->ref[ret][0])
ret++;
- if (ret == 13)
+ if (ret == 14)
ret = FT_PARSE_END_RET;
ret = ft_check_exists(ret, clist);
ret = ft_check_exists_two(ret, clist);