aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_check_not_found.c15
-rw-r--r--src/ft_get_sprite.c5
-rw-r--r--src/ft_get_tex.c20
-rw-r--r--src/ft_parse_map.c1
-rw-r--r--src/ft_print_list.c40
-rw-r--r--src/ft_tex_init.c12
6 files changed, 46 insertions, 47 deletions
diff --git a/src/ft_check_not_found.c b/src/ft_check_not_found.c
new file mode 100644
index 0000000..9233846
--- /dev/null
+++ b/src/ft_check_not_found.c
@@ -0,0 +1,15 @@
+#include <cub3d.h>
+#include <stdint.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int8_t
+ ft_check_not_found(const char *path)
+{
+ int fd;
+
+ if ((fd = open(path, O_RDONLY)) < 0)
+ return (-1);
+ close(fd);
+ return (0);
+}
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c
index 791f51f..ebf0566 100644
--- a/src/ft_get_sprite.c
+++ b/src/ft_get_sprite.c
@@ -35,5 +35,10 @@ int8_t
ft_strlen(FT_ERR_ALLOCATE) + 1);
return (-1);
}
+ if (ft_check_not_found(clist->mlist->sprite_path) < 0)
+ {
+ ft_strlcpy(clist->errmsg, FT_ERR_RD_SP, ft_strlen(FT_ERR_RD_SP) + 1);
+ return (-1);
+ }
return (0);
}
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c
index ad093ed..58a0358 100644
--- a/src/ft_get_tex.c
+++ b/src/ft_get_tex.c
@@ -35,6 +35,11 @@ int8_t
ft_strlen(FT_ERR_ALLOCATE) + 1);
return (-1);
}
+ if (ft_check_not_found(clist->mlist->no_tex_path) < 0)
+ {
+ ft_strlcpy(clist->errmsg, FT_ERR_RD_NO, ft_strlen(FT_ERR_RD_NO) + 1);
+ return (-1);
+ }
return (0);
}
@@ -59,6 +64,11 @@ int8_t
ft_strlen(FT_ERR_ALLOCATE) + 1);
return (-1);
}
+ if (ft_check_not_found(clist->mlist->so_tex_path) < 0)
+ {
+ ft_strlcpy(clist->errmsg, FT_ERR_RD_SO, ft_strlen(FT_ERR_RD_SO) + 1);
+ return (-1);
+ }
return (0);
}
@@ -83,6 +93,11 @@ int8_t
ft_strlen(FT_ERR_ALLOCATE) + 1);
return (-1);
}
+ if (ft_check_not_found(clist->mlist->ea_tex_path) < 0)
+ {
+ ft_strlcpy(clist->errmsg, FT_ERR_RD_EA, ft_strlen(FT_ERR_RD_EA) + 1);
+ return (-1);
+ }
return (0);
}
@@ -107,5 +122,10 @@ int8_t
ft_strlen(FT_ERR_ALLOCATE) + 1);
return (-1);
}
+ if (ft_check_not_found(clist->mlist->we_tex_path) < 0)
+ {
+ ft_strlcpy(clist->errmsg, FT_ERR_RD_WE, ft_strlen(FT_ERR_RD_WE) + 1);
+ return (-1);
+ }
return (0);
}
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index 4fd870b..0dfb779 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -100,6 +100,5 @@ void
ft_get_player_spawn(clist->plist, clist);
ft_check_missing(clist);
ft_set_minimap_scale(clist);
- ft_print_list(clist);
close(fd);
}
diff --git a/src/ft_print_list.c b/src/ft_print_list.c
deleted file mode 100644
index 3b44115..0000000
--- a/src/ft_print_list.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_print_list.c :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/02/14 17:28:57 by rbousset #+# #+# */
-/* Updated: 2020/02/14 17:28:57 by rbousset ### ########lyon.fr */
-/* */
-/* ************************************************************************** */
-
-#include <libft.h>
-#include <cub3d.h>
-
-void
- ft_print_list(t_cub *clist)
-{
- size_t i;
-
- ft_printf("x size ----- [%d]\n", clist->wlist->x_size);
- ft_printf("y size ----- [%d]\n", clist->wlist->y_size);
- ft_printf("North ------ [%s]\n", clist->mlist->no_tex_path);
- ft_printf("South ------ [%s]\n", clist->mlist->so_tex_path);
- ft_printf("West ------- [%s]\n", clist->mlist->we_tex_path);
- ft_printf("East ------- [%s]\n", clist->mlist->ea_tex_path);
- ft_printf("Sprite ----- [%s]\n", clist->mlist->sprite_path);
- ft_printf("F color ---- [%d]\n", ft_rgb_to_hex(clist->f_rgb));
- ft_printf("C color ---- [%d]\n", ft_rgb_to_hex(clist->c_rgb));
- i = 0;
- ft_printf("Map\n----\n");
- while (clist->mlist->map[i])
- {
- ft_printf("%2zu -- [%s]\n", i + 1, clist->mlist->map[i]);
- i++;
- }
- ft_printf("Map width -- [%zu]\n", clist->mlist->map_w);
- ft_printf("2D scale --- [%hhu]\n", clist->mlist->scale);
- ft_printf("----------------------\n");
-}
diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c
index 724877f..40e39e5 100644
--- a/src/ft_tex_init.c
+++ b/src/ft_tex_init.c
@@ -10,10 +10,10 @@
/* */
/* ************************************************************************** */
+#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
#include <mlx.h>
-#include <libft.h>
/*
** 0 : no
@@ -26,23 +26,23 @@
void ft_wall_tex_init(t_cub *cl)
{
cl->tlist[0].img = mlx_xpm_file_to_image(cl->wlist->wlx,
- cl->mlist->no_tex_path, &cl->tlist[0].img_w, &cl->tlist[0].img_h);
+ cl->mlist->no_tex_path, &cl->tlist[0].img_w, &cl->tlist[0].img_h);
cl->tlist[0].ptr = mlx_get_data_addr(cl->tlist[0].img,
&cl->tlist[0].bpp, &cl->tlist[0].sizeline, &cl->tlist[0].endian);
cl->tlist[1].img = mlx_xpm_file_to_image(cl->wlist->wlx,
- cl->mlist->so_tex_path, &cl->tlist[1].img_w, &cl->tlist[1].img_h);
+ cl->mlist->so_tex_path, &cl->tlist[1].img_w, &cl->tlist[1].img_h);
cl->tlist[1].ptr = mlx_get_data_addr(cl->tlist[1].img,
&cl->tlist[1].bpp, &cl->tlist[1].sizeline, &cl->tlist[1].endian);
cl->tlist[2].img = mlx_xpm_file_to_image(cl->wlist->wlx,
- cl->mlist->ea_tex_path, &cl->tlist[2].img_w, &cl->tlist[2].img_h);
+ cl->mlist->ea_tex_path, &cl->tlist[2].img_w, &cl->tlist[2].img_h);
cl->tlist[2].ptr = mlx_get_data_addr(cl->tlist[2].img,
&cl->tlist[2].bpp, &cl->tlist[2].sizeline, &cl->tlist[2].endian);
cl->tlist[3].img = mlx_xpm_file_to_image(cl->wlist->wlx,
- cl->mlist->we_tex_path, &cl->tlist[3].img_w, &cl->tlist[3].img_h);
+ cl->mlist->we_tex_path, &cl->tlist[3].img_w, &cl->tlist[3].img_h);
cl->tlist[3].ptr = mlx_get_data_addr(cl->tlist[3].img,
&cl->tlist[3].bpp, &cl->tlist[3].sizeline, &cl->tlist[3].endian);
cl->tlist[4].img = mlx_xpm_file_to_image(cl->wlist->wlx,
- cl->mlist->sprite_path, &cl->tlist[4].img_w, &cl->tlist[4].img_h);
+ cl->mlist->sprite_path, &cl->tlist[4].img_w, &cl->tlist[4].img_h);
cl->tlist[4].ptr = mlx_get_data_addr(cl->tlist[4].img,
&cl->tlist[4].bpp, &cl->tlist[4].sizeline, &cl->tlist[4].endian);
}