/* ************************************************************************** */
/*                                                                            */
/*                                                        ::::::::            */
/*   map_free.c                                         :+:    :+:            */
/*                                                     +:+                    */
/*   By: qmennen <qmennen@student.codam.nl>           +#+                     */
/*                                                   +#+                      */
/*   Created: 2025/04/23 12:22:28 by whaffman      #+#    #+#                 */
/*   Updated: 2025/06/03 13:28:30 by whaffman      ########   odam.nl         */
/*                                                                            */
/* ************************************************************************** */

#include <stdlib.h>
#include "cub3d.h"

void	map_free(t_map *map)
{
	int	i;

	if (!map)
		return ;
	grid_free(map->grid, map->height);
	if (map->texture_floor)
		mlx_delete_texture(map->texture_floor);
	if (map->texture_ceiling)
		mlx_delete_texture(map->texture_ceiling);
	i = 0;
	while (i < 26)
	{
		if (map->sprite_lib[i].texture)
			mlx_delete_texture(map->sprite_lib[i].texture);
		if (i < 4)
		{
			if (map->textures[i])
				mlx_delete_texture(map->textures[i]);
		}
		i++;
	}
	free(map->sprite_lib);
	free(map->sprites);
	free(map);
}
