aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-01 22:54:56 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-01 22:54:56 +0100
commit459016417094600407756ebe7d387cdc5e4ca6d2 (patch)
tree1a0963fe89f5fa9e173198cd143c5c5ef142952c /src/main.c
parentCool code man (diff)
download42-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/main.c')
-rw-r--r--src/main.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/main.c b/src/main.c
index 3585626..74c9b45 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,42 +13,21 @@
#include <libft.h>
#include <mlx.h>
#include <cub3d.h>
-#include <stddef.h>
-#include <unistd.h>
int
main(int argc, const char *argv[])
{
t_cub *clist;
- if (argc < 2)
- {
- ft_dprintf(STDERR_FILENO, "Error\n\033[1;31mNo map selected\n\033[0m");
+ if (ft_check_map_arg(argc, argv) == FT_RET_BAD_ARGV)
return (FT_RET_BAD_ARGV);
- }
if (ft_init_cub3d(&clist) < 0)
return (FT_RET_FAILED_STRUCTS);
ft_parse_map(argv[1], clist);
if (ft_init_winlx(clist) < 0)
return (ft_exit(FT_RET_FAILED_MLX, clist));
ft_wall_tex_init(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);
- }
- 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));
- }
- /* ft_music(clist); */
- return (0);
+ if (ft_use_args(argc, argv, clist) == FT_RET_FINE)
+ return (FT_RET_FINE);
+ return (FT_RET_FINE);
}