Skip to content

Commit

Permalink
minor fix: missing validation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkosComK committed Jan 26, 2025
1 parent 8b70dbf commit efeb58f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Binary file modified cub3D
Binary file not shown.
4 changes: 2 additions & 2 deletions maps/valid/test.cub
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ EA assets/texture/east.xpm
111111111111
100E00E000001111
1000000000000001
1000100000001111
10001000000E1111
100000001111
10000001
100W0001
100W00E1
11111111
6 changes: 3 additions & 3 deletions srcs/checker/flood_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool flood_fill(char **grid, int height, int width, t_vector_i start)
{
if (!recursive_flood_fill(grid, start, height, width))
{
printf("Error: Map is not fully enclosed.\n");
printf("Error\nMap is not fully enclosed.\n");
return (false);
}
return (true);
Expand All @@ -99,13 +99,13 @@ bool is_map_valid(t_game *game)
map_copy = copy_map(game->map.grid, game->map.height);
if (!map_copy)
{
printf("Error:\n Failed to create map copy.\n");
printf("Error\nFailed to create map copy.\n");
return (cleanup_game(game), exit(1), false);
}
if (!find_start_position(map_copy,
game->map.height, game->map.width, &start))
{
printf("Error:\n Player starting position not found.\n");
printf("Error\nPlayer starting position not found.\n");
free_map_copy(map_copy, game->map.height);
return (cleanup_game(game), exit(1), false);
}
Expand Down
5 changes: 3 additions & 2 deletions srcs/error/cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ void cleanup_gun(t_game *game)
i = 0;
while (i < 4)
{
if (game->p1.gun_anim[i].img)
if (game->p1.gun_anim && game->p1.gun_anim[i].img)
{
mlx_destroy_image(game->mlx, game->p1.gun_anim[i].img);
}
i++;
}
free(game->p1.gun_anim);
if (game->p1.gun_anim)
free(game->p1.gun_anim);
game->p1.gun_anim = NULL;
}

Expand Down

0 comments on commit efeb58f

Please # to comment.