blob: 4cec41abe01578d2d3bd6bbde93cf01dcecce50a (
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
32
33
|
#include <libft.h>
#include <cub3d.h>
#include <stdlib.h>
int
ft_get_sprite_tex(int fd, t_win *wlist)
{
char *line;
char **words;
size_t len;
get_next_line(fd, &line);
if (!(words = ft_split(line, ' ')))
{
ft_memdel(line);
return (ft_exit(5, wlist));
}
if (!(*words) || ft_strcmp(*words, "S") || !words[1] || words[2])
{
ft_free_words(words, line);
return (ft_map_error(7, wlist));
}
ft_memdel(wlist->clist->sprite_path);
len = ft_strlen(*(words + 1));
if (!(wlist->clist->sprite_path = (char*)malloc((len + 1) * sizeof(char))))
{
ft_free_words(words, line);
return (-1);
}
ft_strlcpy(wlist->clist->sprite_path, *(words + 1), len + 1);
ft_free_words(words, line);
return (0);
}
|