From b9d15035f290303c2163c595098b4a70a0324ac0 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Fri, 28 Feb 2020 15:30:41 +0100 Subject: In progress --- src/ft_exit.c | 1 + src/ft_init_map.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ft_exit.c b/src/ft_exit.c index b9e061f..97671d6 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->nlevel_path); ft_memdel((void**)&clist->mlist->mapl); ft_free_words(clist->mlist->map); ft_memdel((void**)&clist->mlist); diff --git a/src/ft_init_map.c b/src/ft_init_map.c index cc767f6..0eb2ab2 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -13,22 +13,32 @@ #include #include #include +#include -t_map - *ft_init_map(void) +static int8_t + ft_init_map_callocs(t_map *mlist) { - t_map *mlist; - - if (!(mlist = (t_map*)malloc(sizeof(t_map)))) - return (NULL); if (!(mlist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->so_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->sprite_path = (char*)ft_calloc(1, sizeof(char))) || + !(mlist->nlevel_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) || !(mlist->map = (char**)ft_calloc(2, sizeof(char*))) || !(mlist->map[0] = (char*)ft_calloc(1, sizeof(char)))) + return (-1); + return (0); +} + +t_map + *ft_init_map(void) +{ + t_map *mlist; + + if (!(mlist = (t_map*)malloc(sizeof(t_map)))) + return (NULL); + if (ft_init_map_callocs(mlist) < 0) return (NULL); mlist->map[1] = 0; mlist->map_w = 0; @@ -38,6 +48,7 @@ t_map mlist->line_chk = 0; mlist->map_start = 0; mlist->isspawn = 0; + mlist->isnlvl = 0; mlist->scale = 0; return (mlist); } -- cgit v1.2.3