aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_parse_map.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-04 16:03:30 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-04 16:03:30 +0100
commitdea9844db4bf893525d692209d004968e4bf89ad (patch)
tree5a7547d2adddfcd2c1c15a8e1db6c86344b46640 /src/ft_parse_map.c
parentInit bmp (diff)
download42-cub3d-dea9844db4bf893525d692209d004968e4bf89ad.tar.gz
42-cub3d-dea9844db4bf893525d692209d004968e4bf89ad.tar.bz2
42-cub3d-dea9844db4bf893525d692209d004968e4bf89ad.tar.xz
42-cub3d-dea9844db4bf893525d692209d004968e4bf89ad.tar.zst
42-cub3d-dea9844db4bf893525d692209d004968e4bf89ad.zip
Tab
Diffstat (limited to 'src/ft_parse_map.c')
-rw-r--r--src/ft_parse_map.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index 3d19fdc..d3a90af 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -74,12 +74,14 @@ static int8_t
return (ret);
}
-static void
- ft_no_map_error(t_cub *clist)
+void
+ ft_save_name(t_map *mlist, t_cub *clist)
{
- ft_dprintf(STDERR_FILENO, "Error\n");
- ft_dprintf(STDERR_FILENO, "\033[31;1mNo map\033[0m\n");
- ft_exit(FT_RET_NO_MAP, clist);
+ ft_memdel((void**)mlist->filename);
+ if (!(mlist->filename =
+ (char*)malloc((ft_strlen(map_path) + 1) * sizeof(char))))
+ ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist);
+ ft_sprintf(mlist->filename, map_path);
}
void
@@ -90,9 +92,10 @@ void
if (ft_check_ext(map_path, ".cub") < 0)
ft_map_error(FT_ERR_NOT_A_CUB, clist);
+ ft_save_name(&clist->mlist, clist);
fd = open(map_path, O_RDONLY);
if (fd < 0)
- ft_no_map_error(clist);
+ ft_error(FT_RET_NO_MAP, FT_ERR_NO_MAP, clist);
ret = 1;
while (ret != 12 && ret >= 0)
ret = ft_parse_it(fd, clist);