fix(main): Bumped calloc for sprites from 3 to MAX_SPRITES and moved it

This commit is contained in:
Theo Champion 2025-08-11 11:51:23 +02:00
parent b7d56363ab
commit aae5e42b13
2 changed files with 4 additions and 3 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
/* Updated: 2025/08/12 14:48:07 by tchampio ### ########.fr */
/* Updated: 2025/08/12 14:48:31 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -64,7 +64,7 @@ int main(int argc, char **argv)
if (argc < 2)
return (ft_printf("Error: Missing cub3d file\n"), 1);
init_cub3d_data(&data, argv);
data.sprite_list = ft_calloc(sizeof(t_sprite *), 3);
data.sprite_list = ft_calloc(sizeof(t_sprite *), MAX_SPRITES);
mlx_hook(data.mlx_win, KeyPress, KeyPressMask, keypress_handler, &data);
mlx_hook(data.mlx_win, KeyRelease, KeyReleaseMask,
keyrelease_handler, &data);

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/31 13:43:05 by kcolin #+# #+# */
/* Updated: 2025/08/05 15:45:01 by tchampio ### ########.fr */
/* Updated: 2025/08/11 11:52:31 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -72,5 +72,6 @@ void init_cub3d_data(t_cub3d_data *data, char **argv)
init_player(&data->player, data->map);
data->screen_matrix = ft_calloc(sizeof(int), WIDTH * HEIGHT);
load_textures(data);
data->sprite_list = ft_calloc(sizeof(t_sprite *), MAX_SPRITES);
ft_memset(data->sprite_distances, -1, MAX_SPRITES);
}