Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromelocf committed Dec 20, 2024
1 parent da1f4e7 commit a479d0b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
3 changes: 0 additions & 3 deletions sources/check_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ bool is_valid_map(t_list *list)
bool is_empty_line(char *line)
{
while (*line && ft_strchr(BLANK_CHARS, *line))
{
line++;
printf("%d ", *line);
}
return (!*line);
}
7 changes: 4 additions & 3 deletions sources/getters.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mlx_texture_t *get_texture(char *line)
texture = NULL;
if (is_valid_png(trimmed_line))
texture = mlx_load_png(trimmed_line);
free(trimmed_line);
return (texture);
}

Expand All @@ -52,9 +53,9 @@ void get_map(char *line, t_cub3d *scene, int fd)
ft_lstadd_back(&lines, ft_lstnew(line));
line = ft_get_next_line(fd);
}
// if (is_valid_map(lines))
fill_map(&scene->map, lines);
// ft_lstclear(&lines, free);
if (is_valid_map(lines))
fill_map(&scene->map, lines);
// ft_lstclear(&lines, free);
}

static void fill_map(char ***map, t_list *list)
Expand Down
15 changes: 8 additions & 7 deletions sources/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,20 @@ void clean_scene(t_cub3d *scene, char *message)
if (scene->rgb_colors.ceiling_color)
free(scene->rgb_colors.ceiling_color);
if (scene->map)
{
ft_for_each((void **)scene->map, free);
free(scene->map);
}
if (scene->mlx)
free(scene->mlx);
mlx_terminate(scene->mlx);
if (scene->textures.loaded_textures.no)
free(scene->textures.loaded_textures.no);
mlx_delete_texture(scene->textures.loaded_textures.no);
if (scene->textures.loaded_textures.so)
free(scene->textures.loaded_textures.so);
mlx_delete_texture(scene->textures.loaded_textures.so);
if (scene->textures.loaded_textures.we)
free(scene->textures.loaded_textures.we);
mlx_delete_texture(scene->textures.loaded_textures.we);
if (scene->textures.loaded_textures.ea)
free(scene->textures.loaded_textures.ea);
if (scene->textures.wall_texture)
free(scene->textures.wall_texture);
mlx_delete_texture(scene->textures.loaded_textures.ea);
if (message)
handle_error(message);
exit(EXIT_SUCCESS);
Expand Down
4 changes: 2 additions & 2 deletions sources/mlx_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ int handle_mlx(mlx_t **mlx, mlx_image_t **image)
*image = mlx_new_image(*mlx, SCREEN_WIDTH, SCREEN_HEIGHT);
if (!(*image))
{
mlx_close_window(*mlx);
mlx_terminate(*mlx);
return (1);
}
if (mlx_image_to_window(*mlx, *image, 0, 0) == -1)
{
mlx_close_window(*mlx);
mlx_terminate(*mlx);
return (1);
}
return (0);
Expand Down

0 comments on commit a479d0b

Please sign in to comment.