fix: Added a check for the sprites, to avoid segfaults and/or invalid writes

This commit is contained in:
Theo Champion 2025-08-14 21:27:53 +02:00
parent 94075506f6
commit 4a70e44697

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/31 13:43:05 by kcolin #+# #+# */
/* Updated: 2025/08/12 16:13:50 by tchampio ### ########.fr */
/* Updated: 2025/08/14 21:26:14 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -69,8 +69,11 @@ void place_base_sprites(t_cub3d_data *data, char **map)
{
if (map[y][x] == 'M' || map[y][x] == 'Q'
|| map[y][x] == 'J' || map[y][x] == 'D')
{
if (c < MAX_SPRITES)
data->sprite_list[c++] = place_right_sprite(data,
map[y][x], x, y);
}
x++;
}
y++;