diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-03 14:47:33 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-03 14:47:33 +0100 |
commit | 8866ef5699150d0549096efa94fc311ff7a48dc7 (patch) | |
tree | 4a03267f7e7f9b399a9ad0536b50ba6a90407e47 /src/ft_init_lists.c | |
parent | Music is pretty bav (diff) | |
download | 42-cub3d-8866ef5699150d0549096efa94fc311ff7a48dc7.tar.gz 42-cub3d-8866ef5699150d0549096efa94fc311ff7a48dc7.tar.bz2 42-cub3d-8866ef5699150d0549096efa94fc311ff7a48dc7.tar.xz 42-cub3d-8866ef5699150d0549096efa94fc311ff7a48dc7.tar.zst 42-cub3d-8866ef5699150d0549096efa94fc311ff7a48dc7.zip |
Changing stuff
Diffstat (limited to 'src/ft_init_lists.c')
-rw-r--r-- | src/ft_init_lists.c | 78 |
1 files changed, 36 insertions, 42 deletions
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index eec8d5d..2b2593c 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -36,15 +36,15 @@ static t_player if (!(plist = (t_player*)malloc(sizeof(t_player)))) return (NULL); - plist->pos_x = 0; - plist->pos_y = 0; - plist->start_x = 0; - plist->start_y = 0; - plist->cam_x = 0; - plist->dir_x = -1; - plist->dir_y = 0; - plist->plane_x = 0; - plist->plane_y = 0.75; + plist.pos_x = 0; + plist.pos_y = 0; + plist.start_x = 0; + plist.start_y = 0; + plist.cam_x = 0; + plist.dir_x = -1; + plist.dir_y = 0; + plist.plane_x = 0; + plist.plane_y = 0.75; return (plist); } @@ -55,58 +55,52 @@ static t_win if (!(wlist = (t_win*)malloc(sizeof(t_win)))) return (NULL); - if (!(wlist->winptr = malloc(1))) + if (!(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; + 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) + ft_init_cub(void) { - t_cub *clist; + t_cub clist; uint8_t i; - if (!(clist = (t_cub*)malloc(sizeof(t_cub)))) + if (!(clist.plist = ft_init_player()) || + !(clist.mlist = ft_init_map())) return (NULL); - if (!(clist->plist = ft_init_player()) || - !(clist->mlist = ft_init_map())) - return (NULL); - ft_bzero(clist->errmsg, 40); + ft_bzero(clist.errmsg, 40); i = -1; while (++i < 5) - clist->key_input[i] = -1; - clist->ishud = 0; - clist->isoldmus = 0; - clist->f_rgb = ft_init_rgb(); - clist->c_rgb = ft_init_rgb(); - clist->rlist = ft_init_s_ray(); - clist->currlvl = 0; - clist->walltexgood = 0; + clist.key_input[i] = -1; + clist.ishud = 0; + clist.isoldmus = 0; + clist.f_rgb = ft_init_rgb(); + clist.c_rgb = ft_init_rgb(); + clist.rlist = ft_init_s_ray(); + clist.currlvl = 0; + clist.walltexgood = 0; ft_init_funptr(clist); return (clist); } -int8_t - ft_init_cub3d(t_cub **clist) +t_cub + ft_init_cub3d(void) { - t_cub *cl; + t_cub cl; if (!(cl = ft_init_cub())) + return (NULL); + if (!(cl.wlist = ft_init_win())) { + ft_memdel((void**)&cl.wlist); ft_memdel((void**)&cl); - return (-1); - } - if (!(cl->wlist = ft_init_win())) - { - ft_memdel((void**)&cl->wlist); - ft_memdel((void**)&cl); - return (-1); + return (NULL); } - *clist = cl; - return (0); + return (cl); } |