diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-12 23:47:37 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-12 23:47:37 +0100 |
commit | a2f0bde9da402ddfd47ec54d42b83585c3296ebf (patch) | |
tree | ff99c82f9a31064617953607eacd56fd1a862827 /src/ft_check_missing.c | |
parent | Secured traps (diff) | |
download | 42-cub3d-a2f0bde9da402ddfd47ec54d42b83585c3296ebf.tar.gz 42-cub3d-a2f0bde9da402ddfd47ec54d42b83585c3296ebf.tar.bz2 42-cub3d-a2f0bde9da402ddfd47ec54d42b83585c3296ebf.tar.xz 42-cub3d-a2f0bde9da402ddfd47ec54d42b83585c3296ebf.tar.zst 42-cub3d-a2f0bde9da402ddfd47ec54d42b83585c3296ebf.zip |
Secured parsing
Diffstat (limited to 'src/ft_check_missing.c')
-rw-r--r-- | src/ft_check_missing.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c index 51c0c23..d01a77f 100644 --- a/src/ft_check_missing.c +++ b/src/ft_check_missing.c @@ -20,7 +20,22 @@ int ft_dprintf(STDERR_FILENO, "Error\n"); ft_dprintf(STDERR_FILENO, "\033[1;31m%s %s\033[0m\n", FT_ERR_MISS_ELEMENT, err); - return (ft_exit(1, clist)); + return (ft_exit(FT_ERR_MISSING, clist)); +} + +static int + ft_check_missing_sprites(t_cub *clist) +{ + int8_t i; + + i = 0; + while ((i + 2) <= clist->mlist.topsp) + { + if (!clist->mlist.sprite_path[i][0]) + return (ft_missing_error(FT_ERR_MISS_SPRITE, clist)); + i++; + } + return (0); } static int @@ -46,7 +61,7 @@ static int return (ft_missing_error(FT_ERR_MISS_NLVL_PATH, clist)); if (clist->mlist.istraps && !clist->mlist.traps_path[0]) return (ft_missing_error(FT_ERR_MISS_TRAP, clist)); - return (0); + return (ft_check_missing_sprites(clist)); } int @@ -60,7 +75,7 @@ int return (ft_missing_error(FT_ERR_MISS_EAST, clist)); else if (!clist->mlist.we_tex_path[0]) return (ft_missing_error(FT_ERR_MISS_WEST, clist)); - else if (!clist->mlist.sprite_path[0]) + else if (!clist->mlist.sprite_path[0][0]) return (ft_missing_error(FT_ERR_MISS_SPRITE, clist)); else if (clist->wlist.x_size == 0 || clist->wlist.y_size == 0) return (ft_missing_error(FT_ERR_MISS_RESOLUTION, clist)); |