From d3891ea3953174760ab21f25ca00c205005eeac9 Mon Sep 17 00:00:00 2001 From: Jean Teissier Date: Tue, 27 Aug 2024 13:15:25 +0200 Subject: [PATCH 1/5] Removed unecessary is_cardinal_pos() check in find_start(), replaced with logicand to check for both values of coordinates having been set --- srcs/parser/parser_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srcs/parser/parser_utils.c b/srcs/parser/parser_utils.c index d4c84c9..8f43ff7 100644 --- a/srcs/parser/parser_utils.c +++ b/srcs/parser/parser_utils.c @@ -6,7 +6,7 @@ /* By: jteissie +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/16 18:12:37 by jteissie #+# #+# */ -/* Updated: 2024/08/26 15:47:38 by jteissie ### ########.fr */ +/* Updated: 2024/08/27 13:11:50 by jteissie ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,7 +92,7 @@ t_parse_status find_start(uint32_t coordinates[], char **map) y = 0; x++; } - if (coordinates[0] == 0 && (!is_cardinal_pos(map[0][0]))) + if (coordinates[0] == 0 && coordinates[1] == 0) return (MAP_ERR); return (MAP_OK); } From 26d479ffdc04e877a5cbd467925cc9be22f20970 Mon Sep 17 00:00:00 2001 From: Jean Teissier Date: Tue, 27 Aug 2024 13:19:42 +0200 Subject: [PATCH 2/5] Changed verify_map(), not initializes the start[] array to -1 to make default state clearer in find_start() verifications --- srcs/parser/parser.c | 6 +++--- srcs/parser/parser_utils.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/srcs/parser/parser.c b/srcs/parser/parser.c index cc4f227..ab3627c 100644 --- a/srcs/parser/parser.c +++ b/srcs/parser/parser.c @@ -6,7 +6,7 @@ /* By: jteissie +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/15 12:12:00 by tsuchen #+# #+# */ -/* Updated: 2024/08/26 15:48:20 by jteissie ### ########.fr */ +/* Updated: 2024/08/27 13:17:50 by jteissie ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,8 +52,8 @@ t_parse_status verify_map(char **map, t_data *data) { uint32_t start[2]; - start[0] = 0; - start[1] = 0; + start[0] = -1; + start[1] = -1; if (check_invalid_chars(map) == MAP_ERR) return (MAP_ERR); fill_whitespaces(map); diff --git a/srcs/parser/parser_utils.c b/srcs/parser/parser_utils.c index 8f43ff7..493e569 100644 --- a/srcs/parser/parser_utils.c +++ b/srcs/parser/parser_utils.c @@ -6,7 +6,7 @@ /* By: jteissie +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/16 18:12:37 by jteissie #+# #+# */ -/* Updated: 2024/08/27 13:11:50 by jteissie ### ########.fr */ +/* Updated: 2024/08/27 13:18:34 by jteissie ### ########.fr */ /* */ /* ************************************************************************** */ @@ -82,7 +82,7 @@ t_parse_status find_start(uint32_t coordinates[], char **map) { if (is_cardinal_pos(map[x][y])) { - if (coordinates[0] != 0 || coordinates[1] != 0) + if (coordinates[0] != -1 || coordinates[1] != -1) return (MAP_ERR); coordinates[0] = x; coordinates[1] = y; @@ -92,7 +92,7 @@ t_parse_status find_start(uint32_t coordinates[], char **map) y = 0; x++; } - if (coordinates[0] == 0 && coordinates[1] == 0) + if (coordinates[0] == -1) return (MAP_ERR); return (MAP_OK); } From 4a31b4c77f58cfa42f9d5e4c5b9408bc5e4ad578 Mon Sep 17 00:00:00 2001 From: Jean Teissier Date: Tue, 27 Aug 2024 13:25:17 +0200 Subject: [PATCH 3/5] Reverted previous change, start array initialized to 0 instead of -1 since all the other functions expect unsigned integers, I do not want to refactor the comparison to ft_strlen(map[x]) in check_walls() --- srcs/parser/parser_utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srcs/parser/parser_utils.c b/srcs/parser/parser_utils.c index 493e569..85e52d7 100644 --- a/srcs/parser/parser_utils.c +++ b/srcs/parser/parser_utils.c @@ -6,7 +6,7 @@ /* By: jteissie +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/16 18:12:37 by jteissie #+# #+# */ -/* Updated: 2024/08/27 13:18:34 by jteissie ### ########.fr */ +/* Updated: 2024/08/27 13:23:59 by jteissie ### ########.fr */ /* */ /* ************************************************************************** */ @@ -82,7 +82,7 @@ t_parse_status find_start(uint32_t coordinates[], char **map) { if (is_cardinal_pos(map[x][y])) { - if (coordinates[0] != -1 || coordinates[1] != -1) + if (coordinates[0] != 0 || coordinates[1] != 0) return (MAP_ERR); coordinates[0] = x; coordinates[1] = y; @@ -92,7 +92,7 @@ t_parse_status find_start(uint32_t coordinates[], char **map) y = 0; x++; } - if (coordinates[0] == -1) + if (coordinates[0] == 0 && coordinates[1] == 0) return (MAP_ERR); return (MAP_OK); } From b92d729b321387ec521fc268e1f15d749e142b9e Mon Sep 17 00:00:00 2001 From: Haliris <97298717+Haliris@users.noreply.github.com> Date: Tue, 27 Aug 2024 13:27:43 +0200 Subject: [PATCH 4/5] Update parser.c ACTUALLY INITALIZES TO 0 AND NOT INT_MIN + 1 --- srcs/parser/parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srcs/parser/parser.c b/srcs/parser/parser.c index ab3627c..f739940 100644 --- a/srcs/parser/parser.c +++ b/srcs/parser/parser.c @@ -52,8 +52,8 @@ t_parse_status verify_map(char **map, t_data *data) { uint32_t start[2]; - start[0] = -1; - start[1] = -1; + start[0] = 0; + start[1] = 0; if (check_invalid_chars(map) == MAP_ERR) return (MAP_ERR); fill_whitespaces(map); From 3befea156cfc8707387fe376ef45928fa91ed4ed Mon Sep 17 00:00:00 2001 From: Alex <147409817+Tsunghao-C@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:12:27 +0200 Subject: [PATCH 5/5] Update vector.c fixed line too long issue --- srcs/vector/vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcs/vector/vector.c b/srcs/vector/vector.c index 7f4464e..f1b1c5d 100644 --- a/srcs/vector/vector.c +++ b/srcs/vector/vector.c @@ -67,6 +67,6 @@ double vec_dot(const t_vec *vec_a, const t_vec *vec_b) // vec_transp(&a); // printf("vec_a after transp ax: %.2f, ay: %.2f\n", a.x, a.y); // vec_rotate(&b, PI/6); -// printf("vec_b after rotate 30 degree counterclockwise bx: %.2f, by: %.2f\n", b.x, b.y); +// printf("vec_b after rotate 30 degree bx: %.2f, by: %.2f\n", b.x, b.y); // return (0); // }