diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-04 02:14:19 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-04 02:14:19 +0100 |
commit | af4075e546ecc25f0572099e95472c10e9a93f2b (patch) | |
tree | 2edaa3f0832a5b27d42c716bf92ec8f0c7bdd3b6 /src/ft_check_map_surrounds.c | |
parent | The surrounds (diff) | |
download | 42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.gz 42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.bz2 42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.xz 42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.zst 42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.zip |
chek
Diffstat (limited to 'src/ft_check_map_surrounds.c')
-rw-r--r-- | src/ft_check_map_surrounds.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/ft_check_map_surrounds.c b/src/ft_check_map_surrounds.c index 8c38a85..fbe2ff8 100644 --- a/src/ft_check_map_surrounds.c +++ b/src/ft_check_map_surrounds.c @@ -15,13 +15,35 @@ #include <stddef.h> #include <stdint.h> +static int8_t + ft_wall_check(size_t y, size_t x, char** const map) +{ + if (map[y + 1][x] == ' ' || + map[y - 1][x] == ' ' || + map[y][x + 1] == ' ' || + map[y][x - 1] == ' ' || + map[y + 1][x + 1] == ' ' || + map[y - 1][x + 1] == ' ' || + map[y + 1][x - 1] == ' ' || + map[y - 1][x - 1] == ' ' || + map[y + 1][x] == '\0' || + map[y - 1][x] == '\0' || + map[y][x + 1] == '\0' || + map[y][x - 1] == '\0' || + map[y + 1][x + 1] == '\0' || + map[y - 1][x + 1] == '\0' || + map[y + 1][x - 1] == '\0' || + map[y - 1][x - 1] == '\0') + return (-1); + return (0); +} + void ft_check_map_surrounds(t_map *ml, t_cub *cl) { size_t y; size_t x; - (void)ml; y = 0; x = 0; while (ml->map[y]) @@ -30,12 +52,7 @@ void { if (ft_ischarset("02NESWL", ml->map[y][x])) { - if ( - ft_ischarset(" \0", ml->map[y + 1][x]) || - ft_ischarset(" \0", ml->map[y - 1][x]) || - ft_ischarset(" \0", ml->map[y][x + 1]) || - ft_ischarset(" \0", ml->map[y][x - 1]) - ) + if (ft_wall_check(y, x, ml->map) < 0) ft_map_error(FT_ERR_MAP_WALLS, cl); } x++; |