diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ft_error.c | 4 | ||||
| -rw-r--r-- | src/ft_exit.c | 1 | ||||
| -rw-r--r-- | src/ft_init_bmp.c | 18 | ||||
| -rw-r--r-- | src/ft_init_map.c | 3 | ||||
| -rw-r--r-- | src/ft_parse_map.c | 15 | 
5 files changed, 23 insertions, 18 deletions
diff --git a/src/ft_error.c b/src/ft_error.c index b793b96..87be01e 100644 --- a/src/ft_error.c +++ b/src/ft_error.c @@ -15,13 +15,13 @@  #include <unistd.h>  int -	ft_error(const char *errmsg, t_cub *clist) +	ft_error(uint8_t retval, const char *errmsg, t_cub *clist)  {  	ft_dprintf(STDERR_FILENO, "Error\n");  	ft_dprintf(STDERR_FILENO,  				"\033[1;31m%s\033[0m\n",  				errmsg); -	return (ft_exit(FT_RET_BMP_ERR, clist)); +	return (ft_exit(retval, clist));  }  int diff --git a/src/ft_exit.c b/src/ft_exit.c index 1be7a32..23cd466 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -21,6 +21,7 @@  static void  	ft_free_lists(t_cub *clist)  { +	ft_memdel((void**)&clist->mlist.filename);  	ft_memdel((void**)&clist->mlist.no_tex_path);  	ft_memdel((void**)&clist->mlist.so_tex_path);  	ft_memdel((void**)&clist->mlist.ea_tex_path); diff --git a/src/ft_init_bmp.c b/src/ft_init_bmp.c index cc8d59b..3236e2f 100644 --- a/src/ft_init_bmp.c +++ b/src/ft_init_bmp.c @@ -13,15 +13,15 @@  #include <cub3d.h>  #include <stdint.h> -t_bmp -	ft_init_bmp(void) +int8_t +	ft_init_bmp(t_bmp_file *bmp_file)  { -	t_bmp	bmp; +	t_bmp_file	bmp_file; -	bmp.file_type = 0x4d42; -	bmp.file_size = 0; -	bmp.reserv_one = 0; -	bmp.reserv_two = 0; -	bmp.offset_data = 0; -	return (bmp); +	bmp_file.file_type = 0x4d42; +	bmp_file.file_size = 0; +	bmp_file.reserv_one = 0; +	bmp_file.reserv_two = 0; +	bmp_file.offset_data = 0; +	return (bmp_file);  } diff --git a/src/ft_init_map.c b/src/ft_init_map.c index e2cfa21..4fa127c 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -18,7 +18,8 @@  static int8_t  	ft_init_map_callocs(t_map *mlist)  { -	if (!(mlist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) || +	if (!(mlist->filename = (char*)ft_calloc(1, sizeof(char))) || +		!(mlist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) ||  		!(mlist->so_tex_path = (char*)ft_calloc(1, sizeof(char))) ||  		!(mlist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) ||  		!(mlist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) || 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);  | 
