aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_get_sprite.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-01-28 16:22:51 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-01-28 16:22:51 +0100
commit6ee3017b31456ae8bcf4f21389e514b67d885098 (patch)
tree39a8354d65268b607d110c67deee9faac081cb5d /src/ft_get_sprite.c
parentBug fix (diff)
download42-cub3d-6ee3017b31456ae8bcf4f21389e514b67d885098.tar.gz
42-cub3d-6ee3017b31456ae8bcf4f21389e514b67d885098.tar.bz2
42-cub3d-6ee3017b31456ae8bcf4f21389e514b67d885098.tar.xz
42-cub3d-6ee3017b31456ae8bcf4f21389e514b67d885098.tar.zst
42-cub3d-6ee3017b31456ae8bcf4f21389e514b67d885098.zip
Got tex
Diffstat (limited to 'src/ft_get_sprite.c')
-rw-r--r--src/ft_get_sprite.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c
new file mode 100644
index 0000000..568e513
--- /dev/null
+++ b/src/ft_get_sprite.c
@@ -0,0 +1,29 @@
+#include <libft.h>
+#include <cub3d.h>
+#include <stdlib.h>
+
+int
+ft_get_sprite(int fd, t_cub *clist)
+{
+ char *line;
+ char **words;
+
+ if (get_next_line(fd, &line) <= 0 || !(words = ft_split(line, ' ')))
+ {
+ ft_memdel(line);
+ return (ft_map_error(7, clist));
+ }
+ if (!(*words) || ft_strcmp(*words, "S") || !words[1] || words[2])
+ {
+ ft_free_words(words, line);
+ return (ft_map_error(7, clist));
+ }
+ ft_memdel(clist->sprite_path);
+ if (!(clist->sprite_path = ft_strdup(*(words + 1))))
+ {
+ ft_free_words(words, line);
+ return (-1);
+ }
+ ft_free_words(words, line);
+ return (0);
+}