aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 20:09:07 +0100
committerRudy Bousset <rbousset@z2r4p3.le-101.fr>2020-02-09 20:09:07 +0100
commit2cf0485db50f566354cdfdef20214b2c0a4e1dca (patch)
tree21285f994ff8ab2b68cd5834191224c519a63767 /src
parentmap update (diff)
download42-cub3d-2cf0485db50f566354cdfdef20214b2c0a4e1dca.tar.gz
42-cub3d-2cf0485db50f566354cdfdef20214b2c0a4e1dca.tar.bz2
42-cub3d-2cf0485db50f566354cdfdef20214b2c0a4e1dca.tar.xz
42-cub3d-2cf0485db50f566354cdfdef20214b2c0a4e1dca.tar.zst
42-cub3d-2cf0485db50f566354cdfdef20214b2c0a4e1dca.zip
Clean norme
Diffstat (limited to 'src')
-rw-r--r--src/ft_click_close.c1
-rw-r--r--src/ft_init_lists.c24
-rw-r--r--src/main.c12
3 files changed, 24 insertions, 13 deletions
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);
+}
diff --git a/src/main.c b/src/main.c
index 439b884..77da0bc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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));