aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_exit.c1
-rw-r--r--src/ft_get_skybox.c43
-rw-r--r--src/ft_init_funptr.c1
-rw-r--r--src/ft_init_map.c1
-rw-r--r--src/ft_warp_level.c1
5 files changed, 47 insertions, 0 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 659d0ec..97c9e02 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -32,6 +32,7 @@ static void
ft_memdel((void**)&clist->mlist.fl_tex_path);
ft_memdel((void**)&clist->mlist.ce_tex_path);
ft_memdel((void**)&clist->mlist.nlevel_path);
+ ft_memdel((void**)&clist->mlist.skybox_path);
ft_memdel((void**)&clist->mlist.music_path);
ft_memdel((void**)&clist->mlist.music_cmd);
ft_memdel((void**)&clist->mlist.mapl);
diff --git a/src/ft_get_skybox.c b/src/ft_get_skybox.c
new file mode 100644
index 0000000..011bec7
--- /dev/null
+++ b/src/ft_get_skybox.c
@@ -0,0 +1,43 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_get_skybox.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+
+int8_t
+ ft_get_skybox(char **words, t_cub *clist)
+{
+ if (!(*words) || !(*(words + 1)) || (*(words + 2)))
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_ARGS);
+ return (-1);
+ }
+ if (ft_check_ext(*(words + 1), ".xpm") < 0)
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_NOT_A_XPM);
+ return (-1);
+ }
+ ft_memdel((void**)&clist->mlist.skybox_path);
+ if (!(clist->mlist.skybox_path = ft_strdup(*(words + 1))))
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_ALLOCATE);
+ return (-1);
+ }
+ if (ft_check_not_found(clist->mlist.skybox_path) < 0)
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_RD_NL_MAP);
+ return (-1);
+ }
+ clist->mlist.isskybox = 1;
+ return (0);
+}
diff --git a/src/ft_init_funptr.c b/src/ft_init_funptr.c
index 6d668dc..6bfa3f7 100644
--- a/src/ft_init_funptr.c
+++ b/src/ft_init_funptr.c
@@ -53,4 +53,5 @@ void
clist->get_ptr[9] = ft_get_tex_nl;
clist->get_ptr[10] = ft_get_music;
clist->get_ptr[11] = ft_get_darkness;
+ clist->get_ptr[12] = ft_get_skybox;
}
diff --git a/src/ft_init_map.c b/src/ft_init_map.c
index f8b91ec..27b4a39 100644
--- a/src/ft_init_map.c
+++ b/src/ft_init_map.c
@@ -28,6 +28,7 @@ static int8_t
!(mlist->fl_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->ce_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->nlevel_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->skybox_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->music_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->music_cmd = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) ||
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index de2103d..0af4ecb 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -33,6 +33,7 @@ static void
ft_memdel((void**)&ml->fl_tex_path);
ft_memdel((void**)&ml->ce_tex_path);
ft_memdel((void**)&ml->nlevel_path);
+ ft_memdel((void**)&ml->skybox_path);
ft_memdel((void**)&ml->music_path);
ft_memdel((void**)&ml->music_cmd);
ft_memdel((void**)&ml->mapl);