diff options
| author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-27 20:36:43 +0100 | 
|---|---|---|
| committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-27 20:36:43 +0100 | 
| commit | c72cf43c89fd216af50c8d209c64d8b6ff188a1c (patch) | |
| tree | 0a7f58ae43eea281469543a5726ca7e31ad9713e /src | |
| parent | Even nicer (diff) | |
| download | 42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.gz 42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.bz2 42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.xz 42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.tar.zst 42-cub3d-c72cf43c89fd216af50c8d209c64d8b6ff188a1c.zip  | |
Okkokokokokok
Diffstat (limited to 'src')
| -rw-r--r-- | src/ft_get_map.c | 8 | ||||
| -rw-r--r-- | src/ft_parse_map.c | 20 | 
2 files changed, 28 insertions, 0 deletions
diff --git a/src/ft_get_map.c b/src/ft_get_map.c index 06f3353..ff16df1 100644 --- a/src/ft_get_map.c +++ b/src/ft_get_map.c @@ -42,8 +42,16 @@ ft_check_err(char *line, size_t size)  static char  *ft_get_first_line(char *line, t_cub *clist)  { +	size_t	i;  	char	*mapl; +	i = 0; +	while (i < ft_strlen(line) && line[i]) +	{ +		if (line[i] != '1' && line[i] != '\0') +			return (NULL); +		i += 2; +	}  	clist->map_w = ft_strlen(line);  	if (clist->map_w <= 2 || ft_check_err(line, clist->map_w) < 0)  		return (NULL); diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 1f31ca1..1911e5c 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -30,6 +30,24 @@ ft_check_cub(const char *map_path, t_cub *clist)  	ft_free_words(words, NULL);  } +static void +ft_check_last_line(t_cub *clist) +{ +	size_t	i; +	size_t	j; + +	i = 0; +	while (clist->map[i]) +		i++; +	j = 0; +	while (clist->map[i - 1][j]) +	{ +		if (clist->map[i - 1][j] != '1' && clist->map[i - 1][j] != '\0') +			ft_map_error(11 + i - 1, clist); +		j++; +	} +} +  /*  ** I can't close fd  */ @@ -57,5 +75,7 @@ ft_parse_map(const char *map_path, t_cub *clist)  	ft_check_empty_line(fd, 10, clist);  	if (ft_get_map(fd, clist) < 0)  		ft_map_error(11, clist); +	ft_check_last_line(clist);  	ft_print_list(clist); +	close(fd);  }  | 
