diff options
-rw-r--r-- | inc/cub3d.h | 5 | ||||
-rw-r--r-- | map/map_one.cub | 2 | ||||
-rw-r--r-- | src/ft_click_close.c | 1 | ||||
-rw-r--r-- | src/ft_init_lists.c | 24 | ||||
-rw-r--r-- | src/main.c | 12 |
5 files changed, 28 insertions, 16 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h index 749e2b6..bc9f1bd 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -125,8 +125,9 @@ typedef struct s_cub ** 6: not a .cub */ -t_win *ft_init_win(void); -t_cub *ft_init_cub(void); +int8_t ft_init_cub3d(t_cub **clist); +/* t_win *ft_init_win(void); */ +/* t_cub *ft_init_cub(void); */ int ft_key_event(int keycode, t_cub *clist); int ft_click_close(int keycode, t_cub *clist); int ft_exit(uint8_t exit_code, t_cub *clist); diff --git a/map/map_one.cub b/map/map_one.cub index d2da4ef..d988c7a 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -20,6 +20,6 @@ C 225,30,0 1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 1 0 0 0 1 -1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 N 0 0 1 +1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 N 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/src/ft_click_close.c b/src/ft_click_close.c index 9708b84..db3b2e2 100644 --- a/src/ft_click_close.c +++ b/src/ft_click_close.c @@ -21,7 +21,6 @@ int { (void)clist; ft_printf("Button [%d] pressed\n", keycode); - /* return (ft_exit(0, clist)); */ exit(0); return (0); } diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index ec46713..8cea58b 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -42,7 +42,7 @@ static t_player return (plist); } -t_win +static t_win *ft_init_win(void) { t_win *wlist; @@ -60,7 +60,7 @@ t_win return (wlist); } -t_cub +static t_cub *ft_init_cub(void) { t_cub *clist; @@ -87,3 +87,23 @@ t_cub clist->c_rgb = ft_init_rgb(); return (clist); } + +int8_t + ft_init_cub3d(t_cub **cl) +{ + t_cub *clist; + + if (!(clist = ft_init_cub())) + { + ft_memdel((void**)&clist); + return (-1); + } + if (!(clist->wlist = ft_init_win())) + { + ft_memdel((void**)&clist->wlist); + ft_memdel((void**)&clist); + return (-1); + } + *cl = clist; + return (0); +} @@ -14,6 +14,7 @@ #include <libft.h> #include <mlx.h> #include <cub3d.h> +#include <stddef.h> #include <unistd.h> int @@ -26,17 +27,8 @@ int ft_dprintf(STDERR_FILENO, "Error\n\033[1;31mNo map selected\n\033[0m"); return (1); } - if (!(clist = ft_init_cub())) - { - ft_memdel((void**)&clist); + if (ft_init_cub3d(&clist) < 0) return (2); - } - if (!(clist->wlist = ft_init_win())) - { - ft_memdel((void**)&clist->wlist); - ft_memdel((void**)&clist); - return (2); - } ft_parse_map(argv[1], clist); if (ft_init_winlx(clist) < 0) return (ft_exit(3, clist)); |