diff options
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r-- | src/ft_raycasting.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 3cbd368..baa71af 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -83,17 +83,16 @@ static void void ft_castray(t_cub *cl) { - uint16_t i; - t_win *wl; - float *dist_tab; + uint16_t i; + t_win *wl; + ft_memdel((void**)&cl->rlist.wall_dist_tab); wl = &cl->wlist; i = (wl->y_size / 2) + 1; while (++i < wl->y_size) ft_floor_cast(i, cl); - if (!(dist_tab = malloc(sizeof(float) * cl->wlist.x_size))) - return ; - if (!(cl->rlist.wall_dist_tab = malloc(sizeof(float) * cl->wlist.x_size))) + if (!(cl->rlist.wall_dist_tab = + (float*)malloc(sizeof(float) * cl->wlist.x_size))) return ; i = 0; while (i < wl->x_size) @@ -102,8 +101,7 @@ void ft_choose_tex(cl); ft_calc_tex(cl); ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); - dist_tab[i] = cl->rlist.wall_dist; - cl->rlist.wall_dist_tab = dist_tab; + cl->rlist.wall_dist_tab[i] = cl->rlist.wall_dist; i++; } } |