/* ************************************************************************** */ /* LE - / */ /* / */ /* ft_check_map_line.c .:: .:/ . .:: */ /* +:+:+ +: +: +:+:+ */ /* By: rbousset +:+ +: +: +:+ */ /* #+# #+ #+ #+# */ /* Created: 2020/02/02 17:19:10 by rbousset #+# ## ## #+# */ /* Updated: 2020/02/02 17:19:11 by rbousset ### #+. /#+ ###.fr */ /* / */ /* / */ /* ************************************************************************** */ #include #include #include #include size_t ft_get_line_len(char *line) { size_t i; size_t j; i = 0; j = 0; while (line[i]) { if (line[i] == ' ') j++; i++; } return (i - j); } int8_t ft_check_map_line(char *line, uint8_t l, t_cub *clist) { size_t i; i = 0; while (line[i]) { if (l != 1) { if (!ft_ischarset("012NSEW ", line[i])) return (-1); if (ft_ischarset("NSEW", line[i])) clist->isspawn += 1; if (clist->isspawn > 1) return (-1); } else { if (!ft_ischarset("1 ", line[i])) return (-1); } i++; } if (line[0] != '1' || line[i - 1] != '1' || ft_get_line_len(line) != clist->map_w) return (-1); return (0); }