diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-01 22:54:56 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-01 22:54:56 +0100 |
commit | 459016417094600407756ebe7d387cdc5e4ca6d2 (patch) | |
tree | 1a0963fe89f5fa9e173198cd143c5c5ef142952c /src/ft_treat_args.c | |
parent | Cool code man (diff) | |
download | 42-cub3d-459016417094600407756ebe7d387cdc5e4ca6d2.tar.gz 42-cub3d-459016417094600407756ebe7d387cdc5e4ca6d2.tar.bz2 42-cub3d-459016417094600407756ebe7d387cdc5e4ca6d2.tar.xz 42-cub3d-459016417094600407756ebe7d387cdc5e4ca6d2.tar.zst 42-cub3d-459016417094600407756ebe7d387cdc5e4ca6d2.zip |
Norme
Diffstat (limited to 'src/ft_treat_args.c')
-rw-r--r-- | src/ft_treat_args.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c new file mode 100644 index 0000000..fae81a0 --- /dev/null +++ b/src/ft_treat_args.c @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_treat_args.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:29:00 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:29:08 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <stdint.h> +#include <unistd.h> + +uint8_t + ft_check_map_arg(int argc, const char *argv[]) +{ + (void)argv; + if (argc < 2) + { + ft_dprintf(STDERR_FILENO, "Error\n\033[1;31mNo map selected\n\033[0m"); + return (FT_RET_BAD_ARGV); + } + return (0); +} + +uint8_t + ft_use_args(int argc, const char *argv[], t_cub *clist) +{ + if (argc < 3) + { + if (ft_init_winptr(clist) < 0) + return (ft_exit(FT_RET_FAILED_MLX, clist)); + ft_draw_scene(clist); + ft_hooks_and_loops(clist->wlist, clist); + /* ft_music(clist); */ + } + else if (argc == 3 && !ft_strncmp("--save", argv[2], 7)) + { + ft_draw_scene_bmp(clist); + return (ft_exit(FT_RET_FINE, clist)); + } + else + { + ft_dprintf(STDERR_FILENO, "Error\n\033[1;31mBad arguments\n\033[0m"); + return (ft_exit(FT_RET_BAD_ARGV, clist)); + } + return (FT_RET_FINE); +} |