diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_exit.c | 1 | ||||
-rw-r--r-- | src/ft_get_path_nl.c | 41 | ||||
-rw-r--r-- | src/ft_get_tex.c | 2 | ||||
-rw-r--r-- | src/ft_get_tex_nl.c | 41 | ||||
-rw-r--r-- | src/ft_select_get.c | 4 |
5 files changed, 87 insertions, 2 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c index 97671d6..83e4b2e 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -25,6 +25,7 @@ static void ft_memdel((void**)&clist->mlist->ea_tex_path); ft_memdel((void**)&clist->mlist->we_tex_path); ft_memdel((void**)&clist->mlist->sprite_path); + ft_memdel((void**)&clist->mlist->nl_tex_path); ft_memdel((void**)&clist->mlist->nlevel_path); ft_memdel((void**)&clist->mlist->mapl); ft_free_words(clist->mlist->map); diff --git a/src/ft_get_path_nl.c b/src/ft_get_path_nl.c new file mode 100644 index 0000000..0b5e987 --- /dev/null +++ b/src/ft_get_path_nl.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_get_path_nl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/28 18:30:18 by rbousset #+# #+# */ +/* Updated: 2020/02/28 18:30:19 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <cub3d.h> +#include <stdint.h> + +int8_t + ft_get_path_nl(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), ".cub") < 0) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); + return (-1); + } + ft_memdel((void**)&clist->mlist->nlevel_path); + if (!(clist->mlist->nlevel_path = ft_strdup(*(words + 1)))) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); + return (-1); + } + if (ft_check_not_found(clist->mlist->nlevel_path) < 0) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_NO); + return (-1); + } + return (0); +} diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c index 1327d58..2611fef 100644 --- a/src/ft_get_tex.c +++ b/src/ft_get_tex.c @@ -12,7 +12,7 @@ #include <libft.h> #include <cub3d.h> -#include <stdlib.h> +#include <stdint.h> int8_t ft_get_tex_no(char **words, t_cub *clist) diff --git a/src/ft_get_tex_nl.c b/src/ft_get_tex_nl.c new file mode 100644 index 0000000..e1ee5ce --- /dev/null +++ b/src/ft_get_tex_nl.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 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 <cub3d.h> +#include <stdint.h> + +int8_t + ft_get_tex_nl(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->nl_tex_path); + if (!(clist->mlist->nl_tex_path = ft_strdup(*(words + 1)))) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); + return (-1); + } + if (ft_check_not_found(clist->mlist->nl_tex_path) < 0) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_RD_NO); + return (-1); + } + return (0); +} diff --git a/src/ft_select_get.c b/src/ft_select_get.c index 4b82430..b5df1bc 100644 --- a/src/ft_select_get.c +++ b/src/ft_select_get.c @@ -67,7 +67,7 @@ static int8_t int8_t ft_select_get(char **words, t_cub *clist) { - int8_t (*fun_ptr[8])(char**, t_cub*); + int8_t (*fun_ptr[10])(char**, t_cub*); int8_t id; fun_ptr[0] = ft_get_res; @@ -78,6 +78,8 @@ int8_t fun_ptr[5] = ft_get_sprite; fun_ptr[6] = ft_get_f_color; fun_ptr[7] = ft_get_c_color; + fun_ptr[8] = ft_get_path_nl; + fun_ptr[9] = ft_get_tex_nl; if ((id = ft_get_id(words, clist)) == 12) { ft_free_words(words); |