From b26a84b9bbe87cf030491f71bea57ea81e5b9b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Fri, 20 Dec 2024 15:07:20 +0100 Subject: [PATCH 01/10] build: not forcing the default compilator --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8e8bb3c..4414c32 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2024/12/20 15:00:12 by rparodi ### ########.fr # +# Updated: 2024/12/20 15:06:28 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ NAME = Cub3D NAME_BONUS = Cub3D_bonus # Commands -CC = cc +CC ?= cc RM = rm -rf # Flags From 4d2b8cb60b36f3bf1668eaad6754bb8ea502fbae Mon Sep 17 00:00:00 2001 From: Baptiste Goulard coderc de lacam Date: Fri, 20 Dec 2024 16:02:08 +0100 Subject: [PATCH 02/10] Fix: no longer launch window in case of parse error, catch error on multiple player in map --- Makefile | 1 + ft_addons/ft_strchrs.c | 24 ++++++++++++++++++++ includes/cub3d_struct.h | 3 ++- includes/ft_addons.h | 4 +++- parsing/load_tiles.c | 50 ++++++++++++++++++++++++++++------------- sources/error.c | 3 ++- sources/main.c | 6 ++--- 7 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 ft_addons/ft_strchrs.c diff --git a/Makefile b/Makefile index 4414c32..ebce9dd 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ LDFLAGS += $(MLXFLAGS) SRC =\ ft_addons/ft_inrange.c \ + ft_addons/ft_strchrs.c \ mlx_layer/mlx_init.c \ mlx_layer/looks.c \ mlx_layer/mooves.c \ diff --git a/ft_addons/ft_strchrs.c b/ft_addons/ft_strchrs.c new file mode 100644 index 0000000..7f4db63 --- /dev/null +++ b/ft_addons/ft_strchrs.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchrs.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: bgoulard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/12/20 15:56:28 by bgoulard #+# #+# */ +/* Updated: 2024/12/20 15:58:47 by bgoulard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_string.h" + +void *ft_strchrs(const char *str, const char *chrs) +{ + while (*str) + { + if (ft_strchr(chrs, *str)) + return ((void *)str); + str++; + } + return (NULL); +} diff --git a/includes/cub3d_struct.h b/includes/cub3d_struct.h index bd936d0..c788560 100644 --- a/includes/cub3d_struct.h +++ b/includes/cub3d_struct.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/28 13:53:54 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 14:47:00 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 15:42:21 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -138,6 +138,7 @@ typedef enum e_error ERROR_PARSE_NO_BG_COLOR, ERROR_PARSE_ALREADY_SET, ERROR_PARSE_META_IN_MAP, + ERROR_PARSE_MULTIPLE_PLAYER, ERROR_CLI, ERROR_MLX, ERROR_TEXTURE_FORMAT, diff --git a/includes/ft_addons.h b/includes/ft_addons.h index c531d3d..743a8ef 100644 --- a/includes/ft_addons.h +++ b/includes/ft_addons.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/16 06:09:01 by bgoulard #+# #+# */ -/* Updated: 2024/12/16 15:34:31 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 15:57:10 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,4 +30,6 @@ bool ft_inrange_ex(int value, int min, int max); /// @return true if the value is in the range, false otherwise bool ft_inrange(int value, int min, int max); +void *ft_strchrs(const char *str, const char *chrs); + #endif diff --git a/parsing/load_tiles.c b/parsing/load_tiles.c index 555e4ad..85448bf 100644 --- a/parsing/load_tiles.c +++ b/parsing/load_tiles.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/01 17:47:15 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 14:46:40 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 15:59:04 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,22 +15,13 @@ #include "cub3d_parsing.h" #include "ft_string.h" +#include "ft_addons.h" #include "ft_vector.h" #include "ft_math.h" +#include #include -void *ft_strchrs(const char *str, const char *chrs) -{ - while (*str) - { - if (ft_strchr(chrs, *str)) - return ((void *)str); - str++; - } - return (NULL); -} - int str_to_tile(const char *str, t_tile *tile, size_t size) { size_t i; @@ -74,15 +65,44 @@ t_vector *load_vector(t_map *map) return (str_map); } +#define EPMP ERROR_PARSE_MULTIPLE_PLAYER + +static bool multiple_player_same_line(const char *str) +{ + const bool p_symbol[8] = {\ + !ft_strchr(str, 'S'), !ft_strchr(str, 'E'), !ft_strchr(str, 'W'), \ + !ft_strchr(str, 'N'), !(ft_strrchr(str, 'N') - ft_strchr(str, 'N')), \ + !(ft_strrchr(str, 'E') - ft_strchr(str, 'E')), \ + !(ft_strrchr(str, 'W') - ft_strchr(str, 'W')), \ + !(ft_strrchr(str, 'S') - ft_strchr(str, 'S')), }; + int i; + int j; + + i = 0; + while (i < 4) + { + j = 0; + while (j < 4) + if (p_symbol[j++] == true && p_symbol[i] == true) + return (true); + i++; + } + i = 0; + while (i < 4) + if (p_symbol[i++ + 4]) + return (true); + return (false); +} + int set_player(t_info *info, int i, t_vector *str_map) { t_dpoint pos; char *str; ft_bzero(&pos, sizeof(t_dpoint)); - if (info->player.pos.x != 0 || info->player.pos.y != 0 || i == 0) - return (ft_vec_destroy(&str_map), info->last_error = ERROR_PARSE, \ - EXIT_FAILURE); + if (info->player.pos.x != 0 || info->player.pos.y != 0 || i == 0 || \ + multiple_player_same_line(ft_vec_at(str_map, i))) + return (ft_vec_destroy(&str_map), sv_errno(info, EPMP), EXIT_FAILURE); str = ft_strchrs(ft_vec_at(str_map, i), "SNWE"); pos.y = i + .5; pos.x = str - (char *)ft_vec_at(str_map, i) + .5; diff --git a/sources/error.c b/sources/error.c index 65ba971..dab3d02 100644 --- a/sources/error.c +++ b/sources/error.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */ -/* Updated: 2024/12/20 14:43:52 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 15:52:43 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,6 +41,7 @@ const char **get_error_message(void) err_msg[ERROR_TEXTURE_MISSING] = "texture missing"; err_msg[ERROR_PARSE_NO_BG_COLOR] = "no background color provided"; err_msg[ERROR_PARSE_META_IN_MAP] = "meta data in map (should be above)"; + err_msg[ERROR_PARSE_MULTIPLE_PLAYER] = "multiple player in map"; return (err_msg); } diff --git a/sources/main.c b/sources/main.c index fe1d716..0c35e60 100644 --- a/sources/main.c +++ b/sources/main.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/30 16:30:03 by rparodi #+# #+# */ -/* Updated: 2024/12/17 17:17:12 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 15:54:59 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,12 +41,12 @@ void run_cub3d(t_info *info) if (!info->mlx_ptr) return (sv_errno(info, ERROR_MLX), (void)0); parse_map(info); + if (info->last_error != NO_ERROR) + return ; if (init_mlx_env(info) != NO_ERROR) return (c3_perror(info)); if (info->cli_ctx.debug) ft_putstr_fd("no debug mod on production run", STDERR_FILENO); - if (info->last_error != NO_ERROR) - return ; if (info->cli_ctx.no_graphics == true) return ; info->camera.screen_buff = mlx_new_image(info->mlx_ptr, info->screen_size.x, From 22a93a5a589590a00a53878c45e551c69d0edb2a Mon Sep 17 00:00:00 2001 From: Baptiste Goulard coderc de lacam Date: Fri, 20 Dec 2024 16:35:37 +0100 Subject: [PATCH 03/10] Fix: fix on multiple player catch --- maps/bad_muplie_players__different_lines.cub | 14 +++++++++ maps/bad_muplie_players__oneline.cub | 11 +++++++ maps/valid_03_isle.cub | 30 ++++++++++++++++++++ parsing/load_tiles.c | 8 +++--- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 maps/bad_muplie_players__different_lines.cub create mode 100644 maps/bad_muplie_players__oneline.cub create mode 100644 maps/valid_03_isle.cub diff --git a/maps/bad_muplie_players__different_lines.cub b/maps/bad_muplie_players__different_lines.cub new file mode 100644 index 0000000..8db0e57 --- /dev/null +++ b/maps/bad_muplie_players__different_lines.cub @@ -0,0 +1,14 @@ +SO ./textures/chiseled_tuff.xpm +NO ./textures/chiseled_tuff_bricks.xpm +WE ./textures/chiseled_stone_bricks.xpm +EA ./textures/chiseled_tuff_bricks_top.xpm + +F 0,255,0 +C 0,255,255 + +111111 +1N0001 +10E001 +100W01 +1000S1 +111111 diff --git a/maps/bad_muplie_players__oneline.cub b/maps/bad_muplie_players__oneline.cub new file mode 100644 index 0000000..0ffa966 --- /dev/null +++ b/maps/bad_muplie_players__oneline.cub @@ -0,0 +1,11 @@ +SO ./textures/chiseled_tuff.xpm +NO ./textures/chiseled_tuff_bricks.xpm +WE ./textures/chiseled_stone_bricks.xpm +EA ./textures/chiseled_tuff_bricks_top.xpm + +F 0,255,0 +C 0,255,255 + +111111 +1NEWS1 +111111 diff --git a/maps/valid_03_isle.cub b/maps/valid_03_isle.cub new file mode 100644 index 0000000..31a2b63 --- /dev/null +++ b/maps/valid_03_isle.cub @@ -0,0 +1,30 @@ +SO ./textures/chiseled_tuff.xpm +NO ./textures/chiseled_tuff_bricks.xpm +WE ./textures/chiseled_stone_bricks.xpm +EA ./textures/chiseled_tuff_bricks_top.xpm + +F 0,255,0 +C 0,255,255 + + + + + + + + + + +1 1 1 11 1 +1111 1 111 1 1 +111 1 1 1 1 +11111111111111111111111 +100000000S0000000000001 0 +10000000000000000000001 +10000000000000000000001 1 +11111011101100111110011 1 +11000000000000000000001 +11110111111111111111111 1 +11111111 1 + 1 + 1 diff --git a/parsing/load_tiles.c b/parsing/load_tiles.c index 85448bf..fcaf4af 100644 --- a/parsing/load_tiles.c +++ b/parsing/load_tiles.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/01 17:47:15 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 15:59:04 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 16:35:03 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,15 +81,15 @@ static bool multiple_player_same_line(const char *str) i = 0; while (i < 4) { - j = 0; + j = i + 1; while (j < 4) - if (p_symbol[j++] == true && p_symbol[i] == true) + if (!p_symbol[j++] && !p_symbol[i]) return (true); i++; } i = 0; while (i < 4) - if (p_symbol[i++ + 4]) + if (p_symbol[i++ + 4] && !p_symbol[i]) return (true); return (false); } From 06e47c03093e103ab222db9804474ee851ddfa4e Mon Sep 17 00:00:00 2001 From: Baptiste Goulard coderc de lacam Date: Fri, 20 Dec 2024 16:56:04 +0100 Subject: [PATCH 04/10] Fix: fix on multiple player catch + traverse map ' ' != wall --- includes/cub3d_struct.h | 3 ++- parsing/load_tiles.c | 22 +++++++++------------- parsing/traverse_map.c | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/includes/cub3d_struct.h b/includes/cub3d_struct.h index c788560..3bc24e9 100644 --- a/includes/cub3d_struct.h +++ b/includes/cub3d_struct.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/28 13:53:54 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 15:42:21 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 16:54:34 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -72,6 +72,7 @@ typedef enum e_tile { EMPTY = 0, WALL = 1, + WALL_ERR = 3, NONE = 2 } t_tile_type; diff --git a/parsing/load_tiles.c b/parsing/load_tiles.c index fcaf4af..1a17126 100644 --- a/parsing/load_tiles.c +++ b/parsing/load_tiles.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/01 17:47:15 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 16:35:03 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 16:54:12 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,8 +29,10 @@ int str_to_tile(const char *str, t_tile *tile, size_t size) i = 0; while (str[i]) { - if (str[i] == '1' || str[i] == ' ') + if (str[i] == '1') tile[i].tile_type = WALL; + else if (str[i] == ' ') + tile[i].tile_type = WALL_ERR; else if (!ft_strchr("0NSWE", str[i])) return (-1); else @@ -69,28 +71,22 @@ t_vector *load_vector(t_map *map) static bool multiple_player_same_line(const char *str) { - const bool p_symbol[8] = {\ - !ft_strchr(str, 'S'), !ft_strchr(str, 'E'), !ft_strchr(str, 'W'), \ - !ft_strchr(str, 'N'), !(ft_strrchr(str, 'N') - ft_strchr(str, 'N')), \ - !(ft_strrchr(str, 'E') - ft_strchr(str, 'E')), \ - !(ft_strrchr(str, 'W') - ft_strchr(str, 'W')), \ - !(ft_strrchr(str, 'S') - ft_strchr(str, 'S')), }; + const char *identifiers = "NEWS"; int i; int j; i = 0; while (i < 4) { + if (ft_strchr(str, identifiers[i]) != ft_strrchr(str, identifiers[i])) + return (true); j = i + 1; while (j < 4) - if (!p_symbol[j++] && !p_symbol[i]) + if (ft_strchr(str, identifiers[j++]) && \ + ft_strchr(str, identifiers[i])) return (true); i++; } - i = 0; - while (i < 4) - if (p_symbol[i++ + 4] && !p_symbol[i]) - return (true); return (false); } diff --git a/parsing/traverse_map.c b/parsing/traverse_map.c index 8444880..8ae1105 100644 --- a/parsing/traverse_map.c +++ b/parsing/traverse_map.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/01 17:49:12 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 14:49:43 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 16:54:55 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,7 +33,7 @@ bool flood_fill(t_tile *tiles, t_ipoint pos, t_ipoint maxs) current = c3_get_cell(tiles, maxs, pos); if (current->tile_visited == true || current->tile_type == WALL) return (true); - if (current->tile_type == NONE) + if (current->tile_type == NONE || current->tile_type == WALL_ERR) return (false); current->tile_visited = true; i = 0; From fa1826a0be68a8dc9123500b59f1d66da472a62c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Fri, 20 Dec 2024 17:09:19 +0100 Subject: [PATCH 05/10] style: renaming the maps for corresponding to bgoulard names --- maps/{empty.cub => bad_empty.cub} | 0 ...ty_textures.cub => bad_empty_textures.cub} | 0 maps/large.cub | 194 ------------------ maps/valid_02.cub | 9 +- maps/valid_04_corridor.cub | 20 ++ 5 files changed, 25 insertions(+), 198 deletions(-) rename maps/{empty.cub => bad_empty.cub} (100%) rename maps/{empty_textures.cub => bad_empty_textures.cub} (100%) delete mode 100644 maps/large.cub create mode 100644 maps/valid_04_corridor.cub diff --git a/maps/empty.cub b/maps/bad_empty.cub similarity index 100% rename from maps/empty.cub rename to maps/bad_empty.cub diff --git a/maps/empty_textures.cub b/maps/bad_empty_textures.cub similarity index 100% rename from maps/empty_textures.cub rename to maps/bad_empty_textures.cub diff --git a/maps/large.cub b/maps/large.cub deleted file mode 100644 index a146f21..0000000 --- a/maps/large.cub +++ /dev/null @@ -1,194 +0,0 @@ -SO ./textures/chiseled_tuff.xpm -NO ./textures/chiseled_tuff_bricks.xpm -WE ./textures/chiseled_stone_bricks.xpm -EA ./textures/chiseled_tuff_bricks_top.xpm - -F 0,255,0 -C 0,255,255 - - - - - - - - - - - - - -111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000S00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011111111111111111111111111111001111111111111111111111111111100111111111111111111111111111110011 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111110111011001111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -11111111 diff --git a/maps/valid_02.cub b/maps/valid_02.cub index c467d8c..6544dbf 100644 --- a/maps/valid_02.cub +++ b/maps/valid_02.cub @@ -1,7 +1,8 @@ -SO ./textures/b.xpm -NO ./textures/wasteland_32.xpm -WE ./textures/sandy_32.xpm -EA ./textures/cobblestone_32.xpm +SO ./textures/chiseled_tuff.xpm +NO ./textures/chiseled_tuff_bricks.xpm +WE ./textures/chiseled_stone_bricks.xpm +EA ./textures/chiseled_tuff_bricks_top.xpm + F 0,255,0 C 0,123,255 diff --git a/maps/valid_04_corridor.cub b/maps/valid_04_corridor.cub new file mode 100644 index 0000000..171ac60 --- /dev/null +++ b/maps/valid_04_corridor.cub @@ -0,0 +1,20 @@ +SO ./textures/chiseled_tuff.xpm +NO ./textures/chiseled_tuff_bricks.xpm +WE ./textures/chiseled_stone_bricks.xpm +EA ./textures/chiseled_tuff_bricks_top.xpm + +F 0,255,0 +C 0,255,255 + + + + + + + + + + +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000W1 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 From e7cc81387ec2ed71470f2c099b45be1eaf493fd4 Mon Sep 17 00:00:00 2001 From: Baptiste Goulard coderc de lacam Date: Fri, 20 Dec 2024 17:12:49 +0100 Subject: [PATCH 06/10] Fix: added check on missing player --- Makefile | 1 + includes/cub3d_parsing.h | 4 +- includes/cub3d_struct.h | 3 +- parsing/load_tiles.c | 80 ++++++++++------------------------------ parsing/set_player.c | 67 +++++++++++++++++++++++++++++++++ sources/error.c | 3 +- 6 files changed, 95 insertions(+), 63 deletions(-) create mode 100644 parsing/set_player.c diff --git a/Makefile b/Makefile index ebce9dd..c4ae664 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,7 @@ SRC =\ parsing/load_textures.c \ parsing/load_bgs.c \ parsing/traverse_map.c \ + parsing/set_player.c \ parsing/load_file.c \ parsing/utils.c \ parsing/map.c \ diff --git a/includes/cub3d_parsing.h b/includes/cub3d_parsing.h index d66f95a..45d3287 100644 --- a/includes/cub3d_parsing.h +++ b/includes/cub3d_parsing.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/11 14:41:07 by bgoulard #+# #+# */ -/* Updated: 2024/12/01 17:53:02 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 17:07:58 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ # define CUB3D_PARSING_H # include "cub3d_struct.h" +# include "ft_vector_types.h" # include # define C3D_PRS_PLS "SO" @@ -27,6 +28,7 @@ t_tile *c3_get_cell(t_tile *map, t_ipoint dimensions, t_ipoint pos); bool is_identifier(const char *str, const char **id_str); +int set_player(t_info *info, int i, t_vector *str_map); void *load_file(void *data); void *load_bgs(void *data); diff --git a/includes/cub3d_struct.h b/includes/cub3d_struct.h index 3bc24e9..34985dc 100644 --- a/includes/cub3d_struct.h +++ b/includes/cub3d_struct.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/28 13:53:54 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 16:54:34 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 17:01:40 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -140,6 +140,7 @@ typedef enum e_error ERROR_PARSE_ALREADY_SET, ERROR_PARSE_META_IN_MAP, ERROR_PARSE_MULTIPLE_PLAYER, + ERROR_NO_PLAYER, ERROR_CLI, ERROR_MLX, ERROR_TEXTURE_FORMAT, diff --git a/parsing/load_tiles.c b/parsing/load_tiles.c index 1a17126..de2abf5 100644 --- a/parsing/load_tiles.c +++ b/parsing/load_tiles.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/01 17:47:15 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 16:54:12 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 17:09:44 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,6 +20,7 @@ #include "ft_math.h" #include +#include #include int str_to_tile(const char *str, t_tile *tile, size_t size) @@ -67,69 +68,14 @@ t_vector *load_vector(t_map *map) return (str_map); } -#define EPMP ERROR_PARSE_MULTIPLE_PLAYER +#define EPMIM ERROR_PARSE_META_IN_MAP +#define ENP ERROR_NO_PLAYER -static bool multiple_player_same_line(const char *str) +t_info *load_tiles_norm(t_info *info, t_vector *str_map) { - const char *identifiers = "NEWS"; - int i; - int j; + size_t i; i = 0; - while (i < 4) - { - if (ft_strchr(str, identifiers[i]) != ft_strrchr(str, identifiers[i])) - return (true); - j = i + 1; - while (j < 4) - if (ft_strchr(str, identifiers[j++]) && \ - ft_strchr(str, identifiers[i])) - return (true); - i++; - } - return (false); -} - -int set_player(t_info *info, int i, t_vector *str_map) -{ - t_dpoint pos; - char *str; - - ft_bzero(&pos, sizeof(t_dpoint)); - if (info->player.pos.x != 0 || info->player.pos.y != 0 || i == 0 || \ - multiple_player_same_line(ft_vec_at(str_map, i))) - return (ft_vec_destroy(&str_map), sv_errno(info, EPMP), EXIT_FAILURE); - str = ft_strchrs(ft_vec_at(str_map, i), "SNWE"); - pos.y = i + .5; - pos.x = str - (char *)ft_vec_at(str_map, i) + .5; - info->player.dir = (t_dpoint){.x = 0, 0}; - info->player.pos = pos; - info->player.pos_i = (t_ipoint){.x = (int)pos.x, .y = (int)pos.y}; - if (*str == 'N') - info->player.dir.y = -1; - else if (*str == 'S') - info->player.dir.y = 1; - else if (*str == 'W') - info->player.dir.x = -1; - else if (*str == 'E') - info->player.dir.x = 1; - info->player.plane = (t_dpoint){.x = info->player.dir.y, \ - .y = -info->player.dir.x}; - return (EXIT_SUCCESS); -} - -#define EPMIM ERROR_PARSE_META_IN_MAP - -void *load_tiles(void *data) -{ - t_info *info; - t_vector *str_map; - size_t i; - - info = (t_info *)data; - str_map = load_vector(&info->map); - if (!str_map) - return (sv_errno(info, ERROR_MALLOC), NULL); info->map.map = ft_calloc(sizeof(t_tile), (info->map.size.y * info->map.size.x)); if (!info->map.map) @@ -145,5 +91,19 @@ void *load_tiles(void *data) return (NULL); i++; } + if (info->player.pos_i.x == 0) + return (ft_vec_destroy(&str_map), sv_errno(info, ENP), NULL); return (ft_vec_destroy(&str_map), info); } + +void *load_tiles(void *data) +{ + t_info *info; + t_vector *str_map; + + info = (t_info *)data; + str_map = load_vector(&info->map); + if (!str_map) + return (sv_errno(info, ERROR_MALLOC), NULL); + return (load_tiles_norm(info, str_map)); +} diff --git a/parsing/set_player.c b/parsing/set_player.c new file mode 100644 index 0000000..a53b0a2 --- /dev/null +++ b/parsing/set_player.c @@ -0,0 +1,67 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* set_player.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: bgoulard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/12/20 17:05:46 by bgoulard #+# #+# */ +/* Updated: 2024/12/20 17:09:59 by bgoulard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "cub3d.h" +#include "ft_vector.h" +#include "ft_string.h" +#include "ft_addons.h" + +#define EPMP ERROR_PARSE_MULTIPLE_PLAYER + +static bool multiple_player_same_line(const char *str) +{ + const char *identifiers = "NEWS"; + int i; + int j; + + i = 0; + while (i < 4) + { + if (ft_strchr(str, identifiers[i]) != ft_strrchr(str, identifiers[i])) + return (true); + j = i + 1; + while (j < 4) + if (ft_strchr(str, identifiers[j++]) && \ + ft_strchr(str, identifiers[i])) + return (true); + i++; + } + return (false); +} + +int set_player(t_info *info, int i, t_vector *str_map) +{ + t_dpoint pos; + char *str; + + ft_bzero(&pos, sizeof(t_dpoint)); + if (info->player.pos.x != 0 || info->player.pos.y != 0 || i == 0 || \ + multiple_player_same_line(ft_vec_at(str_map, i))) + return (ft_vec_destroy(&str_map), sv_errno(info, EPMP), EXIT_FAILURE); + str = ft_strchrs(ft_vec_at(str_map, i), "SNWE"); + pos.y = i + .5; + pos.x = str - (char *)ft_vec_at(str_map, i) + .5; + info->player.dir = (t_dpoint){.x = 0, 0}; + info->player.pos = pos; + info->player.pos_i = (t_ipoint){.x = (int)pos.x, .y = (int)pos.y}; + if (*str == 'N') + info->player.dir.y = -1; + else if (*str == 'S') + info->player.dir.y = 1; + else if (*str == 'W') + info->player.dir.x = -1; + else if (*str == 'E') + info->player.dir.x = 1; + info->player.plane = (t_dpoint){.x = info->player.dir.y, \ + .y = -info->player.dir.x}; + return (EXIT_SUCCESS); +} diff --git a/sources/error.c b/sources/error.c index dab3d02..f8fd685 100644 --- a/sources/error.c +++ b/sources/error.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */ -/* Updated: 2024/12/20 15:52:43 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 17:02:37 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,6 +42,7 @@ const char **get_error_message(void) err_msg[ERROR_PARSE_NO_BG_COLOR] = "no background color provided"; err_msg[ERROR_PARSE_META_IN_MAP] = "meta data in map (should be above)"; err_msg[ERROR_PARSE_MULTIPLE_PLAYER] = "multiple player in map"; + err_msg[ERROR_NO_PLAYER] = "no player in map"; return (err_msg); } From 473e9df5d469af1ef101024d6f2b9ae2ec6e0027 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 5 May 2025 16:11:41 +0200 Subject: [PATCH 07/10] build(nix): adding the flake for nix --- .envrc | 1 + flake.lock | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 ++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..74fa71f --- /dev/null +++ b/flake.lock @@ -0,0 +1,143 @@ +{ + "nodes": { + "c_formatter_42": { + "inputs": { + "c_formatter_42_src": "c_formatter_42_src", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1746356146, + "narHash": "sha256-4nLSqyoQOCSgqdJzxaUnjNY/b3IIqKmHGxPv4SQuAHw=", + "owner": "maix0", + "repo": "c_formatter_42-flake", + "rev": "f19ed7a6c447e0b38592a3fcd0082a17c84b4b2d", + "type": "github" + }, + "original": { + "owner": "maix0", + "repo": "c_formatter_42-flake", + "type": "github" + } + }, + "c_formatter_42_src": { + "flake": false, + "locked": { + "lastModified": 1733560990, + "narHash": "sha256-+9c8Ljz/x2Q6TNzR/mVgVAAIYUGSlXxnEUm2296NwpM=", + "owner": "dawnbeen", + "repo": "c_formatter_42", + "rev": "410326ffc7862e290d8d1c7f63a987c88e6fe05a", + "type": "github" + }, + "original": { + "owner": "dawnbeen", + "repo": "c_formatter_42", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-fusHbZCyv126cyArUwwKrLdCkgVAIaa/fQJYFlCEqiU=", + "path": "/nix/store/isfbldda5j8j6x3nbv1zim0c0dpf90v8-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1746328495, + "narHash": "sha256-uKCfuDs7ZM3QpCE/jnfubTg459CnKnJG/LwqEVEdEiw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "979daf34c8cacebcd917d540070b52a3c2b9b16e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "c_formatter_42": "c_formatter_42", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..044c71e --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + description = "Flake utils demo"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + c_formatter_42.url = "github:maix0/c_formatter_42-flake"; + }; + outputs = { + self, + nixpkgs, + flake-utils, + c_formatter_42, + }: + flake-utils.lib.eachDefaultSystem ( + system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + devShell = pkgs.mkShell { + packages = [ + pkgs.xorg.libX11 + pkgs.xorg.libXext + pkgs.clang + pkgs.clang-tools + pkgs.norminette + c_formatter_42.packages.${system}.default + ]; + }; + } + ); +} From 669ab480e0ec7153f7b3b0950396c3e432a5f328 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 5 May 2025 16:27:09 +0200 Subject: [PATCH 08/10] build(nix): updating the flake for nix build propose --- flake.nix | 71 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/flake.nix b/flake.nix index 044c71e..6617683 100644 --- a/flake.nix +++ b/flake.nix @@ -1,31 +1,46 @@ { - description = "Flake utils demo"; + description = "Shell for 42 cpp"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - c_formatter_42.url = "github:maix0/c_formatter_42-flake"; - }; - outputs = { - self, - nixpkgs, - flake-utils, - c_formatter_42, - }: - flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = nixpkgs.legacyPackages.${system}; - in { - devShell = pkgs.mkShell { - packages = [ - pkgs.xorg.libX11 - pkgs.xorg.libXext - pkgs.clang - pkgs.clang-tools - pkgs.norminette - c_formatter_42.packages.${system}.default - ]; - }; - } - ); + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + c_formatter_42.url = "github:maix0/c_formatter_42-flake"; + }; + outputs = { + self, + nixpkgs, + flake-utils, + c_formatter_42 + }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + in { + devShells.default = pkgs.mkShell { + name = "cpp-42"; + buildInputs = with pkgs; [ + c_formatter_42.packages.${system}.default + clang + clang-tools + norminette + xorg.libX11 + xorg.libXext + ] ++ ( + if pkgs.stdenv.isLinux then [ + valgrind + ] else [] + ); + + shellHook = '' + export NIX_SHOW_STATS=0 + export NIX_HIDE_STATS=1 + export C=clang + export CFLAGS="-std=c89 -Wall -Werror -Wextra" + printf "\n\033[0;90mC w/MLX env loaded for: \033[38;5;220m${system}\033[0m\n" + ''; + }; + } + ); } From a0791f9c01648060b4b3c829ff87e0b7f6eebdfc Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 5 May 2025 16:28:23 +0200 Subject: [PATCH 09/10] style(nix): removing flake.lock --- .gitignore | 1 + flake.lock | 143 ----------------------------------------------------- 2 files changed, 1 insertion(+), 143 deletions(-) delete mode 100644 flake.lock diff --git a/.gitignore b/.gitignore index b7398df..8944651 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ Cub3D* build/ .clangd .clang* +*.lock to_do* .cache/ diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 74fa71f..0000000 --- a/flake.lock +++ /dev/null @@ -1,143 +0,0 @@ -{ - "nodes": { - "c_formatter_42": { - "inputs": { - "c_formatter_42_src": "c_formatter_42_src", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1746356146, - "narHash": "sha256-4nLSqyoQOCSgqdJzxaUnjNY/b3IIqKmHGxPv4SQuAHw=", - "owner": "maix0", - "repo": "c_formatter_42-flake", - "rev": "f19ed7a6c447e0b38592a3fcd0082a17c84b4b2d", - "type": "github" - }, - "original": { - "owner": "maix0", - "repo": "c_formatter_42-flake", - "type": "github" - } - }, - "c_formatter_42_src": { - "flake": false, - "locked": { - "lastModified": 1733560990, - "narHash": "sha256-+9c8Ljz/x2Q6TNzR/mVgVAAIYUGSlXxnEUm2296NwpM=", - "owner": "dawnbeen", - "repo": "c_formatter_42", - "rev": "410326ffc7862e290d8d1c7f63a987c88e6fe05a", - "type": "github" - }, - "original": { - "owner": "dawnbeen", - "repo": "c_formatter_42", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 0, - "narHash": "sha256-fusHbZCyv126cyArUwwKrLdCkgVAIaa/fQJYFlCEqiU=", - "path": "/nix/store/isfbldda5j8j6x3nbv1zim0c0dpf90v8-source", - "type": "path" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1746328495, - "narHash": "sha256-uKCfuDs7ZM3QpCE/jnfubTg459CnKnJG/LwqEVEdEiw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "979daf34c8cacebcd917d540070b52a3c2b9b16e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "c_formatter_42": "c_formatter_42", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} From 7714465d62c39b86500ebce27dbf33ab62aa5540 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 5 May 2025 16:29:01 +0200 Subject: [PATCH 10/10] style(ignore): removing flake.lock to tracked files --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8944651..e748d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ Cub3D* build/ .clangd .clang* -*.lock +flake.lock to_do* .cache/