diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-27 16:44:30 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-27 16:44:30 +0100 |
commit | 44d5f7f4da8465f4829de1232e4cf2c6c2bf76bc (patch) | |
tree | 0926de3e4bebc9015b7806bcdeb99818d84af9ae /src | |
parent | Problem (diff) | |
download | 42-cub3d-44d5f7f4da8465f4829de1232e4cf2c6c2bf76bc.tar.gz 42-cub3d-44d5f7f4da8465f4829de1232e4cf2c6c2bf76bc.tar.bz2 42-cub3d-44d5f7f4da8465f4829de1232e4cf2c6c2bf76bc.tar.xz 42-cub3d-44d5f7f4da8465f4829de1232e4cf2c6c2bf76bc.tar.zst 42-cub3d-44d5f7f4da8465f4829de1232e4cf2c6c2bf76bc.zip |
Segv fix
Diffstat (limited to '')
-rw-r--r-- | src/ft_draw_sprite.c | 8 | ||||
-rw-r--r-- | src/ft_init_map.c | 2 | ||||
-rw-r--r-- | src/ft_sort_s_t.c | 18 |
3 files changed, 7 insertions, 21 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 2aa1b43..1b3f912 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -76,11 +76,11 @@ static void + powf(cl->plist.pos_y - sprite->s_pos_y, 2))) <= 0) dist = 0.0001; rgb.r = (uint8_t)cl->tlist[sprite->current_sprite].ptr[sprite->tex_x - * 4 + 4 * cl->tlist[sprite->current_sprite].img_h * sprite->tex_y + 2]; + * 4 + 4 * cl->tlist[sprite->current_sprite].img_w * sprite->tex_y + 2]; rgb.g = (uint8_t)cl->tlist[sprite->current_sprite].ptr[sprite->tex_x - * 4 + 4 * cl->tlist[sprite->current_sprite].img_h * sprite->tex_y + 1]; + * 4 + 4 * cl->tlist[sprite->current_sprite].img_w * sprite->tex_y + 1]; rgb.b = (uint8_t)cl->tlist[sprite->current_sprite].ptr[sprite->tex_x - * 4 + 4 * cl->tlist[sprite->current_sprite].img_h * sprite->tex_y]; + * 4 + 4 * cl->tlist[sprite->current_sprite].img_w * sprite->tex_y]; *(int*)(cl->img.ptr + ((uint16_t)sprite->x * 4 + (sprite->y * cl->img.sizeline))) = ft_rgb_to_hex(dist, rgb, cl); } @@ -105,7 +105,7 @@ void sprite->spriteheight) / 128; if (sprite->transformy > 0 && cl->tlist[sprite->current_sprite].ptr[sprite->tex_x * 4 + 4 * - cl->tlist[sprite->current_sprite].img_h * sprite->tex_y] + cl->tlist[sprite->current_sprite].img_w * sprite->tex_y] && cl->rlist.wall_dist_tab[sprite->x] > sprite->transformy) ft_put_sprite(sprite, cl); sprite->y++; diff --git a/src/ft_init_map.c b/src/ft_init_map.c index 72a02fd..1859afe 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -70,7 +70,7 @@ int8_t i = -1; while (++i < FT_TOTAL_SPRT) ft_bzero(mlist->sprite_order[i], 4096); - ft_bzero(mlist->st_o, FT_TOTAL_SPRT); + ft_bzero(mlist->st_o, FT_TOTAL_SPRT + 1); ft_bzero(mlist->heals_order, 64); mlist->weaps_nbr[0] = 0; mlist->weaps_nbr[1] = 0; diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index 9cbde8b..31ae237 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -34,19 +34,6 @@ float } static void - ft_init_st(int32_t *st_o) -{ - int8_t i; - - i = 0; - while (i < FT_TOTAL_SPRT) - { - st_o[i] = i; - i++; - } -} - -static void ft_swap_them(int16_t i, float **dist_tab) { float tmp_i[4096]; @@ -63,11 +50,10 @@ void int32_t tmp; i = -1; - ft_init_st(cl->mlist.st_o); while (++i < FT_TOTAL_SPRT) { - if (i < FT_TOTAL_SPRT && dist_tab[i][0] - && dist_tab[i][0] < dist_tab[i + 1][0]) + cl->mlist.st_o[i] = i; + if (dist_tab[i][0] < dist_tab[i + 1][0]) { tmp = cl->mlist.st_o[i]; cl->mlist.st_o[i] = cl->mlist.st_o[i + 1]; |