/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_map.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: madumerg +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/11 11:24:13 by madumerg #+# #+# */ /* Updated: 2024/09/12 12:57:24 by madumerg ### ########.fr */ /* */ /* ************************************************************************** */ #include "cub3d.h" int err_not_close(char after, char before, char down, char up) { if (after == ' ' || after == '\0') return (1); else if (before == ' ' || before == '\0') return (1); else if (down == ' ' || down == '\0') return (1); else if (up == ' ' || up == '\0') return (1); return (0); } int actual_char(char actual) { if (actual == '0' || actual == 'N' || actual == 'W' || \ actual == 'S' || actual == 'E') return (0); return (1); } int check_map_close(char **map) { int y; int x; y = 0; while (map[y]) { x = 0; while (map[y][x]) { if (actual_char(map[y][x]) == 0 && \ (err_not_close(map[y][x + 1], map[y][x - 1], \ map[y + 1][x], map[y - 1][x]) == 1)) return (1); else x++; } y++; } return (0); } int count_player(char **map) { int y; int x; int cpt; cpt = 0; y = 0; while (map[y]) { x = 0; while (map[y][x]) { if (map[y][x] == 'N' || map[y][x] == 'S' || \ map[y][x] == 'E' || map[y][x] == 'W') cpt++; x++; } y++; } if (cpt != 1) return (1); return (0); } int check_char_map(char **map) { int y; int x; y = 0; while (map[y]) { x = 0; while (map[y][x]) { if (verif_char(map[y][x]) == 1) return (1); x++; } y++; } return (0); }