/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_treat_args.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:29:00 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:29:08 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include #include 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); if (clist.mlist.ismusic) pthread_create(&clist.tid, NULL, ft_music_thread, clist); ft_hooks_and_loops(clist.wlist, 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); }