diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 16:41:06 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 16:41:06 +0100 |
commit | e51748b78bd082d3f781930ba9eba619f0342bf6 (patch) | |
tree | 81871b5c1b6325bc20a2999e3bbd80f418973688 /src/ft_check_missing.c | |
parent | Got colors (diff) | |
download | 42-cub3d-e51748b78bd082d3f781930ba9eba619f0342bf6.tar.gz 42-cub3d-e51748b78bd082d3f781930ba9eba619f0342bf6.tar.bz2 42-cub3d-e51748b78bd082d3f781930ba9eba619f0342bf6.tar.xz 42-cub3d-e51748b78bd082d3f781930ba9eba619f0342bf6.tar.zst 42-cub3d-e51748b78bd082d3f781930ba9eba619f0342bf6.zip |
Better error management
Diffstat (limited to 'src/ft_check_missing.c')
-rw-r--r-- | src/ft_check_missing.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c new file mode 100644 index 0000000..ed86a32 --- /dev/null +++ b/src/ft_check_missing.c @@ -0,0 +1,32 @@ +#include <libft.h> +#include <cub3d.h> +#include <unistd.h> + +int +ft_missing_error(const char *err, t_cub *clist) +{ + ft_dprintf(STDERR_FILENO, "Error\n"); + ft_dprintf(STDERR_FILENO, + "\033[1;31mMissing element: %s\033[0m\n", err); + return (ft_exit(1, clist)); +} + +int +ft_check_missing(t_cub *clist) +{ + if (!clist->no_tex_path) + return (ft_missing_error("north side texture", clist)); + else if (!clist->so_tex_path) + return (ft_missing_error("south side texture", clist)); + else if (!clist->ea_tex_path) + return (ft_missing_error("east side texture", clist)); + else if (!clist->we_tex_path) + return (ft_missing_error("west side texture", clist)); + else if (clist->wlist->x_size < 0 || clist->wlist->y_size < 0) + return (ft_missing_error("resolution", clist)); + else if (clist->f_color < 0) + return (ft_missing_error("floor color", clist)); + else if (clist->c_color < 0) + return (ft_missing_error("ceiling color", clist)); + return (0); +} |