From c120ee5a5f5ffaa747a4a9138b334a509d2aca34 Mon Sep 17 00:00:00 2001 From: Baptiste Goulard coderc de lacam Date: Fri, 20 Dec 2024 15:04:48 +0100 Subject: [PATCH] Fix: fix hole detection, fix norme mlx_struct.h + load_texture.c + error.c --- Makefile | 1 - includes/cub3d_struct.h | 3 +- includes/mlx_structs.h | 4 +-- maps/bad_open_map.cub | 5 +++- parsing/blank_for_raph.c | 61 ---------------------------------------- parsing/load_textures.c | 4 +-- parsing/load_tiles.c | 4 +-- parsing/traverse_map.c | 4 ++- sources/error.c | 5 ++-- 9 files changed, 17 insertions(+), 74 deletions(-) delete mode 100644 parsing/blank_for_raph.c diff --git a/Makefile b/Makefile index da9338b..8e8bb3c 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,6 @@ SRC =\ parsing/load_file.c \ parsing/utils.c \ parsing/map.c \ - parsing/blank_for_raph.c \ parsing/arguments.c \ parsing/load_tiles.c diff --git a/includes/cub3d_struct.h b/includes/cub3d_struct.h index 0de80e4..bd936d0 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/19 22:29:11 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 14:47:00 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -72,6 +72,7 @@ typedef enum e_tile { EMPTY = 0, WALL = 1, + NONE = 2 } t_tile_type; /* diff --git a/includes/mlx_structs.h b/includes/mlx_structs.h index 56abc25..1c510c6 100644 --- a/includes/mlx_structs.h +++ b/includes/mlx_structs.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/10 05:33:08 by bgoulard #+# #+# */ -/* Updated: 2024/11/20 15:13:32 by rparodi ### ########.fr */ +/* Updated: 2024/12/20 15:01:06 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ # define MLX_TYPE_SHM 2 # define MLX_TYPE_XIMAGE 1 -# define MLX_MAX_EVENT LASTEvent +# define MLX_MAX_EVENT 36 # define ENV_DISPLAY "DISPLAY" # define LOCALHOST "localhost" diff --git a/maps/bad_open_map.cub b/maps/bad_open_map.cub index 5a6c30e..8c4fd0d 100644 --- a/maps/bad_open_map.cub +++ b/maps/bad_open_map.cub @@ -20,4 +20,7 @@ C 0,255,255 10111111 11000101 10000011111110000001 100000000000000N0001 -11111111111111111111 +101 +10000000000000000001 +10111111111111111111 +111111 diff --git a/parsing/blank_for_raph.c b/parsing/blank_for_raph.c deleted file mode 100644 index 111c69d..0000000 --- a/parsing/blank_for_raph.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* blank_for_raph.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/11/13 06:44:42 by bgoulard #+# #+# */ -/* Updated: 2024/12/01 18:51:20 by rparodi ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "cub3d_struct.h" - -#include "ft_string.h" -#include - -static t_tile char_to_tile(char c) -{ - t_tile tile; - - ft_bzero(&tile, sizeof(t_tile)); - if (c == '1' || c == ' ') - return ((tile.tile_type = WALL, tile)); - return ((tile.tile_type = EMPTY, tile)); -} - -/// @brief Createsa a blank map for rapahael to test the raycasting -/// @param info The structure containing the information about the game -/// @return void -/// @note based on map: -/// 11111 -/// 10001 -/// 10S01 -/// 10001 -/// 10111 -/// 111 -/// @note The blank does not fill in the textures. -void blank(t_info *info) -{ - int i; - - i = 0; - info->map.size.x = 5; - info->map.size.y = 6; - info->map.fraw = malloc(sizeof(char *) * 6); - info->map.fraw[0] = ft_strdup("11111"); - info->map.fraw[1] = ft_strdup("10001"); - info->map.fraw[2] = ft_strdup("10S01"); - info->map.fraw[3] = ft_strdup("10001"); - info->map.fraw[4] = ft_strdup("10111"); - info->map.fraw[5] = ft_strdup("11111"); - info->map.map = ft_calloc(sizeof(t_tile), \ - (info->map.size.y * info->map.size.x)); - while (i < info->map.size.y * info->map.size.x) - { - info->map.map[i] = char_to_tile (\ - info->map.fraw[i / info->map.size.x][i % info->map.size.x]); - i++; - } -} diff --git a/parsing/load_textures.c b/parsing/load_textures.c index dca5ace..c020e24 100644 --- a/parsing/load_textures.c +++ b/parsing/load_textures.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/01 17:46:52 by bgoulard #+# #+# */ -/* Updated: 2024/12/20 13:24:17 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 14:47:18 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ #include #include -static bool no_leaks(t_info *inf, t_texture *texture, enum e_error error) +static bool no_leaks(t_info *inf, t_texture *texture, enum e_error error) { if (texture->img != NULL) mlx_destroy_image(inf->mlx_ptr, texture->img); diff --git a/parsing/load_tiles.c b/parsing/load_tiles.c index 418692c..555e4ad 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/19 22:32:16 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 14:46:40 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,7 +47,7 @@ int str_to_tile(const char *str, t_tile *tile, size_t size) i++; } while (i < size) - tile[i++].tile_type = WALL; + tile[i++].tile_type = NONE; return (0); } diff --git a/parsing/traverse_map.c b/parsing/traverse_map.c index d61ecf7..8444880 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/16 09:45:25 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 14:49:43 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,6 +33,8 @@ 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) + return (false); current->tile_visited = true; i = 0; while (i != (sizeof(to_check) / sizeof(to_check[0]))) diff --git a/sources/error.c b/sources/error.c index 6e5cc21..65ba971 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/19 22:29:32 by bgoulard ### ########.fr */ +/* Updated: 2024/12/20 14:43:52 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ const char **get_error_message(void) { - static const char *err_msg[ERROR_IMPLEM + 1] = { NULL }; + static const char *err_msg[ERROR_IMPLEM + 1] = {NULL}; err_msg[NO_ERROR] = "no error"; err_msg[ERROR_UNKNOWN] = "unknown error"; @@ -41,7 +41,6 @@ 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)"; - return (err_msg); }