/* ************************************************************************** */ /* LE - / */ /* / */ /* ft_init_lists.c .:: .:/ . .:: */ /* +:+:+ +: +: +:+:+ */ /* By: rbousset +:+ +: +: +:+ */ /* #+# #+ #+ #+# */ /* Created: 2020/02/02 17:19:29 by rbousset #+# ## ## #+# */ /* Updated: 2020/02/02 17:19:29 by rbousset ### #+. /#+ ###.fr */ /* / */ /* / */ /* ************************************************************************** */ #include #include #include #include #include #include static t_rgb ft_init_rgb(void) { t_rgb rgb; rgb.r = -1; rgb.g = -1; rgb.b = -1; return (rgb); } static t_player *ft_init_player(void) { t_player *plist; if (!(plist = (t_player*)malloc(sizeof(t_player)))) return (NULL); plist->pos_x = 0; plist->pos_y = 0; plist->view_side = 0; return (plist); } static t_win *ft_init_win(void) { t_win *wlist; if (!(wlist = (t_win*)malloc(sizeof(t_win)))) return (NULL); if (!(wlist->wlx = malloc(1)) || !(wlist->winptr = malloc(1))) return (NULL); wlist->inited = 0; wlist->x_size = 0; wlist->y_size = 0; wlist->x_max_size = 0; wlist->y_max_size = 0; return (wlist); } static t_cub *ft_init_cub(void) { t_cub *clist; if (!(clist = (t_cub*)malloc(sizeof(t_cub)))) return (NULL); if (!(clist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(clist->so_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(clist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(clist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(clist->sprite_path = (char*)ft_calloc(1, sizeof(char))) || !(clist->mapl = (char*)ft_calloc(1, sizeof(char))) || !(clist->map = (char**)ft_calloc(2, sizeof(char*))) || !(clist->map[0] = (char*)ft_calloc(1, sizeof(char))) || !(clist->plist = ft_init_player())) return (NULL); clist->map[1] = 0; clist->map_w = 0; clist->map_h = 0; clist->line_chk = 0; clist->map_start = 0; clist->isspawn = 0; clist->f_rgb = ft_init_rgb(); clist->c_rgb = ft_init_rgb(); return (clist); } int8_t ft_init_cub3d(t_cub **clist) { t_cub *cl; if (!(cl = ft_init_cub())) { ft_memdel((void**)&cl); return (-1); } if (!(cl->wlist = ft_init_win())) { ft_memdel((void**)&cl->wlist); ft_memdel((void**)&cl); return (-1); } *clist = cl; return (0); }