aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_check_missing.c32
-rw-r--r--src/ft_get_map_redo.c12
-rw-r--r--src/ft_init_lists.c15
-rw-r--r--src/ft_parse_map.c4
4 files changed, 58 insertions, 5 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c
new file mode 100644
index 0000000..ed86a32
--- /dev/null
+++ b/src/ft_check_missing.c
@@ -0,0 +1,32 @@
+#include <libft.h>
+#include <cub3d.h>
+#include <unistd.h>
+
+int
+ft_missing_error(const char *err, t_cub *clist)
+{
+ ft_dprintf(STDERR_FILENO, "Error\n");
+ ft_dprintf(STDERR_FILENO,
+ "\033[1;31mMissing element: %s\033[0m\n", err);
+ return (ft_exit(1, clist));
+}
+
+int
+ft_check_missing(t_cub *clist)
+{
+ if (!clist->no_tex_path)
+ return (ft_missing_error("north side texture", clist));
+ else if (!clist->so_tex_path)
+ return (ft_missing_error("south side texture", clist));
+ else if (!clist->ea_tex_path)
+ return (ft_missing_error("east side texture", clist));
+ else if (!clist->we_tex_path)
+ return (ft_missing_error("west side texture", clist));
+ else if (clist->wlist->x_size < 0 || clist->wlist->y_size < 0)
+ return (ft_missing_error("resolution", clist));
+ else if (clist->f_color < 0)
+ return (ft_missing_error("floor color", clist));
+ else if (clist->c_color < 0)
+ return (ft_missing_error("ceiling color", clist));
+ return (0);
+}
diff --git a/src/ft_get_map_redo.c b/src/ft_get_map_redo.c
new file mode 100644
index 0000000..9b7793b
--- /dev/null
+++ b/src/ft_get_map_redo.c
@@ -0,0 +1,12 @@
+#include <libft.h>
+#include <cub3d.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+int
+ft_get_map(int fd, t_cub *clist)
+{
+ (void)fd;
+ (void)clist;
+ return (0);
+}
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index f9c5c6c..4fb5256 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -14,9 +14,11 @@ t_win
if (!(wlist->wlx = ft_calloc(1, 1)) ||
!(wlist->winptr = ft_calloc(1, 1)))
return (NULL);
+ wlist->wlx = NULL;
+ wlist->winptr = NULL;
wlist->inited = 0;
- wlist->x_size = 0;
- wlist->y_size = 0;
+ wlist->x_size = -1;
+ wlist->y_size = -1;
return (wlist);
}
@@ -33,8 +35,8 @@ t_cub
!(clist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(clist->sprite_path = (char*)ft_calloc(1, sizeof(char))))
return (NULL);
- clist->f_color = 0;
- clist->c_color = 0;
+ clist->f_color = -1;
+ clist->c_color = -1;
if (!(clist->map = (char**)ft_calloc(2, sizeof(char*))))
return (NULL);
if (!(clist->map[0] = (char*)ft_calloc(1, sizeof(char))))
@@ -42,5 +44,10 @@ t_cub
clist->map[1] = 0;
clist->map_w = 0;
clist->line_chk = 0;
+ clist->no_tex_path = NULL;
+ clist->so_tex_path = NULL;
+ clist->ea_tex_path = NULL;
+ clist->we_tex_path = NULL;
+ clist->sprite_path = NULL;
return (clist);
}
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index 52c6316..0be76bc 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -91,7 +91,9 @@ ft_parse_map(const char *map_path, t_cub *clist)
ret = 1;
while (ret != 12)
ret = ft_parse_it(fd, clist);
- ft_get_map(fd, clist);
+ ft_check_missing(clist);
+ if (ft_get_map(fd, clist) < 0)
+ ft_map_error(clist);
/* if (ft_get_tex(fd, clist) < 0) */
/* return ; */
/* ft_check_empty_line(fd, 6, clist); */