aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/main.c b/src/main.c
index 52bb211..43b482a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,26 +13,20 @@
#include <libft.h>
#include <mlx.h>
#include <cub3d.h>
-#include <stddef.h>
-#include <unistd.h>
int
- main(int argc, const char *argv[])
+ main(int argc, const char *argv[], char *const envp[])
{
- t_cub *clist;
+ t_cub clist;
- if (argc < 2)
- {
- ft_dprintf(STDERR_FILENO, "Error\n\033[1;31mNo map selected\n\033[0m");
- return (1);
- }
+ if (ft_check_map_arg(argc, argv) == FT_RET_BAD_ARGV)
+ return (FT_RET_BAD_ARGV);
if (ft_init_cub3d(&clist) < 0)
- return (2);
- ft_parse_map(argv[1], clist);
- if (ft_init_winlx(clist) < 0)
- return (ft_exit(3, clist));
- ft_wall_tex_init(clist);
- ft_draw_scene(clist);
- ft_hooks_and_loops(clist->wlist, clist);
- return (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);
+ ft_use_args(argc, argv, envp, &clist);
+ return (FT_RET_FINE);
}