diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_init_map.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/ft_init_map.c b/src/ft_init_map.c index cc767f6..68a3b6d 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -13,31 +13,54 @@ #include <libft.h> #include <cub3d.h> #include <stdlib.h> +#include <stdint.h> -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))) || + if (!(mlist->filename = (char*)ft_calloc(1, sizeof(char))) || + !(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->nl_tex_path = (char*)ft_calloc(1, sizeof(char))) || + !(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->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))) || !(mlist->map = (char**)ft_calloc(2, sizeof(char*))) || - !(mlist->map[0] = (char*)ft_calloc(1, sizeof(char)))) - return (NULL); + !(mlist->map[0] = (char*)ft_calloc(1, sizeof(char))) || + !(mlist->mcmd_words = (char**)ft_calloc(2, sizeof(char*))) || + !(mlist->mcmd_words[0] = (char*)ft_calloc(1, sizeof(char)))) + return (-1); + return (0); +} + +int8_t + ft_init_map(t_map *mlist) +{ + if (ft_init_map_callocs(mlist) < 0) + return (-1); mlist->map[1] = 0; + mlist->mcmd_words[1] = 0; mlist->map_w = 0; mlist->map_h = 0; + mlist->mapl_len = 0; mlist->x_step = 0; mlist->y_step = 0; mlist->line_chk = 0; mlist->map_start = 0; mlist->isspawn = 0; + mlist->isftex = 0; + mlist->isctex = 0; + mlist->isnlvl = 0; + mlist->ismusic = 0; + mlist->darklvl = 0; mlist->scale = 0; - return (mlist); + mlist->nlx = 0; + mlist->nly = 0; + return (0); } |