diff --git a/includes/so_long.h b/includes/so_long.h index af45e66..5da804c 100644 --- a/includes/so_long.h +++ b/includes/so_long.h @@ -6,7 +6,7 @@ /* By: nbuchhol +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/03 12:15:22 by nbuchhol #+# #+# */ -/* Updated: 2025/01/20 16:56:01 by nbuchhol ### ########.fr */ +/* Updated: 2025/01/24 14:41:59 by nbuchhol ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,16 +26,16 @@ typedef struct s_valid_check { size_t first_line_len; - int qnt_player; - int qnt_collectibles; - int qnt_exit; + size_t qnt_player; + size_t qnt_collectibles; + size_t qnt_exit; } t_valid_check; typedef struct s_game { char **map; - int map_hight; - int map_width; + size_t map_hight; + size_t map_width; } t_game; size_t ft_strlen(const char *s); @@ -45,7 +45,7 @@ void *ft_calloc(size_t nmemb, size_t size); char *ft_substr(const char *s, unsigned int start, size_t len); char *get_next_line(int fd); void free_map(int map_fd, char *line); -int error_handling(void); +int error_handling(int error_code); int valid_map(char *map); diff --git a/maps/teste.ber b/maps/teste.ber index 5579c74..03fb008 100644 --- a/maps/teste.ber +++ b/maps/teste.ber @@ -1,4 +1,4 @@ 1111111111111 1P0011E000C01 -1000000000001 +10000C0000001 1111111111111 diff --git a/src/error_handling.c b/src/error_handling.c index ec00637..dff06c0 100644 --- a/src/error_handling.c +++ b/src/error_handling.c @@ -6,13 +6,13 @@ /* By: nbuchhol +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/06 11:40:33 by nbuchhol #+# #+# */ -/* Updated: 2025/01/06 11:43:18 by nbuchhol ### ########.fr */ +/* Updated: 2025/01/23 11:45:45 by nbuchhol ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/so_long.h" -int error_handling(void) +int error_handling(int error_code) { write(1, "Error\n", 7); return (1); diff --git a/src/utils_validation_map.c b/src/utils_validation_map.c new file mode 100644 index 0000000..1b90d18 --- /dev/null +++ b/src/utils_validation_map.c @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils_validation_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: nbuchhol +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/01/24 13:55:48 by nbuchhol #+# #+# */ +/* Updated: 2025/01/24 15:15:20 by nbuchhol ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/so_long.h" + +int is_rectangle(char **map, size_t map_w, size_t map_h) +{ + size_t x; + + x = 1; + while (x < map_h) + { + if (ft_strlen(map[x]) != map_w) + return (error_handling(1)); + x++; + } + return (0); +} + +int valid_chars(char **map, size_t map_h, size_t map_w) +{ + size_t y; + size_t x; + + y = 0; + while (y < map_h) + { + x = 0; + while (x < map_w) + { + if (!ft_strchr("EPC10", map[y][x])) + return (error_handling(1)); + x++; + } + y++; + } + return (0); +} + +int element_blocked(char **map, size_t map_w, size_t map_h) +{ + return (0); +} diff --git a/src/validate_map.c b/src/validate_map.c index 7a4afcf..827d403 100644 --- a/src/validate_map.c +++ b/src/validate_map.c @@ -6,7 +6,7 @@ /* By: nbuchhol +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/09 09:58:46 by nbuchhol #+# #+# */ -/* Updated: 2025/01/20 16:54:14 by nbuchhol ### ########.fr */ +/* Updated: 2025/01/23 11:49:39 by nbuchhol ### ########.fr */ /* */ /* ************************************************************************** */ @@ -73,7 +73,17 @@ int valid_map(char *map_file) game.map = load_map(map_fd, &game); if (!game.map) return (free_map(map_fd, NULL), 1); + // flood fill close(map_fd); return (0); } +int flood_fill(char **map) +{ + int x; + int y; + + x = 0; + y = 0; + +}