aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-04 02:14:19 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-04 02:14:19 +0100
commitaf4075e546ecc25f0572099e95472c10e9a93f2b (patch)
tree2edaa3f0832a5b27d42c716bf92ec8f0c7bdd3b6
parentThe surrounds (diff)
download42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.gz
42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.bz2
42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.xz
42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.tar.zst
42-cub3d-af4075e546ecc25f0572099e95472c10e9a93f2b.zip
chek
-rw-r--r--inc/cub3d_defines.h1
-rw-r--r--map/map_five.cub10
-rw-r--r--map/map_two.cub102
-rw-r--r--src/ft_check_map_surrounds.c31
-rw-r--r--src/ft_parse_map.c2
5 files changed, 84 insertions, 62 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index a403c5f..969e9fc 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -130,6 +130,7 @@ enum
# define FT_ERR_MULT_SPAWN "multiple spawn points"
# define FT_ERR_MULT_NLVL "multiple spawn new level access points"
# define FT_ERR_MAP_WALLS "map is not surrounded by walls"
+# define FT_ERR_MAP_SPACE "unexpected space"
# define FT_ERR_MAP_EMPL "empty line in map"
# define FT_ERR_MAP_L_L "last line is invalid"
# define FT_ERR_RD_NO "could not find north side texture file"
diff --git a/map/map_five.cub b/map/map_five.cub
index 80ebff6..0ab70b2 100644
--- a/map/map_five.cub
+++ b/map/map_five.cub
@@ -8,17 +8,21 @@ S ./media/img/crapaud.xpm
F 220,100,0
C 225,30,0
+LT ./media/img/linuz.xpm
+L ./map/map_two.cub
+
1111111111111111111111111
1000000000110000000000001
- 1011000001110000002000001
+ 1000000000110000000000001
+ 1011000001110000000000L01
1001000000000000000000001
111111111011000001110000000000001
-100000000011000001110111111111111
+100000000011000001111111111111111
11110111111111011100000010001
11110111111111011101010000001
11000000110101011100000000001
10002000000000000000000000001
10000000000000000001010000001
11000001110101011111011110N0111
-11110111 1110101 101111010001
+11110111 1110101 101111 10001
11111111 1111111 111111111111
diff --git a/map/map_two.cub b/map/map_two.cub
index c1f3e29..2d6dd1c 100644
--- a/map/map_two.cub
+++ b/map/map_two.cub
@@ -9,54 +9,54 @@ S ./media/img/linuz.xpm
C 50,100,200
F 150,150,124
-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-1 E 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1
-1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1
-1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 1 1 0 0 0 0 2 0 0 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 1
-1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 1
-1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+111111111111111111111111111111111111111111111111111111
+1E0000000000001100000011000000110000001100000011000001
+100100000000000000000000000000000000000000000000000001
+101100000000010000000000000000000000000000000000000001
+111111111111111110000000000000000001111111111111110011
+100000000000001100000011000000110000001100000011000001
+100100000000000000000000000000000000000000000000000001
+101100000000011100000111000001110000011100000111000001
+100000000000000000000000000000000000000000000000000001
+100002000200020002000200020002000200020002000200020001
+100000000000000000000000000000000000000000000000000001
+110000000000110101001101010001000000000000000000010111
+100020000000000000000000000001111111111111111110000011
+100000000000000000000000000000000000000000000000000011
+110000000000110101001101010011010100110101001101010111
+111101100011111101111111011111110111111101111111010111
+101100000000010000000000000000000000000000000000000001
+101100000000010000000000000000000000000000000000000001
+101100011000010011001100110011001100110011001100110001
+101100000000010011001100110011001100110011001100110001
+101100011000110000000000000000000000000000000000000001
+101100000000100000000000000000000000000000000000000001
+101100011000100011001100110011001100110011001100110001
+101100000000100011001100110011001100110011001100110001
+101100011000100000000000000000000000000000000000000001
+101100000000100000000000000000000000000000000000000001
+101100011000100011001100110011001100110011001100110001
+101100000000100011001100110011001100110011001100110001
+101100011000100000000000000000000000000000000000000001
+101100000000100000000000000000000000000000000000000001
+101100011000100011001100110011001100110011001100110001
+101100000000100011001100110011001100110011001100110001
+101100011000100000000000000000000000000000000000000001
+101100000000100000000000000000000000000000000000000001
+101100011000100011001100110011001100110011001100110001
+101100000000100011001100110011001100110011001100110001
+101100011000100000000000000000000000000000000000000001
+101100000000010000000000000000000000000000000000000001
+101100011000010011001100110011001100110011001100110001
+101100000000010011001100110011001100110011001100110001
+101102020202010000000000000000000000000000000000000001
+101100000000010000000000000000000000000000000000000001
+101100002000010011001100110011001100110011001100110001
+101100000000010011001100110011001100110011001100110001
+101100002000010000000000000000000000000000000000000001
+101100000000010000000000000000000000000000000000000001
+101100002000010011001100110011001100110011001100010101
+101100000000010011001100110011001100110011001100010101
+101100000000010000000000000000000000000000000000000001
+101100000000010000000000000000000000000000000000000001
+111111111111111111111111111111111111111111111111111111
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++;
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index eb62f3f..2d5590e 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -65,7 +65,7 @@ static int8_t
}
if (ft_ischarset("1 ", line[0]))
return ((ft_get_map_first_line(line, clist) < 0) ? (-1) : (12));
- if (!ft_ischarset("RNSEWFCLM\0", line[0])
+ if (!ft_ischarset("RNSEWFCLM", line[0])
|| !(words = ft_split(line, ' ')))
return (ft_error_here(FT_ERR_ILL_ENTRY, line, clist));
if ((ret = ft_select_get(words, clist)) == 12)