From 45521211b0ea167c8a44d9f5c549d8fcf79b9a0c Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Mon, 12 Jun 2023 14:31:59 +0200 Subject: [PATCH] clean: norm --- TestParsing/..cub | 30 ++++++++++++++++++++++++++++++ TestParsing/.cub | 0 TestParsing/DuplicateArg.cub | 12 ++++++++++++ TestParsing/Empty.cub | 0 TestParsing/EmptyLineMap.cub | 13 +++++++++++++ TestParsing/EmptyNL.cub | 1 + TestParsing/MissingMap.cub | 9 +++++++++ TestParsing/MissingRGB.cub | 12 ++++++++++++ TestParsing/MissingTexture.cub | 11 +++++++++++ TestParsing/NoFileTexture.cub | 12 ++++++++++++ TestParsing/NoPos.cub | 12 ++++++++++++ TestParsing/NoRightTexture.cub | 12 ++++++++++++ TestParsing/NoWallBottom.cub | 12 ++++++++++++ TestParsing/NoWallCorner.cub | 12 ++++++++++++ TestParsing/NoWallLeft.cub | 12 ++++++++++++ TestParsing/NoWallMiddle.cub | 13 +++++++++++++ TestParsing/NoWallRight.cub | 12 ++++++++++++ TestParsing/NoWallTop.cub | 12 ++++++++++++ TestParsing/TooManyArg.cub | 13 +++++++++++++ TestParsing/TwoPos.cub | 12 ++++++++++++ TestParsing/UnknowChar.cub | 12 ++++++++++++ TestParsing/WrongArg.cub | 12 ++++++++++++ TestParsing/WrongExtention.cube | 12 ++++++++++++ TestParsing/WrongExtention3.cu | 12 ++++++++++++ TestParsing/WrongRGB.cub | 12 ++++++++++++ TestParsing/map_empty.cub | 10 ++++++++++ cube3D.h | 3 +-- libftx/extra/extra.h | 7 ++++--- map/parsing_body.c | 18 +++++++++++++++++- map/parsing_body2.c | 18 +----------------- 30 files changed, 315 insertions(+), 23 deletions(-) create mode 100644 TestParsing/..cub create mode 100644 TestParsing/.cub create mode 100644 TestParsing/DuplicateArg.cub create mode 100644 TestParsing/Empty.cub create mode 100644 TestParsing/EmptyLineMap.cub create mode 100644 TestParsing/EmptyNL.cub create mode 100644 TestParsing/MissingMap.cub create mode 100644 TestParsing/MissingRGB.cub create mode 100644 TestParsing/MissingTexture.cub create mode 100644 TestParsing/NoFileTexture.cub create mode 100644 TestParsing/NoPos.cub create mode 100644 TestParsing/NoRightTexture.cub create mode 100644 TestParsing/NoWallBottom.cub create mode 100644 TestParsing/NoWallCorner.cub create mode 100644 TestParsing/NoWallLeft.cub create mode 100644 TestParsing/NoWallMiddle.cub create mode 100644 TestParsing/NoWallRight.cub create mode 100644 TestParsing/NoWallTop.cub create mode 100644 TestParsing/TooManyArg.cub create mode 100644 TestParsing/TwoPos.cub create mode 100644 TestParsing/UnknowChar.cub create mode 100644 TestParsing/WrongArg.cub create mode 100644 TestParsing/WrongExtention.cube create mode 100644 TestParsing/WrongExtention3.cu create mode 100644 TestParsing/WrongRGB.cub create mode 100644 TestParsing/map_empty.cub diff --git a/TestParsing/..cub b/TestParsing/..cub new file mode 100644 index 0000000..bce3fb4 --- /dev/null +++ b/TestParsing/..cub @@ -0,0 +1,30 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + + + + + +F 220,100,0 +C 0,0,255 + + + + + + 111111111111111111111111 + 1000000000110000000000001 + 1011000001110000000000001 + 1001000001 1000000000001 +111111111011000001110000000000001 +100000000011000001110111111111111 +11110111111111011100000010001 +11110111111111011101010010001 +11000000110101011100000010001 +10000000E00000100000000100011 +10000000000000001101010010001 +11000001110101011111011110001 +11110111 1110101 101111010001 +11111111 1111111111111111111 diff --git a/TestParsing/.cub b/TestParsing/.cub new file mode 100644 index 0000000..e69de29 diff --git a/TestParsing/DuplicateArg.cub b/TestParsing/DuplicateArg.cub new file mode 100644 index 0000000..c363605 --- /dev/null +++ b/TestParsing/DuplicateArg.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +WE ./assets/W.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/Empty.cub b/TestParsing/Empty.cub new file mode 100644 index 0000000..e69de29 diff --git a/TestParsing/EmptyLineMap.cub b/TestParsing/EmptyLineMap.cub new file mode 100644 index 0000000..21e6e63 --- /dev/null +++ b/TestParsing/EmptyLineMap.cub @@ -0,0 +1,13 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 + +10N011111 +11111 diff --git a/TestParsing/EmptyNL.cub b/TestParsing/EmptyNL.cub new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/TestParsing/EmptyNL.cub @@ -0,0 +1 @@ + diff --git a/TestParsing/MissingMap.cub b/TestParsing/MissingMap.cub new file mode 100644 index 0000000..485a262 --- /dev/null +++ b/TestParsing/MissingMap.cub @@ -0,0 +1,9 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + diff --git a/TestParsing/MissingRGB.cub b/TestParsing/MissingRGB.cub new file mode 100644 index 0000000..3e23823 --- /dev/null +++ b/TestParsing/MissingRGB.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 + + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/MissingTexture.cub b/TestParsing/MissingTexture.cub new file mode 100644 index 0000000..c8a32ee --- /dev/null +++ b/TestParsing/MissingTexture.cub @@ -0,0 +1,11 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm + + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/NoFileTexture.cub b/TestParsing/NoFileTexture.cub new file mode 100644 index 0000000..af72017 --- /dev/null +++ b/TestParsing/NoFileTexture.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/NotAFile + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/NoPos.cub b/TestParsing/NoPos.cub new file mode 100644 index 0000000..e0cc999 --- /dev/null +++ b/TestParsing/NoPos.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +100011111 +11111 diff --git a/TestParsing/NoRightTexture.cub b/TestParsing/NoRightTexture.cub new file mode 100644 index 0000000..da526bf --- /dev/null +++ b/TestParsing/NoRightTexture.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/ENoRight.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/NoWallBottom.cub b/TestParsing/NoWallBottom.cub new file mode 100644 index 0000000..c808677 --- /dev/null +++ b/TestParsing/NoWallBottom.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11011 diff --git a/TestParsing/NoWallCorner.cub b/TestParsing/NoWallCorner.cub new file mode 100644 index 0000000..924892c --- /dev/null +++ b/TestParsing/NoWallCorner.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111100 + 10000001 +10N011111 +11111 diff --git a/TestParsing/NoWallLeft.cub b/TestParsing/NoWallLeft.cub new file mode 100644 index 0000000..00e6de6 --- /dev/null +++ b/TestParsing/NoWallLeft.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +00N011111 +11111 diff --git a/TestParsing/NoWallMiddle.cub b/TestParsing/NoWallMiddle.cub new file mode 100644 index 0000000..062d8c0 --- /dev/null +++ b/TestParsing/NoWallMiddle.cub @@ -0,0 +1,13 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 + 100 00001 +10N011111 +11111 diff --git a/TestParsing/NoWallRight.cub b/TestParsing/NoWallRight.cub new file mode 100644 index 0000000..40bcf5c --- /dev/null +++ b/TestParsing/NoWallRight.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000000 +10N011111 +11111 diff --git a/TestParsing/NoWallTop.cub b/TestParsing/NoWallTop.cub new file mode 100644 index 0000000..32603e9 --- /dev/null +++ b/TestParsing/NoWallTop.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11101111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/TooManyArg.cub b/TestParsing/TooManyArg.cub new file mode 100644 index 0000000..ade46de --- /dev/null +++ b/TestParsing/TooManyArg.cub @@ -0,0 +1,13 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/TwoPos.cub b/TestParsing/TwoPos.cub new file mode 100644 index 0000000..b4d793a --- /dev/null +++ b/TestParsing/TwoPos.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 100000E1 +10N011111 +11111 diff --git a/TestParsing/UnknowChar.cub b/TestParsing/UnknowChar.cub new file mode 100644 index 0000000..f080f5d --- /dev/null +++ b/TestParsing/UnknowChar.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10008001 +10N011111 +11111 diff --git a/TestParsing/WrongArg.cub b/TestParsing/WrongArg.cub new file mode 100644 index 0000000..33c5d16 --- /dev/null +++ b/TestParsing/WrongArg.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EW ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/WrongExtention.cube b/TestParsing/WrongExtention.cube new file mode 100644 index 0000000..3215e7a --- /dev/null +++ b/TestParsing/WrongExtention.cube @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/WrongExtention3.cu b/TestParsing/WrongExtention3.cu new file mode 100644 index 0000000..3215e7a --- /dev/null +++ b/TestParsing/WrongExtention3.cu @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/WrongRGB.cub b/TestParsing/WrongRGB.cub new file mode 100644 index 0000000..ad723a9 --- /dev/null +++ b/TestParsing/WrongRGB.cub @@ -0,0 +1,12 @@ +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,256 + + 11111111 + 10000001 +10N011111 +11111 diff --git a/TestParsing/map_empty.cub b/TestParsing/map_empty.cub new file mode 100644 index 0000000..b33fe89 --- /dev/null +++ b/TestParsing/map_empty.cub @@ -0,0 +1,10 @@ + +NO ./assets/N.xpm +SO ./assets/S.xpm +WE ./assets/W.xpm +EA ./assets/E.xpm + +F 200,100,0 +C 0,0,255 + + diff --git a/cube3D.h b/cube3D.h index 0fb209a..c1e1027 100644 --- a/cube3D.h +++ b/cube3D.h @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/26 12:34:04 by erey-bet #+# #+# */ -/* Updated: 2023/05/05 11:37:41 by cchauvet ### ########.fr */ +/* Updated: 2023/06/12 14:31:28 by cchauvet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,6 @@ # include # include - /*INIT*/ int start_game(t_map map); diff --git a/libftx/extra/extra.h b/libftx/extra/extra.h index 44fe9c4..503cc0e 100644 --- a/libftx/extra/extra.h +++ b/libftx/extra/extra.h @@ -6,7 +6,7 @@ /* By: cchauvet # include -#include +# include # include # include # include "../libft/libft.h" @@ -31,7 +31,8 @@ char *ft_strgen(char c, size_t len); char *ft_strfjoin(char *s1, char *s2); char *ft_strmerger(size_t arg_len, ...); int ft_is_in(const char *str, char c); -char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size); +char **ft_tabrealloc(char **tab, size_t current_size, + size_t new_size); char *ft_strndup(const char *src, size_t n); ssize_t ft_strchri(char *str, char c); int ft_contain_only_str(const char *str, const char *to_find); diff --git a/map/parsing_body.c b/map/parsing_body.c index 75fa174..6c897bd 100644 --- a/map/parsing_body.c +++ b/map/parsing_body.c @@ -6,7 +6,7 @@ /* By: cchauvet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/05/16 14:51:13 by cchauvet #+# #+# */ -/* Updated: 2023/05/16 16:34:23 by cchauvet ### ########.fr */ +/* Updated: 2023/05/17 16:29:12 by cchauvet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -67,3 +67,19 @@ int get_spawn_position(const char **body, double *spawn_x, double *spawn_y) return (2); return (0); } + +int map_is_in_one_part(const char **body) +{ + int y; + + y = ft_tablen((const void **) body) - 1; + while (body[y][0] == '\0' || ft_contain_only(body[y], ' ')) + y--; + while (y > 0) + { + if (body[y][0] == '\0' || ft_contain_only(body[y], ' ')) + return (1); + y--; + } + return (0); +} diff --git a/map/parsing_body2.c b/map/parsing_body2.c index 8a8c0d7..923afb3 100644 --- a/map/parsing_body2.c +++ b/map/parsing_body2.c @@ -6,28 +6,12 @@ /* By: cchauvet 0) - { - if (body[y][0] == '\0' || ft_contain_only(body[y], ' ')) - return (1); - y--; - } - return (0); -} - static int map_surround(const char **body) { int y;