From 7d67dfd45289165ab211217e65ee65936b613127 Mon Sep 17 00:00:00 2001 From: Ladebeze66 Date: Mon, 29 Jan 2024 20:26:06 +0100 Subject: [PATCH] manqueunefonctionnorme --- Makefile | 12 +- cub3d.h | 275 +++++++++++++++------------ draw/ft_2d_view.c | 32 ++-- draw/ft_3d_view.c | 143 +++++--------- draw/ft_3d_view_utils.c | 93 ++++++++++ draw/ft_background.c | 30 +-- draw/ft_draw.c | 8 +- draw/ft_horizontal_ray.c | 55 +++--- draw/ft_load_textures.c | 3 +- draw/ft_textures.c | 44 ++--- draw/ft_vertical_ray.c | 56 +++--- include/mlx.h | 168 ++++------------- libft/Makefile | 102 ---------- libft/ft_atoi.c | 38 ---- libft/ft_atoi.o | Bin 1480 -> 0 bytes libft/ft_bzero.c | 25 --- libft/ft_bzero.o | Bin 1272 -> 0 bytes libft/ft_calloc.c | 28 --- libft/ft_calloc.o | Bin 1568 -> 0 bytes libft/ft_isalnum.c | 21 --- libft/ft_isalnum.o | Bin 1288 -> 0 bytes libft/ft_isalpha.c | 21 --- libft/ft_isalpha.o | Bin 1272 -> 0 bytes libft/ft_isascii.c | 20 -- libft/ft_isascii.o | Bin 1264 -> 0 bytes libft/ft_isdigit.c | 21 --- libft/ft_isdigit.o | Bin 1264 -> 0 bytes libft/ft_isprint.c | 20 -- libft/ft_isprint.o | Bin 1264 -> 0 bytes libft/ft_itoa.c | 56 ------ libft/ft_itoa.o | Bin 1784 -> 0 bytes libft/ft_lstadd_back.c | 29 --- libft/ft_lstadd_front.c | 22 --- libft/ft_lstclear.c | 25 --- libft/ft_lstdelone.c | 21 --- libft/ft_lstiter.c | 24 --- libft/ft_lstlast.c | 24 --- libft/ft_lstmap.c | 35 ---- libft/ft_lstnew.c | 25 --- libft/ft_lstsize.c | 28 --- libft/ft_memchr.c | 27 --- libft/ft_memchr.o | Bin 1304 -> 0 bytes libft/ft_memcmp.c | 27 --- libft/ft_memcmp.o | Bin 1336 -> 0 bytes libft/ft_memcpy.c | 32 ---- libft/ft_memcpy.o | Bin 1328 -> 0 bytes libft/ft_memmove.c | 42 ----- libft/ft_memmove.o | Bin 1408 -> 0 bytes libft/ft_memset.c | 26 --- libft/ft_memset.o | Bin 1280 -> 0 bytes libft/ft_putchar_fd.c | 18 -- libft/ft_putchar_fd.o | Bin 1400 -> 0 bytes libft/ft_putendl_fd.c | 28 --- libft/ft_putendl_fd.o | Bin 1616 -> 0 bytes libft/ft_putnbr_fd.c | 36 ---- libft/ft_putnbr_fd.o | Bin 1872 -> 0 bytes libft/ft_putstr_fd.c | 27 --- libft/ft_putstr_fd.o | Bin 1456 -> 0 bytes libft/ft_realloc.c | 35 ---- libft/ft_realloc.o | Bin 1608 -> 0 bytes libft/ft_reallocarray.c | 32 ---- libft/ft_reallocarray.o | Bin 1688 -> 0 bytes libft/ft_strcat.c | 32 ---- libft/ft_strcat.o | Bin 1304 -> 0 bytes libft/ft_strchr.c | 32 ---- libft/ft_strchr.o | Bin 1352 -> 0 bytes libft/ft_strcmp.c | 23 --- libft/ft_strcmp.o | Bin 1296 -> 0 bytes libft/ft_strcpy.c | 28 --- libft/ft_strcpy.o | Bin 1288 -> 0 bytes libft/ft_striteri.c | 25 --- libft/ft_striteri.o | Bin 1312 -> 0 bytes libft/ft_strlcat.c | 33 ---- libft/ft_strlcat.o | Bin 1616 -> 0 bytes libft/ft_strlcpy.c | 32 ---- libft/ft_strlcpy.o | Bin 1368 -> 0 bytes libft/ft_strmapi.c | 33 ---- libft/ft_strmapi.o | Bin 1592 -> 0 bytes libft/ft_strncmp.c | 29 --- libft/ft_strncmp.o | Bin 1392 -> 0 bytes libft/ft_strncpy.c | 31 ---- libft/ft_strncpy.o | Bin 1336 -> 0 bytes libft/ft_strnstr.c | 41 ---- libft/ft_strnstr.o | Bin 1496 -> 0 bytes libft/ft_strrchr.c | 29 --- libft/ft_strrchr.o | Bin 1328 -> 0 bytes libft/ft_strstr.c | 42 ----- libft/ft_strstr.o | Bin 1392 -> 0 bytes libft/ft_strtok.c | 83 --------- libft/ft_strtok.o | Bin 2296 -> 0 bytes libft/ft_strtol.c | 115 ------------ libft/ft_strtol.o | Bin 3008 -> 0 bytes libft/ft_strtrim.c | 52 ------ libft/ft_strtrim.o | Bin 1880 -> 0 bytes libft/ft_substr.c | 37 ---- libft/ft_substr.o | Bin 1520 -> 0 bytes libft/ft_tolower.c | 20 -- libft/ft_tolower.o | Bin 1256 -> 0 bytes libft/ft_toupper.c | 20 -- libft/ft_toupper.o | Bin 1256 -> 0 bytes libft/libft.a | Bin 61112 -> 0 bytes libft/libft.h | 82 -------- main.c | 7 +- map.cub | 2 +- move/ft_collision.c | 63 +++++-- move/ft_key.c | 29 +-- move/ft_move.c | 110 ++++++----- parsing/ft_find_map_start.c | 8 +- parsing/ft_find_player_position.c | 109 ++++------- parsing/ft_find_player_utils.c | 71 +++++++ parsing/ft_map_check.c | 298 ++++++++---------------------- parsing/ft_map_check_utils.c | 29 +++ parsing/ft_map_dimensions.c | 28 +-- parsing/ft_parsing.c | 28 +-- parsing/ft_read_map.c | 97 ---------- parsing/ft_text_and_col_utils.c | 91 +++++++++ parsing/ft_textures_and_colors.c | 149 ++++----------- window/ft_map.c | 12 +- window/ft_player.c | 41 ++-- window/ft_refresh_window.c | 22 +-- window/ft_window.c | 11 +- 121 files changed, 998 insertions(+), 2860 deletions(-) create mode 100644 draw/ft_3d_view_utils.c delete mode 100644 libft/Makefile delete mode 100644 libft/ft_atoi.c delete mode 100644 libft/ft_atoi.o delete mode 100644 libft/ft_bzero.c delete mode 100644 libft/ft_bzero.o delete mode 100644 libft/ft_calloc.c delete mode 100644 libft/ft_calloc.o delete mode 100644 libft/ft_isalnum.c delete mode 100644 libft/ft_isalnum.o delete mode 100644 libft/ft_isalpha.c delete mode 100644 libft/ft_isalpha.o delete mode 100644 libft/ft_isascii.c delete mode 100644 libft/ft_isascii.o delete mode 100644 libft/ft_isdigit.c delete mode 100644 libft/ft_isdigit.o delete mode 100644 libft/ft_isprint.c delete mode 100644 libft/ft_isprint.o delete mode 100644 libft/ft_itoa.c delete mode 100644 libft/ft_itoa.o delete mode 100644 libft/ft_lstadd_back.c delete mode 100644 libft/ft_lstadd_front.c delete mode 100644 libft/ft_lstclear.c delete mode 100644 libft/ft_lstdelone.c delete mode 100644 libft/ft_lstiter.c delete mode 100644 libft/ft_lstlast.c delete mode 100644 libft/ft_lstmap.c delete mode 100644 libft/ft_lstnew.c delete mode 100644 libft/ft_lstsize.c delete mode 100644 libft/ft_memchr.c delete mode 100644 libft/ft_memchr.o delete mode 100644 libft/ft_memcmp.c delete mode 100644 libft/ft_memcmp.o delete mode 100644 libft/ft_memcpy.c delete mode 100644 libft/ft_memcpy.o delete mode 100644 libft/ft_memmove.c delete mode 100644 libft/ft_memmove.o delete mode 100644 libft/ft_memset.c delete mode 100644 libft/ft_memset.o delete mode 100644 libft/ft_putchar_fd.c delete mode 100644 libft/ft_putchar_fd.o delete mode 100644 libft/ft_putendl_fd.c delete mode 100644 libft/ft_putendl_fd.o delete mode 100644 libft/ft_putnbr_fd.c delete mode 100644 libft/ft_putnbr_fd.o delete mode 100644 libft/ft_putstr_fd.c delete mode 100644 libft/ft_putstr_fd.o delete mode 100644 libft/ft_realloc.c delete mode 100644 libft/ft_realloc.o delete mode 100644 libft/ft_reallocarray.c delete mode 100644 libft/ft_reallocarray.o delete mode 100644 libft/ft_strcat.c delete mode 100644 libft/ft_strcat.o delete mode 100644 libft/ft_strchr.c delete mode 100644 libft/ft_strchr.o delete mode 100644 libft/ft_strcmp.c delete mode 100644 libft/ft_strcmp.o delete mode 100644 libft/ft_strcpy.c delete mode 100644 libft/ft_strcpy.o delete mode 100644 libft/ft_striteri.c delete mode 100644 libft/ft_striteri.o delete mode 100644 libft/ft_strlcat.c delete mode 100644 libft/ft_strlcat.o delete mode 100644 libft/ft_strlcpy.c delete mode 100644 libft/ft_strlcpy.o delete mode 100644 libft/ft_strmapi.c delete mode 100644 libft/ft_strmapi.o delete mode 100644 libft/ft_strncmp.c delete mode 100644 libft/ft_strncmp.o delete mode 100644 libft/ft_strncpy.c delete mode 100644 libft/ft_strncpy.o delete mode 100644 libft/ft_strnstr.c delete mode 100644 libft/ft_strnstr.o delete mode 100644 libft/ft_strrchr.c delete mode 100644 libft/ft_strrchr.o delete mode 100644 libft/ft_strstr.c delete mode 100644 libft/ft_strstr.o delete mode 100644 libft/ft_strtok.c delete mode 100644 libft/ft_strtok.o delete mode 100644 libft/ft_strtol.c delete mode 100644 libft/ft_strtol.o delete mode 100644 libft/ft_strtrim.c delete mode 100644 libft/ft_strtrim.o delete mode 100644 libft/ft_substr.c delete mode 100644 libft/ft_substr.o delete mode 100644 libft/ft_tolower.c delete mode 100644 libft/ft_tolower.o delete mode 100644 libft/ft_toupper.c delete mode 100644 libft/ft_toupper.o delete mode 100644 libft/libft.a delete mode 100644 libft/libft.h create mode 100644 parsing/ft_find_player_utils.c create mode 100644 parsing/ft_map_check_utils.c delete mode 100644 parsing/ft_read_map.c create mode 100644 parsing/ft_text_and_col_utils.c diff --git a/Makefile b/Makefile index 0463881..a90e203 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: fgras-ca +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/01/14 16:54:48 by fgras-ca #+# #+# # -# Updated: 2024/01/23 19:56:56 by fgras-ca ### ########.fr # +# Updated: 2024/01/29 20:12:12 by fgras-ca ### ########.fr # # # # **************************************************************************** # @@ -24,7 +24,6 @@ WHITE = \033[0;97m ORANGE = \033[38;5;214m NAME = cub3d -LIBFT = libft.a SRC = main.c \ ./utils/ft_utils_gnl.c \ @@ -32,7 +31,6 @@ SRC = main.c \ ./utils/ft_utils_convert.c \ ./utils/ft_utils_str_1.c \ ./parsing/ft_map_check.c \ - ./parsing/ft_read_map.c \ ./parsing/ft_map_dimensions.c \ ./parsing/ft_parsing.c \ ./move/ft_collision.c \ @@ -43,6 +41,7 @@ SRC = main.c \ ./draw/ft_2d_view.c \ ./draw/ft_textures.c \ ./draw/ft_3d_view.c \ + ./draw/ft_3d_view_utils.c \ ./draw/ft_horizontal_ray.c \ ./draw/ft_vertical_ray.c \ ./draw/ft_pixel.c \ @@ -56,10 +55,9 @@ SRC = main.c \ ./parsing/ft_find_map_start.c \ ./parsing/ft_textures_and_colors.c \ ./parsing/ft_find_player_position.c \ - -SRC_DIR_LIBFT = libft/ - -SRC_LIBFT = $(addprefix $(SRC_DIR_LIBFT), $(LIBFT)) + ./parsing/ft_find_player_utils.c \ + ./parsing/ft_map_check_utils.c \ + ./parsing/ft_text_and_col_utils.c \ OBJ = $(SRC:.c=.o) diff --git a/cub3d.h b/cub3d.h index b308b4a..574e70f 100644 --- a/cub3d.h +++ b/cub3d.h @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 16:56:52 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 22:03:37 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 20:09:43 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,29 +24,30 @@ # include "include/mlx.h" # ifndef BUFFER_SIZE -# define BUFFER_SIZE 100000 +# define BUFFER_SIZE 100000 # endif # define PI 3.14159265359 -# define P2 PI/2 -# define P3 3*PI/2 +# define P2 1.57079632679 +# define P3 4.71238898038 # define COLBUF 1 # define NUMRAY 1280 # define FOVIEW 60 # define DISRAY 1000000 # define DOF 120 -# define WIDTH 1780 +# define WIDTH 1680 # define HEIGHT 720 -# define BOV 500 +# define BOV 400 # define MAX_LINE_LENGTH 100000 +# define DX_LENGTH 8 -typedef enum { +typedef enum s_WallDirection { NORTH, SOUTH, WEST, EAST, - NONE // Utilisé lorsqu'aucun mur n'est touché -} WallDirection; + NONE +} t_WallDirection; typedef struct s_img { @@ -108,15 +109,15 @@ typedef struct s_struture_windows typedef struct s_texture { - char *north; - char *south; - char *west; - char *east; + char *north; + char *south; + char *west; + char *east; char *door; char *door_open; - unsigned int floor_color; - unsigned int ceil_color; -} t_texture; + unsigned int floor_color; + unsigned int ceil_color; +} t_texture; typedef struct s_struture_map { @@ -126,9 +127,9 @@ typedef struct s_struture_map int i; int j; int temp; - int mapX; - int mapY; - int mapS; + int map_x; + int map_y; + int map_s; float player_x; float player_y; char player_direction; @@ -136,10 +137,14 @@ typedef struct s_struture_map } t_structure_map; typedef struct s_sprite { - void *frames[3]; // Tableau pour stocker les frames du sprite - int width, height; // Dimensions du sprite - int current_frame; // Index de la frame actuelle -} t_sprite; + void *frames[3]; + int width; + int height; + int current_frame; + float world_x; + float world_y; + float distance; +} t_sprite; typedef struct s_structure_main { @@ -166,7 +171,7 @@ typedef struct s_res_params { int original_y; int pixel_pos_rescaled; int pixel_pos_original; -} t_res_params; +} t_res_params; typedef struct s_rescale_params { void *original_img; @@ -177,30 +182,29 @@ typedef struct s_rescale_params { int px; int py; t_res_params *res; -} t_rescale_params; +} t_rescale_params; typedef struct s_position_params { int *future_px; int *future_py; int pdx; int pdy; - int collisionBuffer; + int collision_buffer; int px; int py; double pa; char direction; -} t_position_params; - +} t_position_params; typedef struct s_map_params { t_structure_map *map_info; const char *buffer; int length; - int *maxWidth; + int *max_width; int *height; - int *currentWidth; - int *isNewLine; -} t_map_params; + int *current_width; + int *is_new_line; +} t_map_params; typedef struct s_square_params { t_structure_main *w; @@ -209,15 +213,15 @@ typedef struct s_square_params { int xo; int yo; int color; -} t_square_params; +} t_square_params; typedef struct s_sky_ground_params { t_structure_main *w; - int startHeight; - int endHeight; + int start_height; + int end_height; int color; - int backgroundOffsetX; -} t_sky_ground_params; + int background_off_setx; +} t_sky_ground_params; typedef struct s_line_params { t_structure_main *w; @@ -226,7 +230,7 @@ typedef struct s_line_params { int x1; int y1; int color; -} t_line_params; +} t_line_params; typedef struct s_line_deltas { int dx; @@ -235,53 +239,51 @@ typedef struct s_line_deltas { int sy; int err; t_line_params *params; -} t_line_deltas; - - +} t_line_deltas; typedef struct s_texture_params { t_structure_main *w; - int startX; - int endX; - float lineOff; - float lineH; - WallDirection wallDir; + int start_x; + int end_x; + float line_off; + float line_h; + t_WallDirection wall_dir; float rx; float ry; - float disT; -} t_texture_params; + float dis_t; +} t_texture_params; typedef struct s_ray_params { t_structure_main *w; t_square_params sq; t_texture_params texture; int r; - int tileSize; + int tile_size; float rx; float ry; - float disT; - WallDirection wallDir; - int numRays; + float dis_t; + t_WallDirection wall_dir; + int num_rays; int color; - int start3DHeight; - int max3DHeight; - float lineH; - float lineOff; - int backgroundOffsetX; + int start3d_height; + int max3d_height; + float line_h; + float line_off; + int background_off_setx; int raywidth; -} t_ray_params; +} t_ray_params; typedef struct s_ray_calc_params { t_structure_main *w; float ra; - float *disRay; + float *dis_ray; float *rx; float *ry; - WallDirection *wallDir; + t_WallDirection *wall_dir; float xo; float yo; int dof; -} t_ray_calc_params; +} t_ray_calc_params; typedef struct s_texture_data { @@ -295,71 +297,109 @@ typedef struct s_init_params { t_structure_main *w; int tilesize; int numrays; - float FOV; - float DR; -} t_init_params; + float fo_v; + float d_r; +} t_init_params; typedef struct s_ray_properties { - float disH; - float disV; - WallDirection hwalldir; - WallDirection vwalldir; + float dis_h; + float dis_v; + t_WallDirection hwalldir; + t_WallDirection vwalldir; float hx; float hy; float vx; float vy; -} t_ray_properties; +} t_ray_properties; -typedef struct { +typedef struct s_base_params { int tilesize; int numrays; - float FOV; - float DR; + float fo_v; + float d_r; float ra; -} t_base_params; +} t_base_params; -typedef struct { - float disH; - float disV; - float disT; +typedef struct s_ray_state { + float dis_h; + float dis_v; + float dis_t; float hx; float hy; float vx; float vy; - WallDirection hwalldir; - WallDirection vwalldir; -} t_ray_state; + t_WallDirection hwalldir; + t_WallDirection vwalldir; +} t_ray_state; -typedef struct { +typedef struct s_ray_calc { t_structure_main *w; int r; int color; -} t_ray_calc; +} t_ray_calc; -typedef struct { +typedef struct s_drawrays2d_params { t_base_params base_params; t_ray_state ray_state; t_ray_calc ray_calc; t_ray_params rayparams; t_ray_calc_params hrayparams; t_ray_calc_params vrayparams; -} t_drawrays2d_params; +} t_drawrays2d_params; -typedef struct { - int jkl; - int yui; -} t_state; +typedef struct s_state { + int jkl; + int yui; +} t_state; -typedef struct { - t_structure_main *w; - t_state state; -} t_global_struct; +typedef struct s_global_struct { + t_structure_main *w; + t_state state; +} t_global_struct; + +typedef struct s_draw_params +{ + int texturewidth; + int textureheight; + int texturex; + int textureY; + int a; + int b; + int c; + double step; + int x; + int i; +} t_draw_params; + +typedef struct s_collision_params +{ + int dx[DX_LENGTH]; + int dy[DX_LENGTH]; +} t_collision_params; + +typedef struct s_player_info +{ + bool *found_player; + t_structure_map *map; + int line_number; + int column_number; +} t_player_info; + +typedef struct s_point +{ + int x; + int y; +} t_point; + +typedef struct s_map_check +{ + char *map; + int maxWidth; + int height; +} t_map_check; -//ft_utils_split.c 5 / 5 char **ft_split(char const *s, char c); -//ft_utils_gnl.c 4 / 5 char *get_next_line(int fd); -/*ft_key.c 3/5*/ int *kill_prog(t_structure_main *w); void move(int key, t_structure_main *w); int deal_key(int key, t_structure_main *w); @@ -371,13 +411,12 @@ int ft_strncmp(const char *s1, const char *s2, size_t n); int ft_strcmp(const char *s1, const char *s2); void *ft_memcpy(void *dest, const void *src, size_t n); void *ft_memset(void *s, int c, size_t n); -/*collision*/ -int can_move_to(t_structure_main *w, double future_x, double future_y); +int can_move_to(t_structure_main *w, double future_x, double future_y); char *ft_itoa(int nb); void draw_black_ground(t_ray_params *params, t_texture_params tparams); -/*parsing*/ -int is_map_closed(char* map, int width, int height); -bool parse_map(const char *map_content, int length, t_structure_map *map_info); +int is_map_closed(char *map, int width, int height); +bool parse_map(const char *map_content, + int length, t_structure_map *map_info); int check_borders(char *map, int maxWidth, int height); int check_interior(char *map, int maxWidth, int height); void exit_error(t_structure_main *w); @@ -386,24 +425,25 @@ void process_character(t_map_params *params, int *i); void get_map_dimensions(t_map_params *params); void fill_map_space(t_structure_map *map_info, int maxWidth, int height); void copy_map_data(t_map_params *params); -bool load_cub_file(const char *filename, t_texture *textures, t_structure_map *map_info); +bool load_cub_file(const char *filename, + t_texture *textures, t_structure_map *map_info); bool parse_texture_line(const char *line, t_texture *textures); bool handle_map(int fd, char **map_buffer, int *map_length); bool parse_color_line(const char *line, unsigned int *color); +bool parse_number_from_str(const char **str, int *number); bool is_valid_texture(const char *line); bool handle_textures(int fd, t_texture *textures); -bool find_player_position_and_direction(const char *map_content, int length, t_structure_map *map_info); +bool find_player(const char *map_content, + int length, t_structure_map *map); void calculate_map(t_structure_map *map_info); -/*textures*/ void load_wall_textures(t_structure_main *w); void draw_texture(t_texture_params *tex_params); -int get_texture_color(t_structure_main *w, WallDirection wallDir, int textureX, int textureY); -void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca); -/*3D view*/ +int get_texture_color(t_structure_main *w, + t_WallDirection wallDir, int textureX, int textureY); +void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca); void drawray(t_ray_params *ray_params); void draw_background(t_structure_main *w); float correctFisheye(float distance, float ra, float playerAngle); -//2D map void rescale_image(t_rescale_params *params, t_structure_main *w); void draw_square(t_structure_main *w, int x, int y, int color); void draw_map(t_structure_main *w); @@ -411,20 +451,27 @@ void put_pixel_img(t_structure_main *w, int x, int y, int color); void draw_square_raw(t_square_params *params); void draw_line(t_line_params *params); void drawrays2d(t_structure_main *w); -//Ray void calculateverticalray(t_ray_calc_params *params); void handle_ra_vertical(t_ray_calc_params *params, float nTan, int tileSize); void calculatehorizontalray(t_ray_calc_params *params); -void handle_ra_not_equal_pi(t_ray_calc_params *params, float atan, int tilesize); +void handle_ra_not_equal_pi(t_ray_calc_params *params, + float atan, int tilesize); float dist(float ax, float ay, float bx, float by); -//window void init_windows(t_structure_main *w); void init_player(t_structure_main *w); void init_mlx_and_window(t_structure_main *w); void sleep_mouse(t_global_struct *global_struct); -//sprite -void load_sprite_frames(t_sprite *sprite, void *mlx_ptr); -void update_sprite_frame(t_sprite *sprite); -void draw_sprite(t_sprite *sprite, void *mlx_ptr, void *win_ptr, int win_width, int win_height); +void init_line_params(t_line_params *lineparams, t_ray_params *rayParams); +void init_texture_params(t_texture_params *textureparams, + t_ray_params *rayParams); +void initialize_variables(int *i, int *line_number, + int *column_number, bool *found_player); +bool check_for_player(char current_char, bool *found_player); +void update_player_info(t_structure_map *map_info, + int line_number, int column_number, char player_direction); +void update_position(char current_char, int *line_number, int *column_number); +bool check_for_multiple_players(bool found_player); +int check_boundaries(t_point p, t_map_check *map_check); +int is_space_surrounded_by_walls(t_map_check *map_check, t_point p); #endif diff --git a/draw/ft_2d_view.c b/draw/ft_2d_view.c index 58f825b..dc37893 100644 --- a/draw/ft_2d_view.c +++ b/draw/ft_2d_view.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 17:49:42 by fgras-ca #+# #+# */ -/* Updated: 2024/01/23 17:43:56 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 16:20:39 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,39 +26,39 @@ float correctfisheye(float distance, float ra, float playerAngle) void init_base_params(t_base_params *params, t_structure_main *w) { - params->tilesize = w->s_map.mapS; + params->tilesize = w->s_map.map_s; params->numrays = NUMRAY; - params->FOV = FOVIEW * (PI / 180); - params->DR = params->FOV / params->numrays; - params->ra = w->s_player.pa - (params->FOV / 2); + params->fo_v = FOVIEW * (PI / 180); + params->d_r = params->fo_v / params->numrays; + params->ra = w->s_player.pa - (params->fo_v / 2); draw_background(w); } void calculate_ray(t_base_params *base, t_ray_state *state, t_ray_calc *calc, t_ray_params *rayparams) { - if (state->disH < state->disV) + if (state->dis_h < state->dis_v) { - rayparams->disT = state->disH; + rayparams->dis_t = state->dis_h; calc->color = 0xFF0000; - rayparams->wallDir = state->hwalldir; + rayparams->wall_dir = state->hwalldir; rayparams->rx = state->hx; rayparams->ry = state->hy; } else { - rayparams->disT = state->disV; + rayparams->dis_t = state->dis_v; calc->color = 0x00FF00; - rayparams->wallDir = state->vwalldir; + rayparams->wall_dir = state->vwalldir; rayparams->rx = state->vx; rayparams->ry = state->vy; } - rayparams->disT = correctfisheye(rayparams->disT, + rayparams->dis_t = correctfisheye(rayparams->dis_t, base->ra, calc->w->s_player.pa); rayparams->w = calc->w; - rayparams->tileSize = base->tilesize; + rayparams->tile_size = base->tilesize; rayparams->r = calc->r; - rayparams->numRays = base->numrays; + rayparams->num_rays = base->numrays; rayparams->color = calc->color; } @@ -73,16 +73,16 @@ void drawrays2d(t_structure_main *w) { params.base_params.ra = fmod(params.base_params.ra + 2 * PI, 2 * PI); params.hrayparams = (t_ray_calc_params){w, params.base_params.ra, - ¶ms.ray_state.disH, ¶ms.ray_state.hx, + ¶ms.ray_state.dis_h, ¶ms.ray_state.hx, ¶ms.ray_state.hy, ¶ms.ray_state.hwalldir}; params.vrayparams = (t_ray_calc_params){w, params.base_params.ra, - ¶ms.ray_state.disV, ¶ms.ray_state.vx, + ¶ms.ray_state.dis_v, ¶ms.ray_state.vx, ¶ms.ray_state.vy, ¶ms.ray_state.vwalldir}; calculatehorizontalray(¶ms.hrayparams); calculateverticalray(¶ms.vrayparams); calculate_ray(¶ms.base_params, ¶ms.ray_state, ¶ms.ray_calc, ¶ms.rayparams); drawray(¶ms.rayparams); - params.base_params.ra += params.base_params.DR; + params.base_params.ra += params.base_params.d_r; } } diff --git a/draw/ft_3d_view.c b/draw/ft_3d_view.c index 108b878..3256678 100644 --- a/draw/ft_3d_view.c +++ b/draw/ft_3d_view.c @@ -6,32 +6,50 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 17:35:53 by fgras-ca #+# #+# */ -/* Updated: 2024/01/26 17:25:05 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:05:58 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../cub3d.h" -void init_line_params(t_line_params *lineparams, t_ray_params *rayParams) +static void calculate_line_height(t_ray_params *rayparams) { - lineparams->w = rayParams->w; - lineparams->x0 = (int)rayParams->w->s_player.px; - lineparams->y0 = (int)rayParams->w->s_player.py; - lineparams->x1 = (int)rayParams->rx; - lineparams->y1 = (int)rayParams->ry; - lineparams->color = rayParams->color; + rayparams->line_h = (rayparams->tile_size * rayparams->max3d_height) + / rayparams->dis_t; + if (rayparams->line_h > rayparams->max3d_height) + { + rayparams->line_h = rayparams->max3d_height; + } + rayparams->line_off = ((rayparams->max3d_height - rayparams->line_h) / 2); } -void init_texture_params(t_texture_params *textureparams, - t_ray_params *rayParams) +static void calculate_deca(t_ray_params *rayparams, float *olineh, int *deca) { - textureparams->w = rayParams->w; - textureparams->lineOff = rayParams->lineOff; - textureparams->lineH = rayParams->lineH; - textureparams->wallDir = rayParams->wallDir; - textureparams->rx = rayParams->rx + rayParams->backgroundOffsetX; - textureparams->ry = rayParams->ry; - textureparams->disT = rayParams->disT; + *olineh = (rayparams->w->s_map.map_s * rayparams->w->s_win.height) + / rayparams->dis_t; + if (*olineh > rayparams->w->s_win.height) + { + *deca = *olineh - rayparams->w->s_win.height; + } + else + { + *deca = 0; + } +} + +static void set_rayparams(t_ray_params *rayparams) +{ + rayparams->start3d_height = 0; + rayparams->max3d_height = rayparams->w->s_win.height + + rayparams->start3d_height; +} + +static void set_texture_params(t_ray_params *rayparams, + t_texture_params *textureparams) +{ + textureparams->start_x = rayparams->r * rayparams->raywidth + + rayparams->background_off_setx; + textureparams->end_x = textureparams->start_x + rayparams->raywidth; } void drawray(t_ray_params *rayparams) @@ -40,96 +58,23 @@ void drawray(t_ray_params *rayparams) t_texture_params textureparams; float olineh; int deca; - int color; - rayparams->start3DHeight = 0; - rayparams->max3DHeight = rayparams->w->s_win.height - + rayparams->start3DHeight; - rayparams->lineH = (rayparams->tileSize * rayparams->max3DHeight) - / rayparams->disT; - if (rayparams->lineH > rayparams->max3DHeight) - { - rayparams->lineH = rayparams->max3DHeight; - } - rayparams->lineOff = ((rayparams->max3DHeight - rayparams->lineH) / 2); - olineh = (rayparams->w->s_map.mapS * rayparams->w->s_win.height) / rayparams->disT; - rayparams->backgroundOffsetX = BOV; - rayparams->raywidth = rayparams->w->s_win.width / rayparams->numRays; - textureparams.startX = rayparams->r * rayparams->raywidth - + rayparams->backgroundOffsetX; - textureparams.endX = textureparams.startX + rayparams->raywidth; + set_rayparams(rayparams); + calculate_line_height(rayparams); + rayparams->raywidth = rayparams->w->s_win.width / rayparams->num_rays; + rayparams->background_off_setx = BOV; + calculate_deca(rayparams, &olineh, &deca); + set_texture_params(rayparams, &textureparams); init_texture_params(&textureparams, rayparams); init_line_params(&lineparams, rayparams); draw_line(&lineparams); - if (olineh > rayparams->w->s_win.height) - deca = olineh - rayparams->w->s_win.height; - else - deca = 0; draw_black_ground(rayparams, textureparams); if (deca != 0) + { draw_yolo(rayparams, &textureparams, deca); + } else + { draw_texture(&textureparams); -} - -void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca) -{ - int texturewidth; - int textureheight; - int i; - int y; - int x; - float perspectivefactor; - int texturex; - int color; - - texturewidth = tparams->w->s_img.texture_width; - textureheight = tparams->w->s_img.texture_height; - i = 0; - for (y = rparams->lineOff; y < rparams->lineOff + rparams->lineH; y++) { - // La variable perspectiveFactor permet de mapper la texture en tenant compte de la perspective - perspectivefactor = (float)(y - rparams->lineOff) / rparams->lineH; - int textureY = perspectivefactor * (textureheight ); - if (textureY >= textureheight) { - textureY = textureheight - 1; - } - - //for (int x = startX; x < endX; x++) { - x = tparams->startX; - switch (tparams->wallDir) { - case NORTH: - case SOUTH: - // Assurez-vous que rx est normalisé correctement pour le mappage de texture - texturex = (int)(tparams->rx * texturewidth / tparams->w->s_map.mapS) % texturewidth; - break; - case WEST: - case EAST: - // Assurez-vous que ry est normalisé correctement pour le mappage de texture - texturex = (int)(tparams->ry * texturewidth / tparams->w->s_map.mapS) % texturewidth; - break; - } - if (texturex >= texturewidth) { - texturex = texturewidth - 1; - } - //printf("%f %f\n",lineOff, lineOff/lineH); - - - color = get_texture_color(tparams->w, tparams->wallDir, texturex, y); - - - // BLOCK OK MEH - // float ww = ((720+merde)/lineH); - // //printf("%d %d %d\n", t ,td, merde); - // put_pixel_img(w, x, (int)(iii*ww)-merde/2, color); - // iii++; - - int a = tparams->lineOff - deca / 2; - int b = tparams->lineH + (deca /2); - int c = tparams->lineH; - double step = (b - a)/(double)(c - 1); - //printf("%d %d %d\n", t ,td, merde); - put_pixel_img(tparams->w, x, (int)(a + i * step), color); - i++; - //} } } diff --git a/draw/ft_3d_view_utils.c b/draw/ft_3d_view_utils.c new file mode 100644 index 0000000..0b7a378 --- /dev/null +++ b/draw/ft_3d_view_utils.c @@ -0,0 +1,93 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_3d_view_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: fgras-ca +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/29 17:00:21 by fgras-ca #+# #+# */ +/* Updated: 2024/01/29 17:05:55 by fgras-ca ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../cub3d.h" + +static void set_texture_coords(t_texture_params *tparams, + t_draw_params *dparams) +{ + if (tparams->wall_dir == NORTH || tparams->wall_dir == SOUTH) + { + dparams->texturex = (int)(tparams->rx * dparams->texturewidth + / tparams->w->s_map.map_s) % dparams->texturewidth; + } + else if (tparams->wall_dir == WEST || tparams->wall_dir == EAST) + { + dparams->texturex = (int)(tparams->ry * dparams->texturewidth + / tparams->w->s_map.map_s) % dparams->texturewidth; + } + if (dparams->texturex >= dparams->texturewidth) + { + dparams->texturex = dparams->texturewidth - 1; + } +} + +static void draw_texture_line(t_ray_params *rparams, + t_texture_params *tparams, t_draw_params *dparams, int deca) +{ + int y; + int color; + float perspectivefactor; + + y = rparams->line_off; + dparams->i = 0; + dparams->x = tparams->start_x; + while (y < rparams->line_off + rparams->line_h) + { + perspectivefactor = (float)(y - rparams->line_off) / rparams->line_h; + dparams->textureY = perspectivefactor * dparams->textureheight; + if (dparams->textureY >= dparams->textureheight) + dparams->textureY = dparams->textureheight - 1; + set_texture_coords(tparams, dparams); + color = get_texture_color(tparams->w, + tparams->wall_dir, dparams->texturex, y); + dparams->a = tparams->line_off - deca / 2; + dparams->b = tparams->line_h + (deca / 2); + dparams->c = tparams->line_h; + dparams->step = (dparams->b - dparams->a) / (double)(dparams->c - 1); + put_pixel_img(tparams->w, dparams->x, + (int)(dparams->a + dparams->i * dparams->step), color); + dparams->i++; + y++; + } +} + +void draw_yolo(t_ray_params *rparams, t_texture_params *tparams, int deca) +{ + t_draw_params dparams; + + dparams.texturewidth = tparams->w->s_img.texture_width; + dparams.textureheight = tparams->w->s_img.texture_height; + draw_texture_line(rparams, tparams, &dparams, deca); +} + +void init_line_params(t_line_params *lineparams, t_ray_params *rayParams) +{ + lineparams->w = rayParams->w; + lineparams->x0 = (int)rayParams->w->s_player.px; + lineparams->y0 = (int)rayParams->w->s_player.py; + lineparams->x1 = (int)rayParams->rx; + lineparams->y1 = (int)rayParams->ry; + lineparams->color = rayParams->color; +} + +void init_texture_params(t_texture_params *textureparams, + t_ray_params *rayParams) +{ + textureparams->w = rayParams->w; + textureparams->line_off = rayParams->line_off; + textureparams->line_h = rayParams->line_h; + textureparams->wall_dir = rayParams->wall_dir; + textureparams->rx = rayParams->rx + rayParams->background_off_setx; + textureparams->ry = rayParams->ry; + textureparams->dis_t = rayParams->dis_t; +} diff --git a/draw/ft_background.c b/draw/ft_background.c index 4a4ff1f..945bf43 100644 --- a/draw/ft_background.c +++ b/draw/ft_background.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 23:19:39 by fgras-ca #+# #+# */ -/* Updated: 2024/01/26 17:40:14 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:08:15 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,10 +17,10 @@ void draw_sky_ground(t_sky_ground_params *params) t_square_params square_params; square_params.w = params->w; - square_params.x = params->backgroundOffsetX; - square_params.y = params->startHeight; - square_params.xo = params->w->s_win.width + params->backgroundOffsetX; - square_params.yo = params->endHeight; + square_params.x = params->background_off_setx; + square_params.y = params->start_height; + square_params.xo = params->w->s_win.width + params->background_off_setx; + square_params.yo = params->end_height; square_params.color = params->color; draw_square_raw(&square_params); } @@ -33,16 +33,16 @@ void draw_background(t_structure_main *w) backgroundoffsetx = BOV; sky_params.w = w; - sky_params.startHeight = 0; - sky_params.endHeight = w->s_win.height / 2; + sky_params.start_height = 0; + sky_params.end_height = w->s_win.height / 2; sky_params.color = w->t->ceil_color; - sky_params.backgroundOffsetX = backgroundoffsetx; + sky_params.background_off_setx = backgroundoffsetx; draw_sky_ground(&sky_params); ground_params.w = w; - ground_params.startHeight = w->s_win.height / 2; - ground_params.endHeight = w->s_win.height; + ground_params.start_height = w->s_win.height / 2; + ground_params.end_height = w->s_win.height; ground_params.color = w->t->floor_color; - ground_params.backgroundOffsetX = backgroundoffsetx; + ground_params.background_off_setx = backgroundoffsetx; draw_sky_ground(&ground_params); } @@ -51,10 +51,10 @@ void draw_black_ground(t_ray_params *params, t_texture_params tparams) t_square_params square_params; square_params.w = params->w; - square_params.x = tparams.startX; - square_params.y = params->lineOff; + square_params.x = tparams.start_x; + square_params.y = params->line_off; square_params.xo = square_params.x + 1; - square_params.yo = params->lineOff + params->lineH ; + square_params.yo = params->line_off + params->line_h ; square_params.color = 0x000000; draw_square_raw(&square_params); -} \ No newline at end of file +} diff --git a/draw/ft_draw.c b/draw/ft_draw.c index bc2fb1c..e64f5b7 100644 --- a/draw/ft_draw.c +++ b/draw/ft_draw.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 22:38:28 by fgras-ca #+# #+# */ -/* Updated: 2024/01/14 17:54:44 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 15:47:48 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,9 +20,9 @@ void draw_square(t_structure_main *w, int x, int y, int color) int i; int j; - xo = x * w->s_map.mapS; - yo = y * w->s_map.mapS; - size = w->s_map.mapS; + xo = x * w->s_map.map_s; + yo = y * w->s_map.map_s; + size = w->s_map.map_s; i = 0; while (i < size) { diff --git a/draw/ft_horizontal_ray.c b/draw/ft_horizontal_ray.c index 5170326..5ca2f13 100644 --- a/draw/ft_horizontal_ray.c +++ b/draw/ft_horizontal_ray.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 19:53:47 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 20:37:32 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:12:54 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,38 +25,37 @@ void inithorizontalray(t_ray_calc_params *params) int tilesize; atan = -1 / tan(params->ra); - tilesize = params->w->s_map.mapS; + tilesize = params->w->s_map.map_s; if (params->ra != PI) handle_ra_not_equal_pi(params, atan, tilesize); else handle_ra_equal_pi(params); } -void update_ray_params(t_ray_calc_params *params, int mx, int my) { - int mp = my * params->w->s_map.mapX + mx; +void update_ray_params(t_ray_calc_params *params, int mx, int my) +{ + int mp; + char map_pos; - if (mp >= 0 && mp < params->w->s_map.mapX * params->w->s_map.mapY) { - char map_pos = params->w->s_map.map[mp]; - - if (map_pos == '1' || map_pos == '2') { - params->dof = DOF; - *params->disRay = dist(params->w->s_player.px, params->w->s_player.py, - *params->rx, *params->ry); - - if (params->ra > PI) - *params->wallDir = NORTH; - else - *params->wallDir = SOUTH; - - // Définir le type de mur actuel - if (map_pos == '2') { - params->w->current_wall_type = map_pos; - } else { - // Assurez-vous de réinitialiser pour les murs normaux - params->w->current_wall_type = '1'; - } - } - } + mp = my * params->w->s_map.map_x + mx; + if (mp >= 0 && mp < params->w->s_map.map_x * params->w->s_map.map_y) + { + map_pos = params->w->s_map.map[mp]; + if (map_pos == '1' || map_pos == '2') + { + params->dof = DOF; + *params->dis_ray = dist(params->w->s_player.px, + params->w->s_player.py, *params->rx, *params->ry); + if (params->ra > PI) + *params->wall_dir = NORTH; + else + *params->wall_dir = SOUTH; + if (map_pos == '2') + params->w->current_wall_type = map_pos; + else + params->w->current_wall_type = '1'; + } + } } void processhorizontalray(t_ray_calc_params *params) @@ -65,8 +64,8 @@ void processhorizontalray(t_ray_calc_params *params) int my; int tilesize; - tilesize = params->w->s_map.mapS; - *params->disRay = DISRAY; + tilesize = params->w->s_map.map_s; + *params->dis_ray = DISRAY; while (params->dof < DOF) { mx = (int)(*params->rx) / tilesize; diff --git a/draw/ft_load_textures.c b/draw/ft_load_textures.c index d0365ce..6d979fc 100644 --- a/draw/ft_load_textures.c +++ b/draw/ft_load_textures.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 20:30:59 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 20:34:50 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:13:50 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,6 @@ void load_wall_textures(t_structure_main *w) load_texture(w, w->t->west, (void **)&w->s_img.west_texture); load_texture(w, w->t->east, (void **)&w->s_img.east_texture); load_texture(w, "textures/door_close.xpm", (void **)&w->s_img.door_texture); - //load_texture(w, "textures/open_door.xpm", (void **)&w->s_img.open_door_texture); } void exit_error(t_structure_main *w) diff --git a/draw/ft_textures.c b/draw/ft_textures.c index c346c6e..3b0dc3d 100644 --- a/draw/ft_textures.c +++ b/draw/ft_textures.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 17:39:11 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 20:34:32 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:17:21 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,19 +20,19 @@ void draw_texture_line(t_texture_params *params, float y, int textureY) int color; texturewidth = params->w->s_img.texture_width; - x = params->startX; - while (x < params->endX) + x = params->start_x; + while (x < params->end_x) { - if (params->wallDir == NORTH || params->wallDir == SOUTH) + if (params->wall_dir == NORTH || params->wall_dir == SOUTH) texturex = (int)(params->rx * texturewidth - / params->w->s_map.mapS) % texturewidth; + / params->w->s_map.map_s) % texturewidth; else texturex = (int)(params->ry * texturewidth - / params->w->s_map.mapS) % texturewidth; + / params->w->s_map.map_s) % texturewidth; if (texturex >= texturewidth) texturex = texturewidth - 1; color = get_texture_color(params->w, - params->wallDir, texturex, textureY); + params->wall_dir, texturex, textureY); put_pixel_img(params->w, x, y, color); x++; } @@ -46,10 +46,10 @@ void draw_texture(t_texture_params *params) int texturey; textureheight = params->w->s_img.texture_height; - y = params->lineOff; - while (y < params->lineOff + params->lineH) + y = params->line_off; + while (y < params->line_off + params->line_h) { - perspectivefactor = (y - params->lineOff) / params->lineH; + perspectivefactor = (y - params->line_off) / params->line_h; texturey = perspectivefactor * textureheight; if (texturey >= textureheight) texturey = textureheight - 1; @@ -58,14 +58,15 @@ void draw_texture(t_texture_params *params) } } -void *get_selected_texture(t_structure_main *w, WallDirection wallDir) +void *get_selected_texture(t_structure_main *w, t_WallDirection wallDir) { - void *texture = NULL; - if (w->current_wall_type == '2') { - return w->s_img.door_texture; // Texture pour porte fermée - } /*else if (w->current_wall_type == '3') { - return w->s_img.open_door_texture; // Texture pour porte ouverte - }*/ + void *texture; + + texture = NULL; + if (w->current_wall_type == '2') + { + return (w->s_img.door_texture); + } else if (wallDir == NORTH) return (w->s_img.north_texture); else if (wallDir == SOUTH) @@ -76,12 +77,12 @@ void *get_selected_texture(t_structure_main *w, WallDirection wallDir) return (w->s_img.east_texture); else { - fprintf(stderr, "Invalid wall direction.\n"); + printf("Invalid wall direction.\n"); exit_error(w); return (NULL); } - if (texture == NULL) - fprintf(stderr, "get_selected_texture: selected texture is NULL\n"); + if (texture == NULL) + printf("get_selected_texture: selected texture is NULL\n"); else printf("get_selected_texture: selected texture = %p\n", texture); } @@ -95,7 +96,7 @@ t_texture_data get_texture_data(void *texture) return (texture_data); } -int get_texture_color(t_structure_main *w, WallDirection wallDir, +int get_texture_color(t_structure_main *w, t_WallDirection wallDir, int textureX, int textureY) { void *selected_texture; @@ -108,7 +109,6 @@ int get_texture_color(t_structure_main *w, WallDirection wallDir, fprintf(stderr, "No texture selected for color retrieval\n"); return (0); } - texture_data = get_texture_data(selected_texture); pixel_pos = (textureX + textureY * w->s_img.texture_width) * (texture_data.bpp / 8); diff --git a/draw/ft_vertical_ray.c b/draw/ft_vertical_ray.c index 2033889..dfada0b 100644 --- a/draw/ft_vertical_ray.c +++ b/draw/ft_vertical_ray.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 20:03:21 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 20:37:08 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:22:00 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,35 +18,35 @@ void initverticalray(t_ray_calc_params *params) int tilesize; ntan = -tan(params->ra); - tilesize = params->w->s_map.mapS; + tilesize = params->w->s_map.map_s; handle_ra_vertical(params, ntan, tilesize); } -void update_vertical_ray_params(t_ray_calc_params *params, int mx, int my) { - int mp = my * params->w->s_map.mapX + mx; +void update_vertical_ray_params(t_ray_calc_params *params, int mx, int my) +{ + int mp; + char map_pos; - if (mp >= 0 && mp < params->w->s_map.mapX * params->w->s_map.mapY) { - char map_pos = params->w->s_map.map[mp]; - - if (map_pos == '1' || map_pos == '2') { - params->dof = DOF; - *params->disRay = dist(params->w->s_player.px, params->w->s_player.py, - *params->rx, *params->ry); - - if (params->ra > P2 && params->ra < P3) - *params->wallDir = WEST; - else - *params->wallDir = EAST; - - // Définir le type de mur actuel - if (map_pos == '2') { - params->w->current_wall_type = map_pos; - } else { - // Assurez-vous de réinitialiser pour les murs normaux - params->w->current_wall_type = '1'; - } - } - } + mp = my * params->w->s_map.map_x + mx; + if (mp >= 0 && mp < params->w->s_map.map_x * params->w->s_map.map_y) + { + map_pos = params->w->s_map.map[mp]; + if (map_pos == '1' || map_pos == '2') + { + params->dof = DOF; + *params->dis_ray = dist(params->w->s_player.px, + params->w->s_player.py, + *params->rx, *params->ry); + if (params->ra > P2 && params->ra < P3) + *params->wall_dir = WEST; + else + *params->wall_dir = EAST; + if (map_pos == '2') + params->w->current_wall_type = map_pos; + else + params->w->current_wall_type = '1'; + } + } } void processverticalray(t_ray_calc_params *params) @@ -55,8 +55,8 @@ void processverticalray(t_ray_calc_params *params) int my; int tilesize; - tilesize = params->w->s_map.mapS; - *params->disRay = DISRAY; + tilesize = params->w->s_map.map_s; + *params->dis_ray = DISRAY; while (params->dof < DOF) { mx = (int)(*params->rx) / tilesize; diff --git a/include/mlx.h b/include/mlx.h index b323412..fc751cd 100644 --- a/include/mlx.h +++ b/include/mlx.h @@ -1,139 +1,53 @@ -/* -** mlx.h for MinilibX in -** -** Made by Charlie Root -** Login -** -** Started on Mon Jul 31 16:37:50 2000 Charlie Root -** Last update Tue May 15 16:23:28 2007 Olivier Crouzet -*/ - -/* -** MinilibX - Please report bugs -*/ - - -/* -** FR msg - FR msg - FR msg -** -** La MinilibX utilise 2 librairies supplementaires qu'il -** est necessaire de rajouter a la compilation : -** -lmlx -lXext -lX11 -** -** La MinilibX permet le chargement des images de type Xpm. -** Notez que cette implementation est incomplete. -** Merci de communiquer tout probleme de chargement d'image -** de ce type. -*/ - +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* mlx.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: fgras-ca +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/29 17:22:58 by fgras-ca #+# #+# */ +/* Updated: 2024/01/29 17:28:02 by fgras-ca ### ########.fr */ +/* */ +/* ************************************************************************** */ #ifndef MLX_H - -#define MLX_H - +# define MLX_H void *mlx_init(); -/* -** needed before everything else. -** return (void *)0 if failed -*/ - - -/* -** Basic actions -*/ - void *mlx_new_window(void *mlx_ptr, int size_x, int size_y, char *title); -/* -** return void *0 if failed -*/ -int mlx_clear_window(void *mlx_ptr, void *win_ptr); -int mlx_pixel_put(void *mlx_ptr, void *win_ptr, int x, int y, int color); -/* -** origin for x & y is top left corner of the window -** y down is positive -** color is 0x00RRGGBB -*/ - - -/* -** Image stuff -*/ - +int mlx_clear_window(void *mlx_ptr, void *win_ptr); +int mlx_pixel_put(void *mlx_ptr, void *win_ptr, int x, int y, int color); void *mlx_new_image(void *mlx_ptr,int width,int height); -/* -** return void *0 if failed -** obsolete : image2 data is stored using bit planes -** void *mlx_new_image2(void *mlx_ptr,int width,int height); -*/ char *mlx_get_data_addr(void *img_ptr, int *bits_per_pixel, - int *size_line, int *endian); -/* -** endian : 0 = sever X is little endian, 1 = big endian -** for mlx_new_image2, 2nd arg of mlx_get_data_addr is number_of_planes -*/ -int mlx_put_image_to_window(void *mlx_ptr, void *win_ptr, void *img_ptr, + int *size_line, int *endian); +int mlx_put_image_to_window(void *mlx_ptr, void *win_ptr, void *img_ptr, int x, int y); -int mlx_get_color_value(void *mlx_ptr, int color); - - -/* -** dealing with Events -*/ - -int mlx_mouse_hook (void *win_ptr, int (*funct_ptr)(), void *param); -int mlx_key_hook (void *win_ptr, int (*funct_ptr)(), void *param); -int mlx_expose_hook (void *win_ptr, int (*funct_ptr)(), void *param); - -int mlx_loop_hook (void *mlx_ptr, int (*funct_ptr)(), void *param); -int mlx_loop (void *mlx_ptr); -int mlx_loop_end (void *mlx_ptr); - -/* -** hook funct are called as follow : -** -** expose_hook(void *param); -** key_hook(int keycode, void *param); -** mouse_hook(int button, int x,int y, void *param); -** loop_hook(void *param); -** -*/ - - -/* -** Usually asked... -*/ - -int mlx_string_put(void *mlx_ptr, void *win_ptr, int x, int y, int color, - char *string); +int mlx_get_color_value(void *mlx_ptr, int color); +int mlx_mouse_hook (void *win_ptr, int (*funct_ptr)(), void *param); +int mlx_key_hook (void *win_ptr, int (*funct_ptr)(), void *param); +int mlx_expose_hook (void *win_ptr, int (*funct_ptr)(), void *param); +int mlx_loop_hook (void *mlx_ptr, int (*funct_ptr)(), void *param); +int mlx_loop (void *mlx_ptr); +int mlx_loop_end (void *mlx_ptr); +int mlx_string_put(void *mlx_ptr, void *win_ptr, int x, int y, int color, + char *string); void mlx_set_font(void *mlx_ptr, void *win_ptr, char *name); void *mlx_xpm_to_image(void *mlx_ptr, char **xpm_data, - int *width, int *height); + int *width, int *height); void *mlx_xpm_file_to_image(void *mlx_ptr, char *filename, - int *width, int *height); -int mlx_destroy_window(void *mlx_ptr, void *win_ptr); + int *width, int *height); +int mlx_destroy_window(void *mlx_ptr, void *win_ptr); +int mlx_destroy_image(void *mlx_ptr, void *img_ptr); +int mlx_destroy_display(void *mlx_ptr); +int mlx_hook(void *win_ptr, int x_event, int x_mask, + int (*funct)(), void *param); +int mlx_do_key_autorepeatoff(void *mlx_ptr); +int mlx_do_key_autorepeaton(void *mlx_ptr); +int mlx_do_sync(void *mlx_ptr); +int mlx_mouse_get_pos(void *mlx_ptr, void *win_ptr, int *x, int *y); +int mlx_mouse_move(void *mlx_ptr, void *win_ptr, int x, int y); +int mlx_mouse_hide(void *mlx_ptr, void *win_ptr); +int mlx_mouse_show(void *mlx_ptr, void *win_ptr); +int mlx_get_screen_size(void *mlx_ptr, int *sizex, int *sizey); -int mlx_destroy_image(void *mlx_ptr, void *img_ptr); - -int mlx_destroy_display(void *mlx_ptr); - -/* -** generic hook system for all events, and minilibX functions that -** can be hooked. Some macro and defines from X11/X.h are needed here. -*/ - -int mlx_hook(void *win_ptr, int x_event, int x_mask, - int (*funct)(), void *param); - -int mlx_do_key_autorepeatoff(void *mlx_ptr); -int mlx_do_key_autorepeaton(void *mlx_ptr); -int mlx_do_sync(void *mlx_ptr); - -int mlx_mouse_get_pos(void *mlx_ptr, void *win_ptr, int *x, int *y); -int mlx_mouse_move(void *mlx_ptr, void *win_ptr, int x, int y); -int mlx_mouse_hide(void *mlx_ptr, void *win_ptr); -int mlx_mouse_show(void *mlx_ptr, void *win_ptr); - -int mlx_get_screen_size(void *mlx_ptr, int *sizex, int *sizey); - -#endif /* MLX_H */ +#endif diff --git a/libft/Makefile b/libft/Makefile deleted file mode 100644 index 9e89f17..0000000 --- a/libft/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# **************************************************************************** # -# # -# ::: :::::::: # -# Makefile :+: :+: :+: # -# +:+ +:+ +:+ # -# By: fgras-ca +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2023/02/06 12:19:21 by fgras-ca #+# #+# # -# Updated: 2024/01/15 22:06:15 by fgras-ca ### ########.fr # -# # -# **************************************************************************** # - -RST = \033[0m -GRAY = \033[0;90m -RED = \033[0;91m -GREEN = \033[0;92m -YELLOW = \033[0;93m -BLUE = \033[0;94m -MAGENTA = \033[0;95m -CYAN = \033[0;96m -WHITE = \033[0;97m -ORANGE = \033[38;5;214m - -NAME = libft.a - -SOURCES = ft_atoi.c \ - ft_isalpha.c \ - ft_memchr.c \ - ft_memset.c \ - ft_strlcat.c \ - ft_strnstr.c \ - ft_toupper.c \ - ft_bzero.c \ - ft_isascii.c \ - ft_memcmp.c \ - ft_strchr.c \ - ft_strlcpy.c \ - ft_strrchr.c \ - ft_calloc.c \ - ft_isdigit.c \ - ft_memcpy.c \ - ft_substr.c \ - ft_isalnum.c \ - ft_isprint.c \ - ft_memmove.c \ - ft_strncmp.c \ - ft_tolower.c\ - ft_strtrim.c \ - ft_putchar_fd.c \ - ft_putstr_fd.c \ - ft_putendl_fd.c \ - ft_putnbr_fd.c \ - ft_strmapi.c \ - ft_striteri.c \ - ft_itoa.c \ - ft_strcmp.c \ - ft_strstr.c \ - ft_reallocarray.c \ - ft_strcat.c \ - ft_strcpy.c \ - ft_realloc.c \ - ft_strncpy.c \ - ft_strtol.c \ - ft_strtok.c \ - -SRCBONUS = ft_lstnew.c \ - ft_lstadd_front.c \ - ft_lstsize.c \ - ft_lstlast.c \ - ft_lstadd_back.c \ - ft_lstdelone.c \ - ft_lstclear.c \ - ft_lstiter.c \ - ft_lstiter.c \ - ft_lstmap.c \ - - -OBJECTS = $(SOURCES:.c=.o) - -BONUS_OBJ = $(SRCBONUS:.c=.o) - -CC = gcc - -RM = rm -f - -CFLAGS = -Wall -Werror -Wextra - -all: $(NAME) - -$(NAME): $(OBJECTS) - @echo $(CC) (CFLAGS) $(OBJECTS) -o $(NAME) - -bonus: $(OBJECTS) $(BONUS_OBJ) - $(CC) (CFLAGS) $(OBJECTS) $(BONUS_OBJ) -o $(NAME) - -clean: - @echo $(RM) $(OBJECTS) $(BONUS_OBJ) - -fclean: clean - @echo $(RM) $(NAME) $(BONUS_OBJ) - -re: fclean all diff --git a/libft/ft_atoi.c b/libft/ft_atoi.c deleted file mode 100644 index 5756d38..0000000 --- a/libft/ft_atoi.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/11 16:16:54 by fgras-ca #+# #+# */ -/* Updated: 2023/02/21 09:57:55 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_atoi(const char *nptr) -{ - int i; - int sign; - int res; - - i = 0; - sign = 1; - res = 0; - while (nptr[i] == 32 || (nptr[i] >= 9 && nptr[i] <= 13)) - i++; - if (nptr[i] == '-' || nptr[i] == '+') - { - if (nptr[i] == '-') - sign = - (1); - i++; - } - while (nptr[i] >= 48 && nptr[i] <= 57) - { - res = res * 10 + nptr[i] - 48; - i++; - } - return (res * sign); -} diff --git a/libft/ft_atoi.o b/libft/ft_atoi.o deleted file mode 100644 index 129e2ece43af6e35a45deb3f8663c150ff1e068a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1480 zcmbVM&ubG=5T2LBruK)4+JjJ$^`xSCCZ&RkNFY4Bi1Z)?yp(p6Zd=hLC3!2UU_2Cr zkc&tE2M^vnN{WZ{xPO8dA<&bULyxWd`DuIt;{^qLb927_puhnN`>9iJ{5d z%y)QV$l(+=+gX~z7CZeZEGMVy?mFw!bxs=3a)v@jILYBdi3E0rD_x62i$E*+y#;Hx~JD>zp{OTPA z<62UvS=0-tYwKme_4Wx%qLM862H5+Tz}i{1ypW##jBCA)I4Q{-tyx^keoB-UXOfIz ziHFBMs5AwC&f;>(m>ZwR!Yd)%n?>XuxoOG9YhKl!-_h_5y@#hN1mLZMnzSltWz)BN z+LLx$0^hcz1-#N~0k1Y{HM@>jy&-LmYss~wRehu4-MYi~n~i*q(f1~llNCK)rRFJ288MR)4Au-LY0WZw-Be>J1_qpa;aw?H7t5Q z<-?-qYx@9`+7H*givwe71!8H`(BFjDrmgsf7X^>#m%4!|Dvk2LDE`BM>UmNAD@5t{ zQ}nXI!&D8gDd-|vI;ZAqJZ?5oTs41-0+cyax}zwc`bO^#A;_!wS1AaIYCAzLqZh~D NQvBUXrSC-f{{brIy~_Xq diff --git a/libft/ft_bzero.c b/libft/ft_bzero.c deleted file mode 100644 index d032508..0000000 --- a/libft/ft_bzero.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_bzero.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/04 11:37:30 by fgras-ca #+# #+# */ -/* Updated: 2023/02/20 16:07:19 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_bzero(void *ptr, size_t len) -{ - size_t i; - - i = 0; - while (i < len) - { - *(char *)(ptr + i) = 0; - i++; - } -} diff --git a/libft/ft_bzero.o b/libft/ft_bzero.o deleted file mode 100644 index ffe7599a2706736f9fb0e2273bb2baf8b7e9a811..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1272 zcmbVLJ4*vW5T1)~jT&DdC=x3bbV($FC`cfjULh7jz(({EPX$dPmpw=nwGf10lYgN< zLlD%`pCE`JScy%r(V5Hcxh%19V0PyFX1;yiotvx6A;SP^1}woZk}NtW(XvR4s=q>0gYiS4p+!EJ>PBvH%U>vW5QHmHN z;kNcF?s*h>at3AK#72O$}}+jE(&Y@2^GTUA~n$cH9EX z1}V`|8qn|@zWaa%RxIbZox#Z6dfb;8cS;=Cj?HagnPL%Gwvfv?dF1j1?l8QTnIgBd z2LkWqJ$B?4jvSYlfw|71&7A$MUDwVz!D|0bMo>w2)T+&p6gW7)z|^bSI0EA2`^nmg zOth%$C$LWM_h0=qYH7|Gx@vNLs;ef~mvIh@GFSVqRiNa0uZgubbb5c)ZUl&`BJK|1`$hQqr(DsV5EIYz2qCM?MsAy+Xn!h80n34J +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/11 17:47:38 by fgras-ca #+# #+# */ -/* Updated: 2023/02/21 10:45:58 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_calloc(size_t nmemb, size_t size) -{ - void *ptr; - - if (!nmemb || !size) - return (malloc(0)); - if ((nmemb * size) / size != nmemb) - return (NULL); - ptr = malloc(size * nmemb); - if (!ptr) - return (0); - ft_bzero(ptr, size * nmemb); - return (ptr); -} diff --git a/libft/ft_calloc.o b/libft/ft_calloc.o deleted file mode 100644 index f21092ebd0ecc36b366ca74da8b5254571cc46b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1568 zcmbtT&ubG=5S~qIu&@6hX@Fy0u_737faj7OIDW zx_GI7iC6KW=s`Ss@tljWpcnCA5T(v+<|UhDz39MXX1@7mW;^rx$hvvGU>KmqfU7W$ zGz!o!jQx7z)}ag~_&z)Tvniv`a__4tqup3WVPEd;#-NI5`Vf|06Fa7#FSdMU#d7wA z)qh2?{DIsnR;-FIlk_!A_bH8C-X|3@vIf{@03lP(r6_OFAIRv_h>YQfcd*)Mte6W; zCv24eq{yG@Soxk8uQaJ5U^G(L-*`%Hhfaq=e z%68DIU}!hB7kDjOC~r%FxMwRHgwyMRa67*5wGnG~lqc{;i#=t#4>-Qx4n;TUbiF`r zgGf4fo9i2a?R)$M|7T1rr<=`W+SEDL_t5F=|IQpHXpePGU|Zp(NRE%9rCR-T&MRClii=I#Y)1v2VyMjsWr+L5ALCVi^Z(y#7I`M{x z&qR~_l<56w$U%pw*?N=fFKZ&(Z2eut^X|9C4fUPqepIXLHJ&${My>JueF{*Hq0)`A k^+y;-Ga)h8Uzk8gYZ;*@(97PQl3o7()`&TDxa|o2132ocmjD0& diff --git a/libft/ft_isalnum.c b/libft/ft_isalnum.c deleted file mode 100644 index 1f065f3..0000000 --- a/libft/ft_isalnum.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/01 16:21:11 by fgras-ca #+# #+# */ -/* Updated: 2023/02/01 16:24:23 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isalnum(int c) -{ - if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57)) - return (1); - else - return (0); -} diff --git a/libft/ft_isalnum.o b/libft/ft_isalnum.o deleted file mode 100644 index 6f270a08ca3805bc3a37c5eac7793b9b6b4d365c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1288 zcmbVLK}#D^5T1>iL>o1V2gOp-Q(LIdL=;p|7DB3r;z0n#Mei9abVued^6w7W8UsbgvVgMeFIb^<>9sJio`|cy1;BahyYcIv&Jx;UsfQy?^%IQiqLu zSSgnm3m>bs$d^%}R1&kII8}<0uoTbCh~n%g1t%l%=ta$=_Mxt9VOIEF9JFWEPRP z<>qea?E8@?>RP~k3(BE2YpVtj;gKhu8d@2&ZG%1O9!d~D9O;0lg&~M~)AL*(F~2EY zf$NzHrBmNi@s1yfgP?if2J#3*;O;xZZES7_j_2|%UT-InO1nxMEo>Ec_Ml>_)#W_~ zgz-CauEmaFP5uYW(>uPF{~5W|vxuq-&!@aDJfH0xCfV2PuJu6k&Dsj)GN}K&J;pbR zQ&5(T`OR)%f_j?#2Su1?qOvCc8{+gI*(%TGTwQcr0sUy{p3G;w+iap_6@QBYlmS$F jBa=^k&9_4c8j3$bfhG#>AS38?<6o)5ola%jG5LQ1o^fW# diff --git a/libft/ft_isalpha.c b/libft/ft_isalpha.c deleted file mode 100644 index 3ff8fc5..0000000 --- a/libft/ft_isalpha.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalpha.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/01 13:36:34 by fgras-ca #+# #+# */ -/* Updated: 2023/02/01 13:58:21 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isalpha(int c) -{ - if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) - return (1); - else - return (0); -} diff --git a/libft/ft_isalpha.o b/libft/ft_isalpha.o deleted file mode 100644 index cdd8acd360ce8b269a96e8d3fc11b9bf461ad71e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1272 zcmbVLJ4*vW5T1*g_=pZyKRzlD-c-lj`Udwv)+?=u$dUF7R^HG+Bbh zV`kZhW_@*)#S_bdCP6=X1bqN~doK+EfEVKW(8;FS35=V4Fe(vaHXIs!z=3nflarYg zQe%<3Kyoyg!v%!@FnZR0`1tPC?(19u59Myj?Y{>?{vrgx0*#EomEiVz!JD~4g%9!)fNyCC+|`Au4SQRUB8HZy2tuXck3!(qId&E!ZWKlnMgZ|APVT< +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/01 16:40:31 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:07:04 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isascii(int c) -{ - if (c >= 0 && c <= 127) - return (1); - return (0); -} diff --git a/libft/ft_isascii.o b/libft/ft_isascii.o deleted file mode 100644 index 0c87c23440ed7164ef758e7c6645d54cb23ed038..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1264 zcmbVL%}YW-5T9qIeQ6dQ3M1?g71W|(5FJ7gvqMA#LWiQB_ADtscy9#_%0m!&t6P7H z$DqHZQh~8?TM)@7wEdsQPiO*L_VYe;a60<-;!pn+2;gu2(OFL^><4)*vq8_Bn`{YE_xTfG~NFGWXxsbp8So=pK9JFC&+FMo?9e z^C_>2oG$OSD`B4AdJ;qOh6Bbq){hvL;1ohPU?n^^_T@r=W`3H#8 zJBo|EG-a{TDFF +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/01 14:46:59 by fgras-ca #+# #+# */ -/* Updated: 2023/02/01 15:55:00 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isdigit(int c) -{ - if (c >= 48 && c <= 57) - return (1); - else - return (0); -} diff --git a/libft/ft_isdigit.o b/libft/ft_isdigit.o deleted file mode 100644 index 8aa6b69b9c1934804e64c75c8762fbdbed9a2128..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1264 zcmbVL%}YW-5TB>1eQ6dQiX!X~71X9;P#r=Lt3yNtLWjbh_A)6ycy9#@szVTUt6P6c z$DqHZQB33qhd%fm znE1+U+`Zmid|zLDFI)z3UA_uDQTdzii7NMBU_F&uiOghjwKA_oVlkFr(fL@-4P%$_ zIEyA`1?;xQr3*ET>O)=M%76#pnJ_OZ$#BDfalQjaJ#38i2fFWZ=s4n}BvZ7cL*W}w zD(K(C0*X5b?Y9d)e%htIZB8VFg+mJN&LZ*=&la7-Vxh=cUI}F1h;Z+_b79nwx;u^kwEwOU;Z3&sb>^b z6*-^ss>u1$E@D#pYTbhxD862s##{jP&)sAEC^!*erP2S{eN0eKo$tOh#Fr#dSe?I% zIK88!$V*cd8yyiq4_ex% +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/03 12:43:03 by fgras-ca #+# #+# */ -/* Updated: 2023/02/03 13:25:31 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isprint(int c) -{ - if (c >= 32 && c <= 126) - return (1); - return (0); -} diff --git a/libft/ft_isprint.o b/libft/ft_isprint.o deleted file mode 100644 index e3a203c12c54571771f65500c6bc42bb6a28703b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1264 zcmbVL%}YW-5T9qJeW+PyAOD0lPFHF_a zX_lOy6|mPD7e8tgwHtMHBM&}+7s9$wNrvkNjLR)B&Z9;w6zqAxp<{@Xl1$N(i$rgI z*>GS73n*?Qv|m4b{Jvmb1zEV zEC6%4Q@6*`X}4U zMb4+ZDssNG3z(F?TKA|1im%t^Fc(DqclQ`S2~J#CY4m?~7ZcP|=X);=@kL1#R_AXc zPVXoq^3qhqMn?qDi +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/17 15:53:35 by fgras-ca #+# #+# */ -/* Updated: 2023/02/21 10:21:07 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static size_t ft_len_nb(int nb) -{ - int len; - - len = 0; - if (nb <= 0) - len++; - while (nb) - { - len++; - nb = nb / 10; - } - return (len); -} - -char *ft_itoa(int n) -{ - int len; - char *str; - long nb; - - len = ft_len_nb(n); - nb = n; - str = malloc(sizeof(char) * len +1); - if (!str) - return (0); - if (nb < 0) - { - str[0] = '-'; - nb = -nb; - } - if (nb == 0) - str[0] = '0'; - str[len--] = '\0'; - while (nb) - { - str[len] = nb % 10 + '0'; - len--; - nb = nb / 10; - } - return (str); -} diff --git a/libft/ft_itoa.o b/libft/ft_itoa.o deleted file mode 100644 index ad0d02e57578cb82888f3e7c8cae449e4dfad558..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1784 zcmbtT&1(};5P!R^t^KmGC=}{P4n>UEB`G}>v4OJfAbuePyp*zuo3@ybl5DUQ(jr0e z5ehx#>VHu@H5S`iP=W{X(1RC2+Z-Yu8cQ(FY~D-5CV0?+w{PY*^P4ws=IyF}drDOl zCPiU4*@-1l#x~kcbib|oSs&|VKl?8o2Y`R&>Ee!FAx9=%WUJRQdPO-Lrf*g+LZ|=> zALqj1Fys&1`C~O-zRdHy;MwJRk>XRIvU&w_Gg~qpWQty%-p}g$eCJ!PTCHLr8ju67 zmndTnGMfsZla55N44HJ9rMfrB{{EK0OuEFDdmyWqx7i3B&6I2;)mcNlm}TvLl?UwV zFbI^wHe-h?kiAoa*HkPC@Lf1M0A7H6Sq1(9^1mm*Qv&|R#=fXX17#CDdEk4zum+Tu z?pw>q_g=a((W3IVr1@VH$OTVg~8(xK81kz8hdFW1ED@@ts4RM0xsvDN8P8sJHX>_E1gDFRcdy)dt+I1+nwE z1`wCFT?1klanXI7By7ztSaCxOG1MYvY&I4ojW8B9B9VB=raTiw>Jjy()29f=fP!JUgb@EGs|4;^s-N~Opyw&^$MMGs@ zXnw?%d^x{XXVXz23R))vh5lzc$I0(P%sD%R*k{2XCZj>bwd%-O)LQXDfRTD+O>y%7 E03ap}egFUf diff --git a/libft/ft_lstadd_back.c b/libft/ft_lstadd_back.c deleted file mode 100644 index 3615437..0000000 --- a/libft/ft_lstadd_back.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstadd_back.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/23 18:08:00 by fgras-ca #+# #+# */ -/* Updated: 2023/02/23 18:15:14 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstadd_back(t_list **lst, t_list *new) -{ - t_list *temp; - - if (new && lst) - { - if (*lst) - { - temp = ft_lstlast(*lst); - temp->next = new; - } - else - *lst = new; - } -} diff --git a/libft/ft_lstadd_front.c b/libft/ft_lstadd_front.c deleted file mode 100644 index 01305fe..0000000 --- a/libft/ft_lstadd_front.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstadd_front.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/22 18:06:54 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:06:52 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstadd_front(t_list **lst, t_list *new) -{ - if (new) - { - new->next = *lst; - *lst = new; - } -} diff --git a/libft/ft_lstclear.c b/libft/ft_lstclear.c deleted file mode 100644 index 2367922..0000000 --- a/libft/ft_lstclear.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstclear.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/23 18:19:42 by fgras-ca #+# #+# */ -/* Updated: 2023/02/23 18:22:17 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstclear(t_list **lst, void (*del)(void*)) -{ - t_list *temp; - - while (*lst && lst) - { - temp = (*lst)->next; - ft_lstdelone(*lst, (*del)); - *lst = temp; - } -} diff --git a/libft/ft_lstdelone.c b/libft/ft_lstdelone.c deleted file mode 100644 index 07b9774..0000000 --- a/libft/ft_lstdelone.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstdelone.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/23 18:17:06 by fgras-ca #+# #+# */ -/* Updated: 2023/02/23 18:33:01 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstdelone(t_list *lst, void (*del)(void*)) -{ - if (!lst || !del) - return ; - del(lst->content); - free(lst); -} diff --git a/libft/ft_lstiter.c b/libft/ft_lstiter.c deleted file mode 100644 index efed585..0000000 --- a/libft/ft_lstiter.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstiter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/23 18:22:52 by fgras-ca #+# #+# */ -/* Updated: 2023/02/23 18:24:51 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstiter(t_list *lst, void (*f)(void *)) -{ - if (!lst || !f) - return ; - while (lst) - { - f(lst->content); - lst = lst->next; - } -} diff --git a/libft/ft_lstlast.c b/libft/ft_lstlast.c deleted file mode 100644 index e6279bb..0000000 --- a/libft/ft_lstlast.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstlast.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/23 17:48:29 by fgras-ca #+# #+# */ -/* Updated: 2023/02/23 18:02:44 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstlast(t_list *lst) -{ - while (lst) - { - if (lst->next == NULL) - return (lst); - lst = lst->next; - } - return (lst); -} diff --git a/libft/ft_lstmap.c b/libft/ft_lstmap.c deleted file mode 100644 index eea1576..0000000 --- a/libft/ft_lstmap.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/23 18:25:24 by fgras-ca #+# #+# */ -/* Updated: 2023/02/23 18:29:44 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) -{ - t_list *tmp; - t_list *res; - - if (!lst || !f) - return (NULL); - res = 0; - while (lst) - { - tmp = ft_lstnew((*f)(lst->content)); - if (!tmp) - { - ft_lstclear(&res, del); - return (NULL); - } - ft_lstadd_back(&res, tmp); - lst = lst->next; - } - return (res); -} diff --git a/libft/ft_lstnew.c b/libft/ft_lstnew.c deleted file mode 100644 index 0ceaea4..0000000 --- a/libft/ft_lstnew.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstnew.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/22 17:09:25 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:06:38 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstnew(void *content) -{ - t_list *new; - - new = malloc(sizeof(t_list)); - if (!new) - return (0); - new->content = content; - new->next = 0; - return (new); -} diff --git a/libft/ft_lstsize.c b/libft/ft_lstsize.c deleted file mode 100644 index 8c95558..0000000 --- a/libft/ft_lstsize.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstsize.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/23 17:17:36 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:06:24 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_lstsize(t_list *lst) -{ - int i; - t_list *tmp; - - tmp = lst; - i = 0; - while (tmp) - { - tmp = tmp->next; - i++; - } - return (i); -} diff --git a/libft/ft_memchr.c b/libft/ft_memchr.c deleted file mode 100644 index 34c95f7..0000000 --- a/libft/ft_memchr.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/10 13:42:10 by fgras-ca #+# #+# */ -/* Updated: 2023/02/14 13:03:28 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memchr(const void *s, int c, size_t n) -{ - size_t i; - - i = 0; - while (i < n) - { - if (((unsigned char *)s)[i] == (unsigned char)c) - return ((void *)(s + i)); - i++; - } - return (0); -} diff --git a/libft/ft_memchr.o b/libft/ft_memchr.o deleted file mode 100644 index fa3b76a512ae5072c9bd817beb5486ea08f41e64..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1304 zcmbtT&r2IY6n-16KU!0x2nrV2p0rShBq&G=5(uk%kRF5uFJd?8YCty$n^{o7A5bWS zT)YVW89fz`iU)hENB;l|0Z+wC@M7QF%p~Kmr}l%l@4fH6Z)Wz*?vb^!lrRjCFklh7 znPdSb65Ti#g*h04SMV@A_2}63-*)|=Sr6~*x^rt^TP^CipSBxL({5NT+qfD20S)JF z;U-Kfe|?4)qV5;ETRNo{Zqo!+M?imdGdj5-Zq2 zL_BClz3}HLuG$kb!6Y`0DtxpTi8uL%@A<`2z>3`%z@!?2#;%MWfYtVV?iSGVpzTXC z;@&O?_QmBcutKc{tXT1VuZ&!|!aas#nXPfRxGnOna>%MdrRoKI4_M&sxXdeUYzD6H zMO**ZV-nRgqdskwoX9)xFLLTt@fH)}!-0!*Y~gb_o$^c(`YK>{!~{X z_m_Sii!xUGF4aVd^w{;95Gf!5UZO(9s2Lg97&8uIl2 +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/10 14:45:56 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:18:05 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_memcmp(const void *s1, const void *s2, size_t n) -{ - size_t i; - - i = 0; - while (i < n) - { - if (((unsigned char *)s1)[i] != ((unsigned char *)s2)[i]) - return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]); - i++; - } - return (0); -} diff --git a/libft/ft_memcmp.o b/libft/ft_memcmp.o deleted file mode 100644 index a051b0e8cc083594d9fd339897bb300d303840cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1336 zcmbtTL2DCH5S~qITeWr5Qc$Q!yr>2HNJ857Zun1uvy;;`su@a}yno{An6Pr*}i0jCclkL&NzLMY1Ri?&rudsuNY@<6Ig;!UyPdw$Jt zvf3~QC{PWJ){LF_ejiwifU0{Lt(q-QE#%AF9UOf6-k2zG+9gS(HSP~E3Ut;P_+f4+-sr{+i zCzWVX*WboEt?z&JcTr1c7SYqD=2JawYQBogSX6ns?<5UUx!!AIZ5;i~?h*H-rXZsV z`lq^%1v*pLPsl-KC6rOuKSiGYKbEYka3J;9BykZV{Z6G&pLvd diff --git a/libft/ft_memcpy.c b/libft/ft_memcpy.c deleted file mode 100644 index 5473b65..0000000 --- a/libft/ft_memcpy.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/04 14:43:15 by fgras-ca #+# #+# */ -/* Updated: 2023/02/20 16:13:43 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memcpy(void *dest, const void *src, size_t n) -{ - char *destmov; - char *srcmov; - size_t i; - - destmov = (char *)dest; - srcmov = (char *)src; - if (!dest && !src) - return (0); - i = 0; - while (i < n) - { - destmov[i] = srcmov[i]; - i++; - } - return (dest); -} diff --git a/libft/ft_memcpy.o b/libft/ft_memcpy.o deleted file mode 100644 index f6a7acf81f638004baec833d15f0e21bc55dbbf5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1328 zcmbtT&ubGw6n?v{jX(M$6`?{!){_c$NJwXotHd!@7%U63zS)~ z23e+9fRdfzY6`0`4d>wJ+~r>$?|$Xo{bSxu2E6O_dCx`ce#eNpd%_R)k0F`GFo2}+ zmek)W{DV78k;8l53APToHQ>FwsPYhgoO=T=ZGPYmt+aN_?MI(zg{A_udl~%4x8ekI7D59T2U%%%8e#SfECeX<)i~?9s?}N2hv=*le zr(fX%Ttc3lET+YsExxd8GgJ01b`X(o^mdc*<9A+lBIjjiu<^Xcr)QCPOKgTg*l2fH zBf|g=)zD}h+DHIc+zEwW$0(vv+)+pbdji-aU--c4aSW`{3d5j@T(czthR?DT3%~JL z=G)DLwWC%$h(rfi6g=@+u(P=p`C*VA{a?!>s_BiUj9scSAAi5hsaLlvm=LGtr)sYi zFrulyigg;_zv^$Gmi8>6>!!}9x^C)x6<4vSu-^AsPc&@yx>zfq|22Eezo3&j>6$I( zPjv%Jw5O?8m#Spa6q))5$kP9(npU&rNM7`!q|RWZdn&!+bI-=Uiqt +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/07 11:11:49 by fgras-ca #+# #+# */ -/* Updated: 2023/02/07 16:04:25 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memmove(void *dest, const void *src, size_t n) -{ - char *destmov; - char *srcmov; - size_t i; - - if (!dest && !src) - return (0); - destmov = (char *)dest; - srcmov = (char *)src; - i = 0; - if (destmov > srcmov) - { - while (n--) - { - destmov[n] = srcmov[n]; - } - } - else - { - while (n--) - { - destmov[i] = srcmov[i]; - i++; - } - } - return (destmov); -} diff --git a/libft/ft_memmove.o b/libft/ft_memmove.o deleted file mode 100644 index c839f632aa5c5ac01e9caac8a8472ca10cf45818..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1408 zcmbVL&ubG=5T4!ER%>lj@lc6Kda{CjWJ?86kU&`b4k|?mcqw%gw=L)lP%RXH zgdq5bcvUo8-M@``A+lCNuNR_q}<%*}QP?-mxu!djvrL**B{PMqotpAktt$kUKnzCNllRI1c6ipyBDH{32>|d|(BO5L_ z?ja(0Zd-nFTiir_C~vv#^@W49Y!uq4_oUU7jeDTtIP2^9M|xv-;I|7$oe?j0qwfcf zVz>Hiq>8=cwk%WfjYlnhrulsSW@frjjLKn@aU3xxvNKN9DV^uDvm!fpRl$5ewn2Cb zehNN+zd(47UB(9BY!|wLtY;6%+DKXH(c#nY@Q{~)v$K8RA9pPE%Fdq~vfqQjK(g@; z2I==vQgLt`MGkKvtJEM5+m0zU{U>%J((3Vm)yCA{9)iit#RGYGvRVp#3QRh@ +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/03 15:49:51 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:07:29 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memset(void *s, int c, size_t n) -{ - size_t i; - - i = 0; - while (i < n) - { - *(unsigned char *)(s + i) = (unsigned char)c; - i++; - } - return (s); -} diff --git a/libft/ft_memset.o b/libft/ft_memset.o deleted file mode 100644 index 1d349d4798e06b1ba79ab0e184a61d88bbf3a458..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1280 zcmbVL&r2IY6n-0j)*tO!EDDwqPi>(NNl2koD8aDJ9*T#;f)~+EIvQv<3A?k92->1h z8gl8;ze4;I1P@+w^jfeG=t;bUUg~?v%w`?Ziw|Dj_kHhuGrKdJuhxh63Bv#t2E2m- zQ!3WP0Oxuz2Qx4YH;KZ*^)w=Y5A?j?NLm{7kn|$FE!-@!#=`_o-)Ji(+(eyzk!&2FoQpQC`F-^=d%)+`u zk99`c2qwjRzksp#5sbQNEX_~+` zkdvCl!N)PZw-=dr#FodsfD2X{V1Oj`Fz9$GqhLY96K)Y$ApCwUD2r+z%t{;Iylro!>LlQ@ZC zeb&O>1m>N)M}8_jNm*6Vztv4_(3-lxEe&s!QC8i*fja$vaTdi vK5TEYOiKSY5sWEJx+C3B>*{xh5|pKXfk-T*94T{%hWU@>;BGY82fF_jnty7X diff --git a/libft/ft_putchar_fd.c b/libft/ft_putchar_fd.c deleted file mode 100644 index b8a82d7..0000000 --- a/libft/ft_putchar_fd.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putchar_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/15 11:23:07 by fgras-ca #+# #+# */ -/* Updated: 2023/02/15 11:30:37 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putchar_fd(char c, int fd) -{ - write(fd, &c, 1); -} diff --git a/libft/ft_putchar_fd.o b/libft/ft_putchar_fd.o deleted file mode 100644 index 83d697d8f19e17e75e436ba0fab96e1b23732ad5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1400 zcmbVL&1(};5T8vy)mGEup-`!NX{lfy+0sMlp#(x~5cN>Vv4l;sF=96fo3}LeU=M}j zB0`V#=AYo%Q^A9J@xKr}^dh|k3DlY0H_7X3ymVmR%>3pvGn>Q0vnMIb0wxQ#U}!N4 zu#p<-xmeA?EX=^gy`{gUV)Uzcbe@iSQP_J|=oddc@4qkfzEGWF^fUVQn-Wfbe1+|N ze$!qpRl=qWZO0MoBAao-*mT~mt%>aVBL&AT@EJ!=BTpc2zbFBYaYon}GSU4+fc0hv ztZv#`oSB+F!Nv~|Cnn0!Q@EQxPUUAOYZyTGe~4xthd-C2++!m)Glzlm8XosT>>)DE zeU0j}+zw^6;RfY;O;q8E4g0|>=~2##N~GUP+`ml7RydtQI|+d39Qe|$pp-!(8>|K1 zo-3r+l^|-abU{=)9T3%)?|V(enl0%G+-;^K-Rf&)zifu09kkkBAP+#q6}(2d9=Luy zo|@w3!p2nE^`ucEr)=IMyD3(uMKowHIUPj(R0S?5{5DF0_~wk$ehKIA2-TQ;Rt#zO ze~f;rdDDCcbE#$)StssK^>yO@EH}}~x*qpYH#FUheTu#*ykLpdmdh{T569IQn(v8ggTMAcU1JPFf bmj_6qD0qO<|K7YkIlrsGy+LH6nEC$zMnZDy diff --git a/libft/ft_putendl_fd.c b/libft/ft_putendl_fd.c deleted file mode 100644 index 9f65fcc..0000000 --- a/libft/ft_putendl_fd.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putendl_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/15 13:33:49 by fgras-ca #+# #+# */ -/* Updated: 2023/02/21 10:19:05 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putendl_fd(char *s, int fd) -{ - int i; - - i = 0; - if (!s) - return ; - while (s[i]) - { - write(fd, &s[i], 1); - i++; - } - write(fd, "\n", 1); -} diff --git a/libft/ft_putendl_fd.o b/libft/ft_putendl_fd.o deleted file mode 100644 index 9a22a40fd946aa0042e87029f071b3e61d709ef0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1616 zcmbVM&ubG=5S~qITQzB;cn~VO2NebTNJ==y*u2F?s2(Ch z2!;GLf_f=GSok`{;ug^VoU@|k`n{Q_J%_DEzM-LO01xhTq2h&KQ z0R6<&cSf!Qi;#lfOPBxVz0P;9{nPe3JA+PiuU&*x;O!<8 zUH9N4HSjv$I{O1kY`a5C%dz@P@8RuU^ktH{o1(NS;n3=R{d@*sJ(s&{-^drEnvCph zR;-E4N;VpW+1IP9BC~drVSrhzkVZX)y8bv1_&Ixo&7hK87#px&ZGg3%ww9Cg3q73k z65^yJE&6d6)9(_w)Lf#083e=&ec~+qI*L1;iM?T(g{C_$=P*34<&S1S>N-3cONDV-H{FfG8;qOzHsh49JrMxWY*nRS zL@UFw-Bex}Z23Y4+Y&_Cmp+JMvk4-skAqUZS`BJ=R;$ZE;I3Ah(l5Q>_-QQ?jj-Mb zLfJwNRSGr>mC&z_K8vS0xv`N-yPGpgI2^0{SI3mA%Q6OZM~)7n|A!Mj#?PW9NIjv8 zj9+J5y-SASgK`XO_P>SaRP&_#EOM#lv0Y-U`kT1f{|@srXm$C-0nMk2;w$?A50$Uy z{m=u=H*+`eY#!B|bHE&%tupHVRs0+ss%i2UxY2Eu$kyc3D~#K}!v)ozY5%8D6<^_T ty{VPM{d*LkBvGl4$)}p;?h%4M^RH2$3BwbF{%_*=Pk4Sg$s9W-{~x`}rSJd% diff --git a/libft/ft_putnbr_fd.c b/libft/ft_putnbr_fd.c deleted file mode 100644 index d71d21d..0000000 --- a/libft/ft_putnbr_fd.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putnbr_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/15 13:53:25 by fgras-ca #+# #+# */ -/* Updated: 2023/02/15 14:00:06 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putnbr_fd(int n, int fd) -{ - if (n == -2147483648) - { - write(fd, "-2147483648", 11); - } - else if (n >= 0 && n < 10) - { - n += 48; - ft_putchar_fd(n, fd); - } - else if (n < 0) - { - ft_putchar_fd('-', fd); - ft_putnbr_fd((n * (-1)), fd); - } - else - { - ft_putnbr_fd(n / 10, fd); - ft_putnbr_fd(n % 10, fd); - } -} diff --git a/libft/ft_putnbr_fd.o b/libft/ft_putnbr_fd.o deleted file mode 100644 index ba22b06adae360a72f269840e35cf74583eb6ce1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1872 zcmbu9&1(}u6u@VOq1fb`R>I5EMMLn{?AwO;R_r*b23k zsxSnhNB@L^{sH1avlSFQl;A!4p*o$Wou)P8h z`};jx^(cGip>LM~8kveQ{bn+o%^L1k&D~JlYJa#XtaKiNTw}Ui4_epUs>;^fKmFk! zY?W2qkE&8p%3+timWwaHdL9{!#ZSbCjvbE=5i&A7d`cTgrJX!=v{+1!>(NNe@yyt* z!9hJ54|7afVb390J7A4mND-BgGBRLsccg=!(-Xq0(djNI-7W({h2tW`gSvof3(0tk+ z%TDN-CX?K-r>VtJX3E46QTGT};Jm!Es%_RK$~m4P?ppAR5^t0E^=7e=9QTQJ`gcyoPP%_kuP{qZ*2IO_g_H+1m}Q#{P|eZKYKuAoc|!4uPnT5 T1MLPaDE|_Nv=LcX{P}+YPZ +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/15 12:29:14 by fgras-ca #+# #+# */ -/* Updated: 2023/02/15 19:02:37 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putstr_fd(char *s, int fd) -{ - int i; - - i = 0; - if (!s || !fd) - return ; - while (s[i]) - { - write(fd, &s[i], 1); - i++; - } -} diff --git a/libft/ft_putstr_fd.o b/libft/ft_putstr_fd.o deleted file mode 100644 index 1d149a0cd2ab75ddee5bed081c35dd93d6c8210a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1456 zcmbVKPiqrV5TD)F)<3C@;z6j&f+7m`ku5z)5ebI1i--py#}YQ_#){1!cHh#p5IsbM z5QKgT@e_FPRPa!}Nbuwbh_FyE;zcA-XEtx>%Qhf%U@|kmncvLI%)W9SKQs*kSPZxi zM-ig{P4mdlCvG0*AOpYWul+5$-5+k}r{#9raW@+5J3}gPJM9?cgHC$@^4`IXo-=eS zeYfYt?%Ryna|R!2jNAR%-H)lf;|vY0#^}#~fY*D`=L2K+%O_YZ6jrQT#d1`ak!9Or zS>zV&C<*PCOG_fRd|ScP3uPKLi+T!m^+^%%`Fn&-p^{u088CL9g3-zv3z^x|yZE9j zh?A03>Bl*rePb5pX3RCLAYii4pP7bVhm*2X6E;e3yQtyGEX1y&Qtp^kWvLm-PzI&y zx~PC2!dCEH`Xh#;i1c4chleAv6i#Q47MR zA&5$&R`ctK)f>_mxZA~0dX*O{epZh}GiWsZKyHIbI`|u1JyfDYAhtuu4hsW z@+#&%a++#&S-^nylGj1>`>OD=!q1{5h)>S=O@;G!q{`tPJ1LuY3*MQ3ZFoP}wwp z4e?3$i`7HrTJ$Rj%G~WEB^H{^!TnXU_O2OgrXL* H`5*p2N=S>3 diff --git a/libft/ft_realloc.c b/libft/ft_realloc.c deleted file mode 100644 index 9fccdf1..0000000 --- a/libft/ft_realloc.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_realloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/15 16:31:35 by fgras-ca #+# #+# */ -/* Updated: 2023/12/10 13:59:12 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_realloc(void *ptr, size_t newsize, size_t oldsize) -{ - char *newptr; - - if (ptr == NULL) - { - return (malloc(newsize)); - } - if (newsize <= oldsize) - { - return (ptr); - } - newptr = malloc(newsize); - if (newptr == NULL) - { - return (NULL); - } - ft_memcpy(newptr, ptr, oldsize); - free(ptr); - return (newptr); -} diff --git a/libft/ft_realloc.o b/libft/ft_realloc.o deleted file mode 100644 index d09ef802c007edcd8c2e3595fa4b252047ccd023..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1608 zcmb_bL2DCH5S~qIQnih-cu*>`C#zzgN$EigyO(tX1wejQnciR$&IF;peFfzv?pjCbz$rWwaH`DEum;`i|V*iXkk@fra6xm>9eDB)Vbk ztmn~-cP%|DBWsAHA%ul@N%g!OV4K0+7^{Xd`oe99s`W~9?PZ+=68T3hv&HG?%l#IFQ!qjVA$a%y_ zNnX;ARV=;A)n@X!r&vKiw$Lso;m3Yfb|PcbMJ$}v@MIQZ=TPan(_$i!gOQ zUf&Ds28dqZAJ{eae79wbz}*NyJhB5DM5EUO;dDIDZ6nt11g^l_F7yK1d7|RS?ND_6 zPS^E=K8U1)ySCc&Z4Y1aKZuDv=+^XZx>QxbcjR39KQ@O6+HaK$lr_~-9;)~RTH^92 zcUIvS70%zWg5e`ODVv^u74y{dsQe0Ysb?8g7oJc3b>aDJmodq{Ubm+QnxC${jkyBq z*f)eR^G)=1;r%hzK!wYg(L%tK;kGRZdJZm i(v8ym;|fPJCVPs1Z4CW;*QYU`zCBUisON9}gZ~FSHnhqB diff --git a/libft/ft_reallocarray.c b/libft/ft_reallocarray.c deleted file mode 100644 index cc89e9a..0000000 --- a/libft/ft_reallocarray.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_reallocarray.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/15 15:52:29 by fgras-ca #+# #+# */ -/* Updated: 2023/12/07 11:46:15 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static size_t get_mul_no_overflow(void) -{ - return ((size_t)1 << (sizeof(size_t) * 4)); -} - -void *ft_reallocarray(void *optr, size_t nmemb, size_t size, size_t oldsize) -{ - size_t mul_no_overflow; - - mul_no_overflow = get_mul_no_overflow(); - if ((nmemb >= mul_no_overflow || size >= mul_no_overflow) - && nmemb > 0 && SIZE_MAX / nmemb < size) - { - errno = ENOMEM; - return (NULL); - } - return (ft_realloc(optr, nmemb * size, oldsize)); -} diff --git a/libft/ft_reallocarray.o b/libft/ft_reallocarray.o deleted file mode 100644 index a0b7cfdddc2f384fe2dc981090db314596098496..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1688 zcmbtS&1(}u6n`80p|v%!dJrm_lOJG*q*R0|5-72QUk4@7OIbGQrWH54?POLPp?WBm zE@grhKriCKB0_v`Gn1~%p7aN^@4er9zxQT#=2`Lfjg(=4 zh5^^%Akr+r^q~X45V{2zfQ zcDv1k;yzz5Hu=@!etiJFJ@Uk5zOvi|$u_A~$o{mOi@lrFl?U(n^DQ~tqTCJ+1_&p9 zJsUPkzr`NGJHB4p#TX}k;=xW>`(YcVCMPGd7fNN{m3}s#XX7k4n)kyn|8#7O<;E{6 z8lVRoXK?l6nz~zp6u=g7`uHc&Cm2uefw7b^Mh5#2zr+omMvfLCtSKJLtfnT1`fgzX za+JG9NyH2K=zMCmQ$Sn-=A15cLf)nHx7>qXkA*Bhbo?PeYPOH1zX4lu&{$YZ&rm>v%7owA18}qx?MVR6a^K$ zj*{rdU&07-^e+pzqF7TuE2qc-w4|jsN;uUqa1Jf;`rRuUK5Hjt +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/21 19:20:36 by fgras-ca #+# #+# */ -/* Updated: 2023/11/21 19:28:29 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcat(char *dest, const char *src) -{ - char *save; - - save = dest; - while (*dest) - { - dest++; - } - while (*src) - { - *dest = *src; - dest++; - src++; - } - *dest = '\0'; - return (save); -} diff --git a/libft/ft_strcat.o b/libft/ft_strcat.o deleted file mode 100644 index 0d90e86ca4028ddcbb9dd2b2be666ce986369555..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1304 zcmbtT&ubGw6n>lj@<(e{DYQ_L?MVeYB&CA%Py%7?9>hZ-Ae2%!>9z$;Qg&yd75o7$ zrNN6w!GFS2&jmsKDu1n<-3eN0J9zIS`e&yj!M@*d80L@Z;3WNZIt9?q zAG^#QxxMnf-{v0B-1CD=Ux^UT*1phkxxDDzt5nm5Oub@JEQrEfG3~LRJz;JL&NkT#cLFz>D4n&(5~W5C4XHm@7|==2p6^f zlhLjuu@TCUL^VlB)SC5r)Bx9L%1B@=bBPRVFBINtq+%y-?nJTNBN0b0LlJGSZ^mIg z>TdmCj~S?WMx)j$C58L%uQ2zTHVeRofxjz_r=kw_r@Dp$uW9Q$O7KVvRkZcb!1Mo8Qgt0Z zs)J4|;wmDaQ|mRKwKq#VrGL%FytKZp6 GZ2biYX?GI< diff --git a/libft/ft_strchr.c b/libft/ft_strchr.c deleted file mode 100644 index 482fac2..0000000 --- a/libft/ft_strchr.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/09 14:27:10 by fgras-ca #+# #+# */ -/* Updated: 2023/02/21 10:54:39 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strchr(const char *s, int c) - -{ - int i; - char *str; - - str = (char *)s; - i = 0; - while (str[i]) - { - if (str[i] == (char)c) - return (&str[i]); - i++; - } - if (str[i] == (char)c) - return (&str[i]); - return (0); -} diff --git a/libft/ft_strchr.o b/libft/ft_strchr.o deleted file mode 100644 index 45d8928fc8ca1eea737e965ca9f9a09acfd72dd3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1352 zcmbtT&r2Io5T1>{t(qu;f>P2`tLP&M3gSTmVRa9s6d}-y*v+~c&?K_^7NVd+TM8i; z{}fNsqtt_iUh*gOpdfe>1BPDOndH6X<*}#sgV~w+X1+JsH=8r_?Rvy8K*E4E=wy-w zup*r}-3-$(0x#ex`to+3DxZF zN-cAwW@KRS94}@Tc``zk9_Co=Ya}z; zANhnGM1+Ixv=<)#gjIV&ZhRCQCltOpi^RKp+vlE>_n6a(0pe6c(3+H00Wkll!0jA* z?zMbgM%*oPU^_Oqf#rN3m{Teg+#+(t5_cJ1%c9S1XJ6!d#ef}pr9;=_N5DMyz-DfK zd)KoIZgcd1J!Vi%chs+)k`{UU{Y6f_DqdkioZO$R{gi>`b^U9s)B65ZzkpggGl8Z; z&ZoKxIbZr^EXr8zdsY)A)_YB?4WM=H9`lCK#D$km|5UfIKxgXuX)$O;3WeA8ACRa2 zPg>Na`yuqxf*3+izf +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/14 16:57:42 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:10:27 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strcmp(const char *s1, const char *s2) -{ - while (*s1 && (*s1 == *s2)) - { - s1++; - s2++; - } - return (*(const unsigned char *)s1 - *(const unsigned char *)s2); -} diff --git a/libft/ft_strcmp.o b/libft/ft_strcmp.o deleted file mode 100644 index 10e7d0600991917294ff893295c74c2bf5864532..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1296 zcmbtT&r2IY6n-0jTQ#c)6_gTBt)N393gSTmVRb3RLrcJm=q6nibd#_<3sF!HiV(aM z{3rSs9D8vgE#NJ@4atk_s#C5^=>m|7$9N52J|w? z0+^{@oR7jhjKK@|nSS-FXg7Y?jq{G(2-{Di_LbE!aA_O%t<_04;kw1A;?P9bMrQ4v ze-p)Y^HGrL=0oFg;bHeHY!wRYnK#8!Sm9wNmt!j|yOax~GbXLI*Y^yd@taB*{iW~F9yg^4MF2pMh?J&Q;$0(^xTjAk&L)o=fFNX z+yPb!0$}B;=eZT+Dpl?>9LrL`o$|5B4=W+7`PG{1^HX5Hd*U$nXz##xJU2S}zm{24 z(~JhSUGgIDzQ4$+SH(Og#L4@UwL2MTUe~|II$htt>K9Q+Q`dhNk~QI_)Ac)8p#LW?8-%BShA +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/21 19:23:08 by fgras-ca #+# #+# */ -/* Updated: 2023/11/21 19:26:36 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcpy(char *dest, const char *src) -{ - char *save; - - save = dest; - while (*src) - { - *dest = *src; - dest++; - src++; - } - *dest = '\0'; - return (save); -} diff --git a/libft/ft_strcpy.o b/libft/ft_strcpy.o deleted file mode 100644 index 3e56cf7cd9e4d4d509b5134c406b94af43b51bd1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1288 zcmbtT&ubGw6n>lj)V6jNp+ZYZPb%0UDJ@73vJlp;P&^0$FQsncwt<=-?9M_{P!ASq z@Zz7)f1={CAow?Ul3WUfp2SP(rG77&NycGM`rys?-uK=&Z+0em?{7ZMISy%a=m`xo z%@R%KhOyTRJ({K|`aQdNRSr65LFesx&`G<&Cm-lvUd$ot&VF&3IC6sz{<(vt>-1?l zJWYRc={phNa_bvyluGOQ2jxoIkZHbH6sw}JTuggu@!iUbD6BqIG>;#JyYMmi#`7}a zc&E&bz}fEhft-UE5)%BwmLyBvDBc z64hqC9yP!G#vMjt(re_4iTd=lfUvBWQWg0^Bq`pX;XS`5MiQ{6&=_q6ptl;E)zDzx=4!SnyeQ*{kT>Y(=&aRbQb)OyWl u&1Q+K^shL9-GuWS*?QjBemhXqQu;Yg3{&)gxs51Gf2 +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/16 14:25:00 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:08:02 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -void ft_striteri(char *s, void (*f)(unsigned int, char*)) -{ - unsigned int i; - - if (!s) - return ; - i = 0; - while (s[i]) - { - f(i, &s[i]); - i++; - } -} diff --git a/libft/ft_striteri.o b/libft/ft_striteri.o deleted file mode 100644 index 3230bb5b537f267975a6909a38c1960f18fa2f72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1312 zcmbVL&ubGw6n?XHBGSL07a`DI#G3@_d%H8~Fzl%h-hS_W?|n0~^W&5A>ZQdPC}Z#f zE;7Xe*w#f{O~Wb_;5z&*-uvgd$#1uFX1mE&&rRYJx3kp)@$AUyQ{(B~uGe?FPS4#g zSX~E0@5D`hCP(MT9jDJ!k^L&}!}GZIE2|+?YaHXtH&)7+m#BR;pM4HoTinJ z)6={>^GMR^Vqh4dgnk8mcFqG_?g4Q_=w!Du0QTWEu#FO%D2!g+!5^JOo}6r+KF-b3 zSF3ho#G1nnBJz#)Xc+#S=T(PtcCd(zw=_PTi^Pj!Arj$=2*MTK(6el0I|KTk)MX05 zqs^x9>xd%Ea9Kqn*bu-ju_Y=nuk2ea(3qyaCk0QH zP@<`SgFL;Xs;n#6lMB5giED_oPNi3T-rOXyrT!fyXk+MfMy8&|HO~$y_$>8wzjTxI TfEvdrPybCeE)6=fz|{W-W^H){ diff --git a/libft/ft_strlcat.c b/libft/ft_strlcat.c deleted file mode 100644 index 4521530..0000000 --- a/libft/ft_strlcat.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/08 14:10:58 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:09:41 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcat(char *dst, const char *src, size_t size) -{ - size_t i; - size_t dst_len; - - i = 0; - if (!dst && !size) - return (0); - dst_len = ft_strlen(dst); - if (size <= dst_len) - return (size + ft_strlen(src)); - while (src[i] && i < size - dst_len -1) - { - dst[dst_len + i] = src[i]; - i++; - } - dst[dst_len + i] = 0; - return (dst_len + ft_strlen(src)); -} diff --git a/libft/ft_strlcat.o b/libft/ft_strlcat.o deleted file mode 100644 index 28bde98967c3e04da7a920db5cd4f883ab22b4d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1616 zcmbtTO=}Zj5S~qItF<3#@la`zfFO$POHz8!DiR25Uqn3!xd>7=acjVQl+7-tLiG@l zhFts!#s8pqED9FASn-mBhhBt;9wJ_X2=$rdeaU9KMbLrC%seyC%h ziI=n)kyW#0_{so2*>-5Xj?rIuo6 z(;2Vmda*=8EQIM+*xgzIaZ-G>G?zLXSX~Z>A|iw9S}a+X?tA#=~1=RHDYr z=+k)p+&%>Va0nh#IQGW7>xn3@7hEet0#DPmIqf-i z-V&}|aY@{@T#H1eTqcn%6$*9{Sh3{V0=JkiyH@tTitiOYvF4Q4Y{y+E(dl64R#qLW zVE1PJhZh5vZ!;9=kyNqXyG{rHYcojj9+SF2*`!*ERPhKbbM+@Ot?)An*WaCjX*M`W zC4%rAaPIl9`~M&**t1X&986(IS%C;1^LGm4$~*oYX0dy T^x&>1kq_RUDO-x4{|o;Q)Wpg| diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c deleted file mode 100644 index 55734e0..0000000 --- a/libft/ft_strlcpy.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/08 13:24:31 by fgras-ca #+# #+# */ -/* Updated: 2023/02/08 13:33:32 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcpy(char *dst, const char *src, size_t size) -{ - size_t i; - - i = 0; - if (size > 0) - { - while (src[i] && i < (size - 1)) - { - dst[i] = src[i]; - i++; - } - dst[i] = 0; - } - while (src[i]) - i++; - return (i); -} diff --git a/libft/ft_strlcpy.o b/libft/ft_strlcpy.o deleted file mode 100644 index 0578b325fc3d9a9c376a5cab4232762e25e8c162..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1368 zcmbVL&1(};5TCdG@}s6vJSY`ePb%0)QYusr5(sPGK|KhIxsyv3FhG}{93sB+ZX9Kksb_0njDJM?~6~~kSL;a&E#6Sr98E4;8&Oh#q#`SLO^tlU&EKI1fc9(@LV?U4`oH+zIlp_5%42Vnb;f$inl z;{4pHH#ndxh?A4Or5`Vsf8~_V%{nPE2*@^??KJ%So7J7ln0yY27YuxK7l}9JMl7S< zTC2@#MxoDjRYGesRtLc2c3lQlj4~R>ZJo(*PXd1y$N+dXj)B*j^?KMqtkIMq$MG!1 zGN|pSdaIG}R@7{Tk!%Bx!rg#}+Z&rvP!IJ}oIEa~lx8(+9Z^#CWDcsf-`Q)36Q=j5 zXz*1hRC6JUY5IQZo2KvA@isPfZu0(^g^}A_4|{Xy|Lvamis({q znElGGV~?n|-c|ZlLrbZxuOLR>Q3>6&zS3V(;AxEXoLaB(th-54QTnG;pq)Xd9oc$1 f*WMjM@LuUJQ(>5bC&+osvh+U`acjaHC$|0{lgE&R diff --git a/libft/ft_strmapi.c b/libft/ft_strmapi.c deleted file mode 100644 index 0178510..0000000 --- a/libft/ft_strmapi.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmapi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/16 13:38:52 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:04:43 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strmapi(const char *s, char (*f)(unsigned int, char)) -{ - char *result; - unsigned int i; - - if (!s) - return (0); - result = malloc(sizeof(char) * (ft_strlen(s) + 1)); - if (!result) - return (0); - i = 0; - while (s[i]) - { - result[i] = f(i, s[i]); - i++; - } - result[i] = 0; - return (result); -} diff --git a/libft/ft_strmapi.o b/libft/ft_strmapi.o deleted file mode 100644 index b420f237f9f7d99ffc211f49b233332812bb9c18..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1592 zcmbtTL2DCH5S~qHqqS|Kcu-O#phy+_NJ>vV$U<1Vi1nc4;GvXF+_qvi37cJLg{rV3 z4MFH%@E3R!PZALf-r`0210t+c5b;t(h%=jccC)SsIxv};Z|0j>W?mj@*RLiN1*9l& z1r8&L0vsd`eKl}Zn1V_8mOlHvq_;la(!I~KdTV=6Z@E3)+uj3r;w9C6^6*D*YnbTz z1n6Ez`Q^7XAB%l(Q$g|m?XK3RqJ7aW^#hjDOTU2ht6qDVVqbqcqqH@2mwT-bt?uCc zPSVr*%1HI&j{ABD_`1@28;tk$_R7J#H?UMJF6L%SWw++Ixk5oKi2Pi^4Z^~M`FW9F zxX3Vl2EZ6<2K5N)(v1?}8ajj}QAth>4Jh|-g0h)WvXiN!ySTvfh|h5DIazHw^CVH6 z8rQsJ;u#ik?oWnpFa}=-artD-g{HCaWC#ytB6bFqzCSAG5QxKJ%~@?awq-Q#ib^P8 zw`$hFGOE>jg&PXCv=h=FgP|;jaN3>3bBxn-3Oy+R(cH2eqm0(Ehjv4HwplfVV{SSi z?ih{%qTFnPsMIaXtRYsbJEp+f%rzaOa*yNnnkyQ1yak4+`mjm|5I5^(7sezz*gm@JiW1r2yqPD%~i`KgKwk5y|lUOC#v-yFP*W O= +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/09 17:12:38 by fgras-ca #+# #+# */ -/* Updated: 2023/02/14 13:26:15 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strncmp(const char *s1, const char *s2, size_t n) -{ - size_t i; - - i = 0; - if (n == 0) - { - return (0); - } - while (s1[i] == s2[i] && (s1[i] != '\0' || s2[i] != '\0') && i < (n - 1)) - { - i++; - } - return ((unsigned char)s1[i] - (unsigned char)s2[i]); -} diff --git a/libft/ft_strncmp.o b/libft/ft_strncmp.o deleted file mode 100644 index 658a0caa1126df1e2e03289d378e9fb4e431c1d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1392 zcmbVLL2DCH5S~qITQz25^iZitJZYhQB%wm|Ac3&<9n^!c;HA_}+_s>*S$5w-t5gpW zA>`sO@GAa+;4$by@f1Ae*ozqOqId~jbSC>=x>@$rfysRH&3x}|W_Dj1ckg604U}nc z8;&!@0(hBYT${ieWZ^9Q(Xae9dFMOt9FBM=JmMX5$UhrnYT@m}A%xivgnvHgZDXwQ zt~ugeW6ZUI-pljuy`w1mqW7TsF|5qg;Z;8@AR~KFfsDwZV#wPgjo&oJ{`*;l-s?w) zns~)my;snC-&O}(pJ20Izg4_$HbPf~#d4W#u+n-toTTL!l?p3utV)`m7GNGdkA4b$ z^S%lA_xr@np_5&V0%*@3fVQ94R@9YmxX&3qny z|4XaRrEDaJjfEILxr@X*VmlDN+jKnEj3w&aq6DHT+*3%{`vTZw zOIW}fK>)1Tava-5&TR>s;ds^qVKtw~eAf+`=eIoD7YD$6`>Dn3z3m;}a%}Y!Cyy&A zrCBW`j;P6eItQ62-{q^w6Q}kl+u(-+iI~)1!#b_;r1~|~(wQanxT*W89yfKriZ`&R zaJ=tA8ky2-Ah(DK`IU-%$-cZoi~{S(2wQ z(sL@k;?wRXi6`}sC_y`ePCH8K>D=V*kb;5KU!o*tlAbc>5vA#u +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/27 20:03:19 by fgras-ca #+# #+# */ -/* Updated: 2023/12/07 11:56:51 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strncpy(char *dest, char *src, unsigned int n) -{ - unsigned int i; - - i = 0; - while (src[i] != '\0' && i < n) - { - dest[i] = src[i]; - ++i; - } - while (i < n) - { - dest[i] = '\0'; - i++; - } - return (dest); -} diff --git a/libft/ft_strncpy.o b/libft/ft_strncpy.o deleted file mode 100644 index fe9533af9b3ee6165d16f758a99d76fdac5bec81..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1336 zcmbVL&ubG=5T3WKtv_m;N)Jj@;z*i#4Q&CECR&3l>IytNAPd6Zx0tA54UcXbi;Wpwx#HC7w zuk!M8B~HT1o0Sz_UcD({fN6Y50reE>+9Mb6XB-eVg-WuN8ep#;1KTOE;@s@%_c(yd zh?9~;blCHSJ*$3x#(Itw1mp|NZW@05&C5>ZOm-d%FKBpj7m+u`MkKCjrV)d29Q+Y(*_tq4=QtvuoH2;k2=;Q?<%5%6Za)$#+xg0}EEj%PU%Uh{>Fw}O~= z!gj|GMHhJJzx24jy|Ed3EnmIjMlh+U@OzlyY!AIp7*5qHu zJgxDh{9DMSo@G>B)cus#McuFLZA>a(ulueCns3(Hn43lYZ}%7vQAtY4nH}aQyN)U9 zY4X*hsu?x$O#Tx@>3>v9vf1%jKJ=o5&Y-1tD!#&V@5Z{S +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/11 14:31:40 by fgras-ca #+# #+# */ -/* Updated: 2023/02/21 10:08:36 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strnstr(const char *haystack, const char *needle, size_t len) -{ - size_t i; - size_t j; - - i = 0; - if (needle == haystack) - return ((char *)haystack); - if (!len && !haystack) - return (0); - while (haystack[i] != '\0') - { - j = 0; - while (haystack[i + j] == needle[j] && (i + j) < len) - { - if (haystack[i + j] == '\0' && needle[j] == '\0') - { - return ((char *)&haystack[j]); - } - j++; - } - if (needle[j] == '\0') - return ((char *)(haystack + i)); - i++; - } - return (NULL); -} diff --git a/libft/ft_strnstr.o b/libft/ft_strnstr.o deleted file mode 100644 index 65c6191c003d84ffe0e74e38726afe40c37e1d08..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1496 zcmbVL&ubG=5S~qHYPD_B;z6lsJgHzGNogS}N+7Ix2Y-MN=%v(6x@|$T37fars#T#@ z2)Xzt_z!p$Pg3fk9(&A5auHH;iFgTK;>_l~c856BRLNZgxv?bGd z#dpn~5hhOX#sew*j;%5W-pr`%h~G4u&l~^k-NpHxB=+u7Z<WAf`A)BAZ!dZ>? zXOVbatk#6!#*YUN<#golBThSg(5-Muyay$c>}_ zvwMu+N_`TsZow~h1(Q@7)PI!vj4nnT)Gs4P|D!CrZp*Uac}Y&-NzbYDiVvGjlBS&h pgaWiP=(MAtp85uNhZJPw{0kIlCfg2~8AM_Fs?=``D+eH`{|jb#y?Ouu diff --git a/libft/ft_strrchr.c b/libft/ft_strrchr.c deleted file mode 100644 index 4c09b3a..0000000 --- a/libft/ft_strrchr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strrchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/09 16:10:11 by fgras-ca #+# #+# */ -/* Updated: 2023/02/14 15:36:23 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strrchr(const char *s, int c) -{ - int i; - - i = 0; - while (s[i]) - i++; - while (i >= 0) - { - if (s[i] == (char)c) - return ((char *)(s + i)); - i--; - } - return (0); -} diff --git a/libft/ft_strrchr.o b/libft/ft_strrchr.o deleted file mode 100644 index ca0a633dacca8e9b28ce21e51f226f9c8914b8ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1328 zcmbVL&r2IY6n+y^f3#{+@nEr(^wb|T!$uUOhY|=|_fR|t0WYGPbv4p%BD=F-1lvQ3 z5OV3i;muR&QRtyP=2GY%pb*GOyofBc?z)0Q3#eP_XNq7WTnP)d;t940ZUmidb^yQ**MJ>l+5F_#_&0pq zQ=_RZ>>wi9=+4q``7fzDl5nHb*fx%|(-~D8B zx4OCG+n%dVaetggDc#kmwnS0p!+Vgq{w+R7o;Wo}*#;*n&`{UEz&efbzWO()r8N!o zxT*cA9yhhW!X+%KINtXsp2T9k*TmWw`kmQh{#R;p5*6s5>;@KSOuFtmc1QvJyJSxWFnmgSm_NoS PN&j0m?hZQ#fv*1#tf_w} diff --git a/libft/ft_strstr.c b/libft/ft_strstr.c deleted file mode 100644 index 59afb4c..0000000 --- a/libft/ft_strstr.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/14 20:54:44 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 21:08:57 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strstr(const char *haystack, const char *needle) -{ - const char *p; - const char *beginning; - const char *n; - - p = haystack; - if (*needle == '\0') - return ((char *)haystack); - while (*p != '\0') - { - if (*p == *needle) - { - beginning = p; - n = needle; - while (*p == *n && *n != '\0' && *p != '\0') - { - p++; - n++; - } - if (*n == '\0') - return ((char *)beginning); - p = beginning; - } - p++; - } - return (NULL); -} diff --git a/libft/ft_strstr.o b/libft/ft_strstr.o deleted file mode 100644 index ffe71d1a8ed30744f3951dd1da1121f80357ad3a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1392 zcmbtT&ubGw6n>l5wDyOIMO3Jkc+!F$l2V~~kcF^z58^=xcnNhAw=HOXusaKBp^6xU z;KhH#tB2w-=v{j3KOjVUiFzqs^n06`WL);7kGy%```-IzCi9Y)&V&0I%OY(S-J?mS zS)z7kg6$aEv_SLpGq>`q;`Y9}y~7i?7ahBA9YkkRT5YfI;pkuS%Pr zqAD}!K4S`Tcsl34b_N!fp*86qVk2~42E(x1m-C|{Z~tY?Mp?kK)9bv(SBSTY&*a8e zANktV&$Lx8-!0s#)S{-03Z;_R5XH4p6sM&Z>+7Ppv8rhFPs8)@bMUQ)6~Z(0nVW*M zT^a?l4jz%!$y>_{GqdmTfY-pYvwh&jxsZR8DKBO-@6o|Ty7Ajj)A!$L)v1)pETVDA z;N!Dcyd$?m8Q>%86HHX#8jQzjjFd=(`wi*U5M?lmdm2f@GNVg^y<%4zT1pMJ7~52K<<+W{O6wV_qKNeui?i>|JSk%HNR0dv5T$p@%L9b z_nLMC33GaWy7ohZL`>>$qR!*{SN&~hdCwx;G<`nTP1EP=cn3v|&Ayd1GNso6Hv|7` z_Q(rLUjQ~O`BSZ;$gN4et@N9w7&xha437UlHr%wK(qC2Nc|^Xa)@wfPY?gGC{s||r mIXKTKspox@vjasZN`HkD!xTMcE&`?LXVru3jyp#nss973P@F{o diff --git a/libft/ft_strtok.c b/libft/ft_strtok.c deleted file mode 100644 index ba4583f..0000000 --- a/libft/ft_strtok.c +++ /dev/null @@ -1,83 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtok.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/11/14 17:14:45 by fgras-ca #+# #+# */ -/* Updated: 2023/12/07 11:41:34 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static char *init_str_and_lasts(char **lasts, char *str) -{ - if (str == NULL) - { - str = *lasts; - if (str == NULL) - return (NULL); - } - else - { - *lasts = str; - } - return (str); -} - -static char *find_token_start(char **lasts, const char *delim) -{ - int ch; - - ch = **lasts; - while (ch != '\0' && ft_strchr(delim, ch) != NULL) - { - (*lasts)++; - ch = **lasts; - } - if (**lasts == '\0') - { - *lasts = NULL; - return (NULL); - } - return (*lasts); -} - -static char *find_token_end(char **lasts, const char *delim) -{ - int ch; - char *str; - - str = *lasts; - ch = **lasts; - while (ch != '\0' && ft_strchr(delim, ch) == NULL) - { - (*lasts)++; - ch = **lasts; - } - if (**lasts != '\0') - { - **lasts = '\0'; - (*lasts)++; - } - else - { - *lasts = NULL; - } - return (str); -} - -char *ft_strtok(char *str, const char *delim) -{ - static char *lasts; - - str = init_str_and_lasts(&lasts, str); - if (str == NULL) - return (NULL); - str = find_token_start(&lasts, delim); - if (str == NULL) - return (NULL); - return (find_token_end(&lasts, delim)); -} diff --git a/libft/ft_strtok.o b/libft/ft_strtok.o deleted file mode 100644 index 9dc26af1509abadcac4c5efd440b79871af22c55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2296 zcmbtWO=uHQ5S~qIqqa4%NKqO0o-SF)E~r zODTBl!JAjl(vt)WExma3;HeiOP!AD<1PR8Ox9=sJZK?$a-kX_ke%`#9x3JHm5AOLS z2?R+n0WD3S06S+|a)gNy=!ZV|5g7gzQ|+&+U8t$HRZ)wD3RqXv&1g;C1l5jmWMGGa zjslJ$R#ELBij}$DW`g238IzPT$st$XR|40EbRvDQ{=u-ScTyS=Awv1w5cW`8#ttn^}`2A1Es@C0VS z3Ap{NPJV;O{l1{z!7jFLdTMH1z7dOChH1&+urj8EM#2_T!%s&?mC)Et4zo^o;~vCC zg-t(J2&k~OGj<%-#ZPWgQa3sc?_MCHoV>-6eH_{E?8^;U?baniK2&WsjQ$MOc zmp{8BVlu~t&hCa-nB$+26R|rXkKmGA`KdQVDlY1~mu3(cz=(Ca2$JXlESmE{sqOH7;BjO6@^mNRp(xP&5FbpzeBtmy`HBMHn)3GpggQg}oKwUpfIVpMc94PegfW35sw*;FDZm@Zh4~&po*4A1JxCw5i3BWA_+O z2`Q_uXo{)lO;D1WseuyDYf(rMj5%*dF!g5SglHZ-x!^~Z*#tY$N-de&S6g=NrF z^NU$6t@8^0kI5KLt?KcliE#ZV@1rn#R2V`7%_<@sIA7&YJkRy>$SGF5$IBeQ&T;Ym za~N*Bha*7l>r&wsDwNY3e}~75^F)kSr|*dB3JC|!MLgwqleoX&<7gDJ+b?;_`tM_q zAD7oX#R1u!6lHJyam46+Z~Q9`Z2u#E4(*-hSLX9u;PEs+I$NAC=GWpC!db-d!H|EH|DVoCJI{{fS`fIk2L diff --git a/libft/ft_strtol.c b/libft/ft_strtol.c deleted file mode 100644 index 374a1ca..0000000 --- a/libft/ft_strtol.c +++ /dev/null @@ -1,115 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtol.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/01 14:00:32 by fgras-ca #+# #+# */ -/* Updated: 2023/12/07 11:56:12 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int skip_whitespaces_and_sign(const char *str, int *sign) -{ - int i; - - i = 0; - while (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r')) - i++; - if (str[i] == '+' || str[i] == '-') - { - if (str[i] == '-') - *sign = -1; - i++; - } - return (i); -} - -static int determine_base(const char *str, int *base, int index) -{ - if ((*base == 0 || *base == 16) && str[index] == '0' - && (str[index + 1] == 'x' || str[index + 1] == 'X')) - { - *base = 16; - index += 2; - } - else if (*base == 0) - { - if (str[index] == '0') - *base = 8; - else - *base = 10; - } - return (index); -} - -static int check_base(const char *str, int *base, int *sign) -{ - int i; - - *sign = 1; - i = skip_whitespaces_and_sign(str, sign); - i = determine_base(str, base, i); - return (i); -} - -static long convert_strtol(const char *str, int base, int sign) -{ - long result; - int digit; - - result = 0; - while (*str) - { - digit = 0; - if (*str >= '0' && *str <= '9') - digit = *str - '0'; - else if (*str >= 'A' && *str <= 'Z') - digit = *str - 'A' + 10; - else if (*str >= 'a' && *str <= 'z') - digit = *str - 'a' + 10; - else - break ; - if (digit >= base) - break ; - if (sign > 0 && result > (LONG_MAX - digit) / base) - return (errno = ERANGE, LONG_MAX); - if (sign < 0 && result < (LONG_MIN + digit) / base) - return (errno = ERANGE, LONG_MIN); - result = result * base + digit; - str++; - } - return (result * sign); -} - -long ft_strtol(const char *str, char **endptr, int base) -{ - int sign; - int i; - long result; - - if (base < 0 || base == 1 || base > 36) - { - if (endptr) - *endptr = (char *)str; - return (0); - } - i = check_base(str, &base, &sign); - result = convert_strtol(str + i, base, sign); - if (endptr) - *endptr = (char *)(str + i); - while (*str) - { - if ((*str >= '0' && *str <= '9' && *str - '0' < base) - || (*str >= 'A' && *str <= 'Z' && *str - 'A' + 10 < base) - || (*str >= 'a' && *str <= 'z' && *str - 'a' + 10 < base)) - *endptr = (char *)(str + 1); - else - break ; - str++; - } - return (result); -} diff --git a/libft/ft_strtol.o b/libft/ft_strtol.o deleted file mode 100644 index 2d52685d67dd853f099c9457b929c2c840e3b3dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3008 zcmbtWZ)jUp6u+3dZ4fS8Q*=IY7qum(M^4vwNlwqb!N0z3qYi*m<dF`C>{Id<3#*}F6G%KGJ%Gi8US@#Ro&stbB``z>4Ujc6a%I(=4w-f6b zqe#|#W6CIMX`{%)S)Mj>T+4dCWT$*qt_EvLw$@-R$>kdCm{rT`NVL`PIuiSkaXrI! zAo3O$ZdBZ}fO~G)flaWs(rjVb+V5zof;VwCZEQMMF32l)CQcJ}l`jrx;3;^@I#>^W zIpL*X8RkV1QpRROzFVb99IX?(*0y#g$W=?W(-o4y=K;mJvmf~ zf97^3H+gqw$2N-TK#`~W*Fl5fdot`ugHgO$E<|e6M^Wv>h8~<%bpE0&c zrvTKnCzB5-wP)^tR6SoWr*fUPv7JAsjQ%q3d^PU`@pQ$z=y~Utitsa@E8mrmBJNAz zr;Y8C#)fC{GuTqI>nwQ^2({)q^%XM5k7Uz<4IaM5-{*h)$$N}K@?Z{ZmSJrautdzy zP=M)P3UHNwMHI+98Z7*OBmcYPKU?kZ@YsAFo*VG=e2VtlD^3_K%WWJ}MvlgU3Uzte zv+xZno!6Eyf0AESa6byZhUv@Nfz=_NZhW*IDJV=A#(i~RdCH3|RnV*^u|JYL%u};j zCI%EgBQ)FgUZ-2#ZbX~-Vj#yC`&W@32GQu7f71kPrUN+yNcUru?_dmfJt% zc3?-oEfLmp`4faH4JBAB2!+@3-hP+vg|JThA5v=1T&q;krp19Dk)&rO`JyuWlO^W) zYUVA6c~mhkCZAF2%-o5}nAZez?qR~@PmXScI-)9@h}j_nlTkT2*_vR^CN zUnLxJjvgg@f64w9;gHwq!>sJPMl>Q&?hnWaiC5WQ6L!Z^`y^^3yR%bkp?4;0wY1>a zP=Skg1@^ea)mgkFu%{&ciVP**4cOBX|6JnYoq!EsQT^Q#0&oC%+hileI|3WSs>f%; zRxobGtmwENX7RDn$>5tKqm~(;428{jFccXI#z!wj*pO+Nv5C=$85|77O%@(8!(&p7 zM&2-EDhLY(%~&iF4UR{{A!{@mDaVH?ZiV0$9vKS`hepT6)t4|hBs4pFv5NGmf@J>% zzd}R^ZTDa)z7IMHxk*=X_KRm3S9QPW!d2bpUAU_IM=o5|m+A582`e;+9aR+jh|*%_ zcu2R*DU0btAuGi6!FZhM;poJK837iFTBeTQPKPLqJYR|=^vPIs5+$8xx`<$o1czgx z2~*zS|7||F(?JVZ`R#AKrAZ diff --git a/libft/ft_strtrim.c b/libft/ft_strtrim.c deleted file mode 100644 index a162893..0000000 --- a/libft/ft_strtrim.c +++ /dev/null @@ -1,52 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtrim.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/14 16:30:26 by fgras-ca #+# #+# */ -/* Updated: 2023/03/13 14:12:41 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int char_in_set(char c, char const *set) -{ - size_t i; - - i = 0; - while (set[i]) - { - if (set[i] == c) - return (1); - i++; - } - return (0); -} - -char *ft_strtrim(char const *s1, char const *set) -{ - char *str; - size_t i; - size_t start; - size_t end; - - if (!s1) - return (0); - start = 0; - while (s1[start] && char_in_set(s1[start], set)) - start++; - end = ft_strlen(s1); - while (end > start && char_in_set(s1[end - 1], set)) - end--; - str = (char *)malloc(sizeof(*s1) * (end - start + 1)); - if (!str) - return (0); - i = 0; - while (start < end) - str[i++] = s1[start++]; - str[i] = 0; - return (str); -} diff --git a/libft/ft_strtrim.o b/libft/ft_strtrim.o deleted file mode 100644 index 76c9893166e5f4c3baa993d0a8ea7bfab4dce328..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1880 zcmbtS&1(};5PzF~X>FS*Jrr9sD1Om)O-d1IMFM5*QbbB6;H893+?rxO%4Szuq4kg| z4W;0p(Z8VdRDzWjy_l2qn2Qi?4-qdxg!r46_vmJulMcL{ncvL(X5PGgqdk7)Qxqme zVGr46Ax?feCBDxXr3=BF1{Lut}$Gi&pC&Q%iJ14ensD!MQ*gh$K2`(04oa& zON(M@AN)JYhL7h?YE=tefKrxHI>7z0*iZXxdTMGScsm+*GPV;8ht+X4G#Yle8(te5 zQ$yo-1Wc_V^o#+V4xH&HQRZW;NLU*VNq<8z<@Fp>mIKOQPuIEk*!K`{IwVi&qxA*e z`KEe1eKW{t#2ye18Kzg3@wRIUPvDWWA4+X!KkH{BG!sRer4O#ph4Wc}UB5+l zU^j5+zFxTtpcT#*>{!mWY-=&CCRieASh2-SEN9xTfG|^LhNX>EDw_b;N6~ +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/13 15:40:49 by fgras-ca #+# #+# */ -/* Updated: 2023/11/14 17:07:20 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_substr(char const *s, unsigned int start, size_t len) -{ - char *new_s; - size_t i; - size_t j; - - new_s = (char *)malloc(sizeof(char) * (len + 1)); - if (!s || !new_s) - return (NULL); - i = 0; - j = 0; - while (s[i]) - { - if (i >= start && j < len) - { - new_s[j] = s[i]; - j++; - } - i++; - } - new_s[j] = '\0'; - return (new_s); -} diff --git a/libft/ft_substr.o b/libft/ft_substr.o deleted file mode 100644 index 44b71b53fdc84c3f9a83ef9b289a928acbd89fca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1520 zcmbtT&ubG=5T2LTrfOqj5foa=f*@7wBPl)93bGK^K14kTIZD~Ytp)R=?7oFms2(EX zl8gU^*Pe>UfMBAh9(u?>AO!TV;w6YsXOj2qX1gHh!0gO?GvB9+LdVzl=f?`*+tgdLbnFu<4suqDY5Y4?F z$TXS(`04iqf31m*H7e*>;SgDCSx4fQ)pu`Tk5JsUx}G6g#U4g|!45_1!2rWhu+Osx z@FpdiR><(vXOSYzylVRgh+r)?VTT{_3N35!=>u#O3hTyFvE%b&x7WEA3#=|1u7}|tQppsk~8DP&J0c&L0{7icKEe>!2aZ-|f`dAmT zuTzE0RO%g85Rfc1`$_nIoRpnN*h~fs=OXyo-PWG#RBSGth6Mh^mNxK`=K(L*t5v6l zSgkG{jx$~Mq+Ncd;-@vA@3{3H$CbOlhaH^l%`MliI_d`hXAGp%jHhC4Ocm?->2&V8g&8neXQSmvn#MP_T_%(&=_oK=o)K1LC&%cRz>iMtyJaVaL4mB$JeCi(+ zeZIEqnACo>ZXpRwsJ(|+8g=XqVQeVAfqqo<{4`cVhf3poQ}Neyp|WxQW5kp8x0J9y y;%dI$U((rhR70KLpaA7OD(xuFKdW#wV-hO<;uv~*))z4!-#t-Gb^pp=_`d-e4W-@y diff --git a/libft/ft_tolower.c b/libft/ft_tolower.c deleted file mode 100644 index b7378bb..0000000 --- a/libft/ft_tolower.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_tolower.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/09 14:09:59 by fgras-ca #+# #+# */ -/* Updated: 2023/02/14 13:36:02 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_tolower(int c) -{ - if (c >= 65 && c <= 90) - c += 32; - return (c); -} diff --git a/libft/ft_tolower.o b/libft/ft_tolower.o deleted file mode 100644 index cb388e5423f42a5879279aa8efe0a98ca17f2d5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1256 zcmbVL$w~u35Uq)E-=cU>6d6w{Xp@M7c#wfG>OnjRK@r4E;+TLYBQqUbzy$Rfi=xN{Z1ajW*dTitzu)pUBvp33AZWm&OPDKRgSv#ClArY`5^L~?#w z(Y0CQI400r(N{Mz5CeE7t_7WJs2;#N-vsM4VU6~*cRb?W#*il`vuSYq61TB*Z`&3& z5dOpHSaEp&YF2J(aua>nIH>V93lHR;432^mKNNXr04{SMo`=rVFcF=Vq?ZE`$*>-a zoJs#wg4p+@2O<|mAo4+}fAuq{r8$%6x@8rhx^BEa z#|12MuJ=9YK+DZu7i;b4zuq44qte(aaxlNyT`bU?rv6C@7FnpGsozGP{v$`#ITY1K zhZWI@k@m@Y=9{fek~bRAvb7PQ3nRUesi%3(w G>c0W!x?K|h diff --git a/libft/ft_toupper.c b/libft/ft_toupper.c deleted file mode 100644 index 102da50..0000000 --- a/libft/ft_toupper.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_toupper.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/08 16:02:00 by fgras-ca #+# #+# */ -/* Updated: 2023/02/14 13:36:40 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_toupper(int c) -{ - if (c >= 97 && c <= 122) - c -= 32; - return (c); -} diff --git a/libft/ft_toupper.o b/libft/ft_toupper.o deleted file mode 100644 index 5afb2bc88ef150465921c3c713836c2743ef960f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1256 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 +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/02/12 10:46:53 by fgras-ca #+# #+# */ -/* Updated: 2024/01/15 21:07:07 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LIBFT_H -# define LIBFT_H - -# include -# include -# include -# include -# include -# include -# include -# include -# include "../cub3d.h" - -typedef struct s_list -{ - void *content; - struct s_list *next; -} t_list; - -int ft_isalpha(int c); -int ft_isdigit(int c); -int ft_isalnum(int c); -int ft_isascii(int c); -int ft_isprint(int c); -int ft_toupper(int c); -int ft_tolower(int c); -int ft_strcmp(const char *s1, const char *s2); -int ft_strncmp(const char *s1, const char *s2, size_t n); -int ft_strcmp(const char *s1, const char *s2); -int ft_memcmp(const void *s1, const void *s2, size_t n); -int ft_atoi(const char *nptr); -int ft_lstsize(t_list *lst); -void *ft_memset(void *s, int c, size_t n); -void ft_bzero(void *ptr, size_t len); -void *ft_memcpy(void *dest, const void *src, size_t n); -void *ft_memmove(void *dest, const void *src, size_t n); -void *ft_memchr(const void *s, int c, size_t n); -void *ft_calloc(size_t nmemb, size_t size); -void ft_putchar_fd(char c, int fd); -void ft_putstr_fd(char *s, int fd); -void ft_putendl_fd(char *s, int fd); -void ft_putnbr_fd(int n, int fd); -void ft_striteri(char *s, void (*f)(unsigned int, char*)); -void ft_lstadd_front(t_list **lst, t_list *new); -void ft_lstadd_back(t_list **lst, t_list *new); -void ft_lstdelone(t_list *lst, void (*del)(void *)); -void ft_lstclear(t_list **lst, void (*del)(void *)); -void ft_lstiter(t_list *lst, void (*f)(void *)); -size_t ft_strlcpy(char *dst, const char *src, size_t size); -size_t ft_strlcat(char *dst, const char *src, size_t size); -char *ft_strrchr(const char *s, int c); -char *ft_strtok(char *str, const char *delim); -char *ft_strnstr(const char *haystack, const char *needle, size_t len); -char *ft_strdup(const char *s); -char *ft_strstr(const char *haystack, const char *needle); -char *ft_substr(char const *s, unsigned int start, size_t len); -char *ft_strtrim(char const *s1, char const *set); -char *ft_strmapi(const char *s, char (*f)(unsigned int, char)); -char *ft_strncpy(char *dest, char *src, unsigned int n); -void *ft_reallocarray(void *optr, size_t nmemb, size_t size, size_t oldsize); -void *ft_realloc(void *ptr, size_t newsize, size_t oldsize); -char *ft_itoa(int n); -char *ft_strcat(char *dest, const char *src); -char *ft_strcpy(char *dest, const char *src); -t_list *ft_lstnew(void *content); -t_list *ft_lstlast(t_list *lst); -t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); -long ft_strtol(const char *str, char **endptr, int base); - -#endif diff --git a/main.c b/main.c index 076576f..ab59b75 100644 --- a/main.c +++ b/main.c @@ -6,13 +6,14 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 18:45:52 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 22:39:18 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 15:11:41 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "cub3d.h" -int setup_and_load_map(int argc, char **argv, t_structure_main *w, t_texture *textures) +int setup_and_load_map(int argc, char **argv, + t_structure_main *w, t_texture *textures) { if (argc > 2) { @@ -32,7 +33,7 @@ int setup_and_load_map(int argc, char **argv, t_structure_main *w, t_texture *te return (1); } -void init_structure_main(t_structure_main *w) +void init_structure_main(t_structure_main *w) { if (w == NULL) { diff --git a/map.cub b/map.cub index e5c694d..d74c3d2 100644 --- a/map.cub +++ b/map.cub @@ -7,7 +7,7 @@ C 165, 176, 196 11111111 11111111111 11111111 11111111111 11111111111111111111111111111111111 111111000001110000000001110000001 10000000001 10000000000000000000000000000000001111111111111111111111111111 -1111100000000000000000000000200000001 10000000001 10000000000000000000000000000000000002000000000000000000000001 +1111100000000000000000000000000000001 10000000001 10000000000000000000000000000000000002000000000000000000000001 1000000000000000000000011111111111111 10000000001 10000000000000000000000000000000000002000000000000000000000001111 100000000000000000000001 10000000001 10000000000000000000000000000000001111111100000000000000000000001 100000000000000000000001111111111111111111000000000111110000000000000000000000000000000001 100000000000000000000001 diff --git a/move/ft_collision.c b/move/ft_collision.c index 0d1e6f9..9b600c3 100644 --- a/move/ft_collision.c +++ b/move/ft_collision.c @@ -6,29 +6,54 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 14:09:52 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 20:43:43 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:43:10 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../cub3d.h" -int can_move_to(t_structure_main *w, double future_x, double future_y) { - int map_x, map_y; +static int check_collision(t_structure_main *w, double future_x, + double future_y, t_collision_params *coll_params) +{ + int i; + int map_x; + int map_y; + char map_position; - // Vérification manuelle de chaque position autour de la future position - int dx[] = {0, 0, -COLBUF, COLBUF, -COLBUF, COLBUF, -COLBUF, COLBUF}; - int dy[] = {-COLBUF, COLBUF, 0, 0, -COLBUF, -COLBUF, COLBUF, COLBUF}; - - for (int i = 0; i < 8; i++) { - map_x = (int)((future_x + dx[i]) / w->s_map.mapS); - map_y = (int)((future_y + dy[i]) / w->s_map.mapS); - char map_position = w->s_map.map[map_y * w->s_map.mapX + map_x]; - if (map_position != '0' && map_position != '3') { - printf("Collision détectée à x = %d, y = %d\n", map_x, map_y); - return 0; // Collision détectée, ne peut pas se déplacer - } - } - - printf("Pas de collision, peut se déplacer\n"); - return 1; // Pas de collision, peut se déplacer + i = 0; + while (i < DX_LENGTH) + { + map_x = (int)((future_x + coll_params->dx[i]) / w->s_map.map_s); + map_y = (int)((future_y + coll_params->dy[i]) / w->s_map.map_s); + map_position = w->s_map.map[map_y * w->s_map.map_x + map_x]; + if (map_position != '0' && map_position != '3') + return (0); + i++; + } + return (1); +} + +int can_move_to(t_structure_main *w, double future_x, double future_y) +{ + t_collision_params coll_params; + + coll_params.dx[0] = 0; + coll_params.dx[1] = 0; + coll_params.dx[2] = -COLBUF; + coll_params.dx[3] = COLBUF; + coll_params.dx[4] = -COLBUF; + coll_params.dx[5] = COLBUF; + coll_params.dx[6] = -COLBUF; + coll_params.dx[7] = COLBUF; + coll_params.dy[0] = -COLBUF; + coll_params.dy[1] = COLBUF; + coll_params.dy[2] = 0; + coll_params.dy[3] = 0; + coll_params.dy[4] = -COLBUF; + coll_params.dy[5] = -COLBUF; + coll_params.dy[6] = COLBUF; + coll_params.dy[7] = COLBUF; + if (check_collision(w, future_x, future_y, &coll_params) == 0) + return (0); + return (1); } diff --git a/move/ft_key.c b/move/ft_key.c index 0314654..569edce 100644 --- a/move/ft_key.c +++ b/move/ft_key.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 14:17:56 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 18:45:14 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:53:45 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,7 +41,7 @@ void adjust_player_angle(t_structure_main *w, int key) if (key != 65361 && key != 65363) return ; - angle_adjustment = 4 * (PI/180); + angle_adjustment = 4 * (PI / 180); if (key == 65361) { w->s_player.pa -= angle_adjustment; @@ -67,27 +67,28 @@ void handle_movement_keys(int key, t_structure_main *w) int deal_key(int key, t_structure_main *w) { if (key == 65307) - { kill_prog(w); - } else if (key == 65361 || key == 65363) - { adjust_player_angle(w, key); - } else if (key == 65362 || key == 65364 || key == 114 || key == 102) { } - else if (key == 101) //e door + else if (key == 101) { - printf("Touche 101\n"); - if (w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7)/w->s_map.mapS) * w->s_map.mapX + (int)((w->s_player.px + cos(w->s_player.pa) * 7)/w->s_map.mapS)] == '2') - w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7)/w->s_map.mapS) * w->s_map.mapX + (int)((w->s_player.px + cos(w->s_player.pa) * 7)/w->s_map.mapS)] = '3'; - else if (w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7)/w->s_map.mapS) * w->s_map.mapX + (int)((w->s_player.px + cos(w->s_player.pa) * 7)/w->s_map.mapS)] == '3') - w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7)/w->s_map.mapS) * w->s_map.mapX + (int)((w->s_player.px + cos(w->s_player.pa) * 7)/w->s_map.mapS)] = '2'; + if (w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7) + / w->s_map.map_s) *w->s_map.map_x + (int)((w->s_player.px + + cos(w->s_player.pa) * 7) / w->s_map.map_s)] == '2') + w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7) + / w->s_map.map_s) *w->s_map.map_x + (int)((w->s_player.px + + cos(w->s_player.pa) * 7) / w->s_map.map_s)] = '3'; + else if (w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7) + / w->s_map.map_s) *w->s_map.map_x + (int)((w->s_player.px + + cos(w->s_player.pa) * 7) / w->s_map.map_s)] == '3') + w->s_map.map[(int)((w->s_player.py + sin(w->s_player.pa) * 7) + / w->s_map.map_s) *w->s_map.map_x + (int)((w->s_player.px + + cos(w->s_player.pa) * 7) / w->s_map.map_s)] = '2'; } else - { handle_movement_keys(key, w); - } return (key); } diff --git a/move/ft_move.c b/move/ft_move.c index 1fa45b1..1fb81d7 100644 --- a/move/ft_move.c +++ b/move/ft_move.c @@ -6,70 +6,82 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 14:08:25 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 18:33:49 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 17:59:17 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../cub3d.h" -void move_forward(t_structure_main *w, int key) { - double future_px; - double future_py; +void move_forward(t_structure_main *w, int key) +{ + double future_px; + double future_py; - if (key == 119) { // Touche 'w' pour avancer - future_px = w->s_player.px + cos(w->s_player.pa) * w->s_map.mapS; - future_py = w->s_player.py + sin(w->s_player.pa) * w->s_map.mapS; - - if (can_move_to(w, future_px, future_py)) { - w->s_player.px = future_px; - w->s_player.py = future_py; - } - } + if (key == 119) + { + future_px = w->s_player.px + cos(w->s_player.pa) * w->s_map.map_s; + future_py = w->s_player.py + sin(w->s_player.pa) * w->s_map.map_s; + if (can_move_to(w, future_px, future_py)) + { + w->s_player.px = future_px; + w->s_player.py = future_py; + } + } } -void move_backward(t_structure_main *w, int key) { - double future_px; - double future_py; +void move_backward(t_structure_main *w, int key) +{ + double future_px; + double future_py; - if (key == 115) { // Touche 's' pour reculer - future_px = w->s_player.px - cos(w->s_player.pa) * w->s_map.mapS; - future_py = w->s_player.py - sin(w->s_player.pa) * w->s_map.mapS; - - if (can_move_to(w, future_px, future_py)) { - w->s_player.px = future_px; - w->s_player.py = future_py; - } - } + if (key == 115) + { + future_px = w->s_player.px - cos(w->s_player.pa) * w->s_map.map_s; + future_py = w->s_player.py - sin(w->s_player.pa) * w->s_map.map_s; + if (can_move_to(w, future_px, future_py)) + { + w->s_player.px = future_px; + w->s_player.py = future_py; + } + } } -void move_right(t_structure_main *w, int key) { - double future_px; - double future_py; +void move_right(t_structure_main *w, int key) +{ + double future_px; + double future_py; - if (key == 100) { // Touche 'd' pour aller à droite - future_px = w->s_player.px + cos(w->s_player.pa + (PI/2)) * w->s_map.mapS; - future_py = w->s_player.py + sin(w->s_player.pa + (PI/2)) * w->s_map.mapS; - - if (can_move_to(w, future_px, future_py)) { - w->s_player.px = future_px; - w->s_player.py = future_py; - } - } + if (key == 100) + { + future_px = w->s_player.px + cos(w->s_player.pa + + (PI / 2)) * w->s_map.map_s; + future_py = w->s_player.py + sin(w->s_player.pa + + (PI / 2)) * w->s_map.map_s; + if (can_move_to(w, future_px, future_py)) + { + w->s_player.px = future_px; + w->s_player.py = future_py; + } + } } -void move_left(t_structure_main *w, int key) { - double future_px; - double future_py; +void move_left(t_structure_main *w, int key) +{ + double future_px; + double future_py; - if (key == 97) { // Touche 'a' pour aller à gauche - future_px = w->s_player.px + cos(w->s_player.pa - (PI/2)) * w->s_map.mapS; - future_py = w->s_player.py + sin(w->s_player.pa - (PI/2)) * w->s_map.mapS; - - if (can_move_to(w, future_px, future_py)) { - w->s_player.px = future_px; - w->s_player.py = future_py; - } - } + if (key == 97) + { + future_px = w->s_player.px + cos(w->s_player.pa + - (PI / 2)) * w->s_map.map_s; + future_py = w->s_player.py + sin(w->s_player.pa + - (PI / 2)) * w->s_map.map_s; + if (can_move_to(w, future_px, future_py)) + { + w->s_player.px = future_px; + w->s_player.py = future_py; + } + } } void move(int key, t_structure_main *w) diff --git a/parsing/ft_find_map_start.c b/parsing/ft_find_map_start.c index 7e9219c..bd0f568 100644 --- a/parsing/ft_find_map_start.c +++ b/parsing/ft_find_map_start.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 20:04:23 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 22:48:56 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 18:02:53 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,7 +43,8 @@ bool handle_colors(int fd, t_texture *textures) { line[i] = '\0'; printf("Ligne lue pour les couleurs: '%s'\n", line); - if ((line[0] == 'F' || line[0] == 'C') && process_color_line(line, textures)) + if ((line[0] == 'F' || line[0] == 'C') + && process_color_line(line, textures)) color_count++; i = 0; } @@ -94,10 +95,7 @@ bool load_cub_file(const char *filename, return (cleanup_and_close(fd, map_buffer, false)); } if (map_buffer) - { - //printf("Map buffer loaded:\n%s\n", map_buffer); result = parse_map(map_buffer, map_length, map_info); - } else { printf("No map data found in file.\n"); diff --git a/parsing/ft_find_player_position.c b/parsing/ft_find_player_position.c index d3e99d4..9316a34 100644 --- a/parsing/ft_find_player_position.c +++ b/parsing/ft_find_player_position.c @@ -6,97 +6,60 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/23 19:54:51 by fgras-ca #+# #+# */ -/* Updated: 2024/01/23 20:22:20 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 18:58:31 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../cub3d.h" -static void initialize_variables(int *i, int *line_number, int *column_number, bool *found_player) +bool is_player_char(char c) { - *i = 0; - *line_number = 0; - *column_number = 0; - *found_player = false; + return (c == 'N' || c == 'S' || c == 'E' || c == 'W'); } -static bool check_for_player(char current_char, bool *found_player) +static bool process_player_char(char current_char, t_player_info *player_info) { - if (current_char == 'N' || current_char == 'S' || current_char == 'E' || current_char == 'W') + if (is_player_char(current_char)) { - if (*found_player) + if (check_for_multiple_players(*(player_info->found_player))) + { + *(player_info->found_player) = true; + update_player_info(player_info->map, player_info->line_number, + player_info->column_number, current_char); + } + else { printf("Multiple player start positions found. Invalid map.\n"); - return false; + return (false); } - *found_player = true; } - return true; + return (true); } -static void update_player_info(t_structure_map *map_info, int line_number, int column_number, char player_direction) +bool find_player(const char *map_content, int length, t_structure_map *map) { - map_info->player_x = column_number * map_info->mapS + map_info->mapS / 2; - map_info->player_y = line_number * map_info->mapS + map_info->mapS / 2; - map_info->player_direction = player_direction; - printf("Player found: x = %f, y = %f, direction = %c\n", map_info->player_x, map_info->player_y, map_info->player_direction); -} + int i; + bool found_player; + t_player_info player_info; - -static void update_position(char current_char, int *line_number, int *column_number) -{ - if (current_char == '\n') + i = 0; + initialize_variables(&i, &player_info.line_number, + &player_info.column_number, &found_player); + player_info.map = map; + player_info.found_player = &found_player; + while (i < length) { - (*line_number)++; - *column_number = 0; - } - else - { - (*column_number)++; + if (!found_player) + { + if (!process_player_char(map_content[i], &player_info)) + return (false); + } + calculate_map(map); + update_position(map_content[i], + &player_info.line_number, &player_info.column_number); + i++; } + if (!found_player) + return (false); + return (true); } - -static bool check_for_multiple_players(bool found_player) -{ - if (found_player) - { - printf("Multiple player start positions found. Invalid map.\n"); - return false; - } - return true; -} - -bool find_player_position_and_direction(const char *map_content, int length, t_structure_map *map_info) -{ - int i; - int line_number; - int column_number; - bool found_player; - - initialize_variables(&i, &line_number, &column_number, &found_player); - while (i < length) - { - char current_char = map_content[i]; - if (!found_player && (current_char == 'N' || current_char == 'S' || current_char == 'E' || current_char == 'W')) - { - if (check_for_multiple_players(found_player)) - { - found_player = true; - update_player_info(map_info, line_number, column_number, current_char); - } - else - { - return false; - } - } - calculate_map(map_info); - update_position(current_char, &line_number, &column_number); - i++; - } - if (!found_player) - { - printf("Player start position not found. Invalid map.\n"); - return false; - } - return true; -} \ No newline at end of file diff --git a/parsing/ft_find_player_utils.c b/parsing/ft_find_player_utils.c new file mode 100644 index 0000000..53a703c --- /dev/null +++ b/parsing/ft_find_player_utils.c @@ -0,0 +1,71 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_find_player_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: fgras-ca +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/29 18:57:38 by fgras-ca #+# #+# */ +/* Updated: 2024/01/29 18:58:26 by fgras-ca ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../cub3d.h" + +void initialize_variables(int *i, int *line_number, + int *column_number, bool *found_player) +{ + *i = 0; + *line_number = 0; + *column_number = 0; + *found_player = false; +} + +bool check_for_player(char current_char, bool *found_player) +{ + if (current_char == 'N' || current_char == 'S' + || current_char == 'E' || current_char == 'W') + { + if (*found_player) + { + printf("Multiple player start positions found. Invalid map.\n"); + return (false); + } + *found_player = true; + } + return (true); +} + +void update_player_info(t_structure_map *map_info, + int line_number, int column_number, char player_direction) +{ + map_info->player_x = column_number * map_info->map_s + map_info->map_s / 2; + map_info->player_y = line_number * map_info->map_s + map_info->map_s / 2; + map_info->player_direction = player_direction; + printf("Player found: x = %f, y = %f, direction = %c\n", map_info->player_x, + map_info->player_y, map_info->player_direction); +} + +void update_position(char current_char, + int *line_number, int *column_number) +{ + if (current_char == '\n') + { + (*line_number)++; + *column_number = 0; + } + else + { + (*column_number)++; + } +} + +bool check_for_multiple_players(bool found_player) +{ + if (found_player) + { + printf("Multiple player start positions found. Invalid map.\n"); + return (false); + } + return (true); +} diff --git a/parsing/ft_map_check.c b/parsing/ft_map_check.c index fa472c0..d4b428d 100644 --- a/parsing/ft_map_check.c +++ b/parsing/ft_map_check.c @@ -6,251 +6,105 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 14:49:45 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 22:20:51 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 19:46:50 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../cub3d.h" -int is_space_surrounded_by_walls(char *map, int maxWidth, int height, int x, int y) { - // Vérifie si les cellules adjacentes à un espace sont toutes des murs ('1') - return (x > 0 && map[y * maxWidth + (x - 1)] == '1') && - (x < maxWidth - 1 && map[y * maxWidth + (x + 1)] == '1') && - (y > 0 && map[(y - 1) * maxWidth + x] == '1') && - (y < height - 1 && map[(y + 1) * maxWidth + x] == '1'); -} - -int flood_fill_and_check(char *map, char *visitedMap, int maxWidth, int height, int x, int y, char replacement) { - if (x < 0 || x >= maxWidth || y < 0 || y >= height) { - return 0; // Ouverture détectée - } - - if (visitedMap[y * maxWidth + x] == 1 || map[y * maxWidth + x] == '1') { - return 1; // Mur ou déjà visité - } - - if (map[y * maxWidth + x] == ' ' && !is_space_surrounded_by_walls(map, maxWidth, height, x, y)) { - return 0; // Espace non entouré correctement par des murs, ouverture intérieure détectée - } - - visitedMap[y * maxWidth + x] = 1; // Marquer la cellule comme visitée - map[y * maxWidth + x] = replacement; // Marquer la cellule dans la carte principale - - // Appliquer récursivement à toutes les directions - return flood_fill_and_check(map, visitedMap, maxWidth, height, x + 1, y, replacement) && - flood_fill_and_check(map, visitedMap, maxWidth, height, x - 1, y, replacement) && - flood_fill_and_check(map, visitedMap, maxWidth, height, x, y + 1, replacement) && - flood_fill_and_check(map, visitedMap, maxWidth, height, x, y - 1, replacement); -} - -int is_surrounded_by_walls(char *map, int maxWidth, int height, int x, int y) { - // Vérifier les limites - if (x <= 0 || x >= maxWidth - 1 || y <= 0 || y >= height - 1) return 1; - - // Vérifier les cellules adjacentes - if (map[(y - 1) * maxWidth + x] == '1' && map[(y + 1) * maxWidth + x] == '1' && - map[y * maxWidth + (x - 1)] == '1' && map[y * maxWidth + (x + 1)] == '1') { - return 1; - } - - return 0; -} - -int is_map_closed(char *map, int maxWidth, int height) { - - char *copy_map = malloc(maxWidth * height); - if (copy_map) - { - ft_memcpy(copy_map, map, maxWidth * height); - } - char *visitedMap = calloc(maxWidth * height, sizeof(char)); - if (!visitedMap) { - printf("Erreur d'allocation mémoire pour visitedMap.\n"); - return 0; - } - - int startX = -1, startY = -1; - printf("Début de la vérification de fermeture de la carte.\n"); - - /* Affichage de la carte avant flood_fill - printf("Carte avant flood_fill:\n"); - for (int y = 0; y < height; y++) { - for (int x = 0; x < maxWidth; x++) { - printf("%c", map[y * maxWidth + x]); - } - printf("\n"); - }*/ - - // Trouver un point de départ valide - for (int y = 0; y < height && startX == -1; y++) { - for (int x = 0; x < maxWidth && startX == -1; x++) { - if ((map[y * maxWidth + x] == '0' || map[y * maxWidth + x] == '2') && !is_surrounded_by_walls(map, maxWidth, height, x, y)) { - startX = x; - startY = y; - printf("Point de départ trouvé pour flood_fill à (%d, %d)\n", startX, startY); - break; - } - } - } - - if (startX == -1) { - printf("Aucun point de départ valide trouvé.\n"); - free(visitedMap); - return 1; // Si aucun point de départ n'est trouvé, la carte est considérée comme fermée - } - - int is_closed = flood_fill_and_check(copy_map, visitedMap, maxWidth, height, startX, startY, '3'); - - - /*printf("Carte après flood_fill:\n"); - for (int y = 0; y < height; y++) { - for (int x = 0; x < maxWidth; x++) { - printf("%c", visitedMap[y * maxWidth + x] ? '3' : map[y * maxWidth + x]); - } - printf("\n"); - }*/ - - - free(visitedMap); - free(copy_map); - return is_closed; -} - -/*int is_map_closed(char *map, int maxWidth, int height) +static int flood_fill_and_check(t_map_check *map_check, + char *visitedMap, t_point p, char replacement) { - if (!check_borders(map, maxWidth, height)) + if (p.x < 0 || p.x >= map_check->maxWidth + || p.y < 0 || p.y >= map_check->height) return (0); - if (!check_interior(map, maxWidth, height)) - return (0); - return (1); -} - -int check_line_border(char *line, int lineLength, int y) -{ - if (lineLength == 0) + if (visitedMap[p.y * map_check->maxWidth + p.x] == 1 + || map_check->map[p.y * map_check->maxWidth + p.x] == '1') return (1); - if (line[0] != '1') + if (map_check->map[p.y * map_check->maxWidth + p.x] == ' ' + && !is_space_surrounded_by_walls(map_check, p)) return (0); - if (line[lineLength - 1] != '1') - return (0); - return (1); + visitedMap[p.y * map_check->maxWidth + p.x] = 1; + map_check->map[p.y * map_check->maxWidth + p.x] = replacement; + return (flood_fill_and_check(map_check, visitedMap, + (t_point){p.x + 1, p.y}, replacement) + && flood_fill_and_check(map_check, visitedMap, + (t_point){p.x - 1, p.y}, replacement) + && flood_fill_and_check(map_check, visitedMap, + (t_point){p.x, p.y + 1}, replacement) + && flood_fill_and_check(map_check, visitedMap, + (t_point){p.x, p.y - 1}, replacement)); } -int check_vertical_borders(char *map, int maxWidth, int height) -{ - int x, y, first_wall_found, last_wall_found; - - for (x = 0; x < maxWidth; x++) - { - first_wall_found = 0; - last_wall_found = height - 1; - - // Trouver le premier '1' dans la colonne - for (y = 0; y < height; y++) - { - if (map[y * maxWidth + x] == '1') - { - first_wall_found = 1; - break; - } - } - - // Trouver le dernier '1' dans la colonne - for (y = height - 1; y >= 0; y--) - { - if (map[y * maxWidth + x] == '1') - { - last_wall_found = y; - break; - } - } - - // Si aucun mur trouvé, la colonne est incorrecte - if (!first_wall_found || last_wall_found == height - 1) - { - printf("Border issue detected in column %d\\n", x); - return 0; - } - - // Vérifier que la colonne est correctement fermée - for (y = first_wall_found; y <= last_wall_found; y++) - { - if (map[y * maxWidth + x] != '1' && map[y * maxWidth + x] != ' ') - { - printf("Border issue detected in column %d at position %d\\n", x, y); - return 0; - } - } - } - - return 1; -} - -int check_horizontal_borders(char *map, int maxWidth, int height) -{ - int x, y; - - for (y = 0; y < height; y += height - 1) // Vérifier seulement la première et la dernière ligne - { - int first_wall_found = 0; - int last_wall_found = 0; - - // Trouver le premier '1' dans la ligne - for (x = 0; x < maxWidth; x++) - { - if (map[y * maxWidth + x] == '1') - { - first_wall_found = 1; - break; - } - } - - // Trouver le dernier '1' dans la ligne - for (x = maxWidth - 1; x >= 0; x--) - { - if (map[y * maxWidth + x] == '1') - { - last_wall_found = 1; - break; - } - } - - // Si aucun mur '1' n'est trouvé au début ou à la fin de la ligne - if (!first_wall_found || !last_wall_found) - { - printf("Border issue detected in line %d\\n", y); - return 0; - } - } - - return 1; -} - -int check_borders(char *map, int maxWidth, int height) +static int find_start_point(t_map_check *map_check, t_point *startPoint) { int y; - int linelength; int x; y = 0; - while (y < height) + while (y < map_check->height) { - linelength = 0; x = 0; - while (x < maxWidth && map[y * maxWidth + x] != ' ') + while (x < map_check->maxWidth) { - linelength++; + if ((map_check->map[y * map_check->maxWidth + x] == '0' + || map_check->map[y * map_check->maxWidth + x] == '2') + && !is_space_surrounded_by_walls(map_check, (t_point){x, y})) + { + startPoint->x = x; + startPoint->y = y; + return (1); + } x++; } - if (!check_line_border(&map[y * maxWidth], linelength, y)) - { - return (0); - } y++; } - if (!check_horizontal_borders(map, maxWidth, height)) + return (0); +} + +static int initialize_maps(char **copy_map, char **visited_map, + int maxWidth, int height) +{ + *copy_map = malloc(maxWidth * height); + *visited_map = calloc(maxWidth * height, sizeof(char)); + if (!(*copy_map) || !(*visited_map)) { + free(*copy_map); + free(*visited_map); + printf("Erreur d'allocation mémoire.\n"); return (0); } - return (check_vertical_borders(map, maxWidth, height)); -}*/ + return (1); +} + +static void cleanup_and_print_error(char *visited_map, char *copy_map) +{ + free(visited_map); + free(copy_map); + printf("Aucun point de départ valide trouvé.\n"); +} + +int is_map_closed(char *map, int maxWidth, int height) +{ + char *copy_map; + char *visited_map; + t_map_check map_check; + t_point start_point; + int is_closed; + + map_check.maxWidth = maxWidth; + map_check.height = height; + if (!initialize_maps(©_map, &visited_map, maxWidth, height)) + return (0); + ft_memcpy(copy_map, map, maxWidth * height); + map_check.map = copy_map; + if (!find_start_point(&map_check, &start_point)) + { + cleanup_and_print_error(visited_map, copy_map); + return (1); + } + is_closed = flood_fill_and_check(&map_check, visited_map, start_point, '3'); + free(visited_map); + free(copy_map); + return (is_closed); +} diff --git a/parsing/ft_map_check_utils.c b/parsing/ft_map_check_utils.c new file mode 100644 index 0000000..20e34ad --- /dev/null +++ b/parsing/ft_map_check_utils.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_map_check_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: fgras-ca +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/29 19:44:27 by fgras-ca #+# #+# */ +/* Updated: 2024/01/29 19:48:01 by fgras-ca ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../cub3d.h" + +int check_boundaries(t_point p, t_map_check *map_check) +{ + return (p.x > 0 && p.x < map_check->maxWidth - 1 + && p.y > 0 && p.y < map_check->height - 1); +} + +int is_space_surrounded_by_walls(t_map_check *map_check, t_point p) +{ + if (!check_boundaries(p, map_check)) + return (0); + return (map_check->map[p.y * map_check->maxWidth + (p.x - 1)] == '1' + && map_check->map[p.y * map_check->maxWidth + (p.x + 1)] == '1' + && map_check->map[(p.y - 1) * map_check->maxWidth + p.x] == '1' + && map_check->map[(p.y + 1) * map_check->maxWidth + p.x] == '1'); +} diff --git a/parsing/ft_map_dimensions.c b/parsing/ft_map_dimensions.c index 651617b..b6386b5 100644 --- a/parsing/ft_map_dimensions.c +++ b/parsing/ft_map_dimensions.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 22:17:19 by fgras-ca #+# #+# */ -/* Updated: 2024/01/15 22:37:27 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 16:05:03 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,12 +15,12 @@ void update_max_dimensions(t_map_params *params) { (*(params->height))++; - if (*(params->currentWidth) > *(params->maxWidth)) + if (*(params->current_width) > *(params->max_width)) { - *(params->maxWidth) = *(params->currentWidth); + *(params->max_width) = *(params->current_width); } - *(params->currentWidth) = 0; - *(params->isNewLine) = 1; + *(params->current_width) = 0; + *(params->is_new_line) = 1; } void process_character(t_map_params *params, int *i) @@ -31,8 +31,8 @@ void process_character(t_map_params *params, int *i) } else if (params->buffer[*i] != '\r') { - (*(params->currentWidth))++; - *(params->isNewLine) = 0; + (*(params->current_width))++; + *(params->is_new_line) = 0; } (*i)++; } @@ -46,16 +46,16 @@ void get_map_dimensions(t_map_params *params) i = 0; currentwidth = 0; isnewline = 1; - *(params->maxWidth) = 0; + *(params->max_width) = 0; *(params->height) = 0; - params->currentWidth = ¤twidth; - params->isNewLine = &isnewline; + params->current_width = ¤twidth; + params->is_new_line = &isnewline; while (i < params->length) process_character(params, &i); - if (!*(params->isNewLine)) + if (!*(params->is_new_line)) update_max_dimensions(params); printf("Map dimensions: maxWidth=%d, height=%d\n", - *(params->maxWidth), *(params->height)); + *(params->max_width), *(params->height)); } void fill_map_space(t_structure_map *map_info, int maxWidth, int height) @@ -88,9 +88,9 @@ void copy_map_data(t_map_params *params) y++; x = 0; } - else if (params->buffer[i] != '\r' && x < *params->maxWidth) + else if (params->buffer[i] != '\r' && x < *params->max_width) { - params->map_info->map[y * *params->maxWidth + x] + params->map_info->map[y * *params->max_width + x] = params->buffer[i]; x++; } diff --git a/parsing/ft_parsing.c b/parsing/ft_parsing.c index b2c6cc4..ea62588 100644 --- a/parsing/ft_parsing.c +++ b/parsing/ft_parsing.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 14:43:46 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 17:31:00 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 19:51:28 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,8 +14,8 @@ bool init_map_info(t_structure_map *map_info, int maxWidth, int height) { - map_info->mapX = maxWidth; - map_info->mapY = height; + map_info->map_x = maxWidth; + map_info->map_y = height; map_info->s_win.width = WIDTH; map_info->s_win.height = HEIGHT; map_info->map = malloc(maxWidth * height); @@ -31,7 +31,8 @@ bool init_map_info(t_structure_map *map_info, int maxWidth, int height) bool copy_map_data_and_check(t_map_params *params) { copy_map_data(params); - if (!is_map_closed(params->map_info->map, *params->maxWidth, *params->height)) + if (!is_map_closed(params->map_info->map, + *params->max_width, *params->height)) { printf("Map is not closed!\n"); free(params->map_info->map); @@ -45,23 +46,24 @@ void calculate_map(t_structure_map *map_info) float maps_x; float maps_y; - maps_x = (float)map_info->s_win.width / (map_info->mapX * 4); - maps_y = (float)map_info->s_win.height / (map_info->mapY * 2); + maps_x = (float)map_info->s_win.width / (map_info->map_x * 4); + maps_y = (float)map_info->s_win.height / (map_info->map_y * 2); if (maps_x < maps_y) { - map_info->mapS = (int)maps_x; + map_info->map_s = (int)maps_x; } else { - map_info->mapS = (int)maps_y; + map_info->map_s = (int)maps_y; } - if (map_info->mapS == 0) + if (map_info->map_s == 0) { - map_info->mapS = 1; + map_info->map_s = 1; } } -bool parse_map(const char *map_content, int length, t_structure_map *map_info) +bool parse_map(const char *map_content, int length, + t_structure_map *map_info) { t_map_params map_params; int max_width; @@ -72,7 +74,7 @@ bool parse_map(const char *map_content, int length, t_structure_map *map_info) map_params.map_info = map_info; map_params.buffer = map_content; map_params.length = length; - map_params.maxWidth = &max_width; + map_params.max_width = &max_width; map_params.height = &height; get_map_dimensions(&map_params); if (max_width <= 0 || height <= 0) @@ -82,7 +84,7 @@ bool parse_map(const char *map_content, int length, t_structure_map *map_info) } if (!init_map_info(map_info, max_width, height)) return (false); - if (!find_player_position_and_direction(map_content, length, map_info)) + if (!find_player(map_content, length, map_info)) return (false); return (copy_map_data_and_check(&map_params)); } diff --git a/parsing/ft_read_map.c b/parsing/ft_read_map.c deleted file mode 100644 index b079a2c..0000000 --- a/parsing/ft_read_map.c +++ /dev/null @@ -1,97 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_read_map.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: fgras-ca +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/01/11 19:28:43 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 22:36:40 by fgras-ca ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "../cub3d.h" - -/*static int check_line(char *map, int maxWidth, int height, int y) -{ - int x; - char c; - - for (x = 0; x < maxWidth; x++) - { - c = map[y * maxWidth + x]; - if (c == ' ' && ((x > 0 && map[y * maxWidth + (x - 1)] != '1') || - (x < maxWidth - 1 && map[y * maxWidth + (x + 1)] != '1') || - (y > 0 && map[(y - 1) * maxWidth + x] != '1') || - (y < height - 1 && map[(y + 1) * maxWidth + x] != '1'))) - return (0); - } - return (1); -} - - -static int check_row(char *map, int maxWidth, int height, int y) -{ - return check_line(map, maxWidth, height, y); -} - -int check_interior(char *map, int maxWidth, int height) -{ - int y; - - for (y = 0; y < height; y++) - { - if (!check_row(map, maxWidth, height, y)) - return (0); - } - return (1); -}*/ - -void load_sprite_frames(t_sprite *sprite, void *mlx_ptr) { - sprite->frames[0] = mlx_xpm_file_to_image(mlx_ptr, "sprite/pnj/pnj01.xpm", &sprite->width, &sprite->height); - if (sprite->frames[0] == NULL) { - printf("Erreur de chargement de sprite/pnj/pnj01.xpm\n"); - } else { - printf("Sprite pnj01.xpm chargé avec succès. Dimensions: %d x %d\n", sprite->width, sprite->height); - } - sprite->frames[1] = mlx_xpm_file_to_image(mlx_ptr, "sprite/pnj/pnj02.xpm", &sprite->width, &sprite->height); - if (sprite->frames[1] == NULL) { - printf("Erreur de chargement de sprite/pnj/pnj01.xpm\n"); - } else { - printf("Sprite pnj02.xpm chargé avec succès. Dimensions: %d x %d\n", sprite->width, sprite->height); - } - sprite->frames[2] = mlx_xpm_file_to_image(mlx_ptr, "sprite/pnj/pnj03.xpm", &sprite->width, &sprite->height); - if (sprite->frames[2] == NULL) { - printf("Erreur de chargement de sprite/pnj/pnj01.xpm\n"); - } else { - printf("Sprite pnj03.xpm chargé avec succès. Dimensions: %d x %d\n", sprite->width, sprite->height); - } -} - -void update_sprite_frame(t_sprite *sprite) { - static int counter = 0; - counter = (counter + 1) % 60; - if (counter == 0) { - sprite->current_frame = (sprite->current_frame + 1) % 3; - printf("Frame du sprite mise à jour : %d\n", sprite->current_frame); - } -} - -void draw_sprite(t_sprite *sprite, void *mlx_ptr, void *win_ptr, int win_width, int win_height) { - if (sprite->frames[sprite->current_frame] != NULL) { - float posX = 170; - float posY = 30; - - // Logs pour débogage - printf("Dessin du sprite (frame %d)...\n", sprite->current_frame); - printf("Dimensions du sprite : largeur = %d, hauteur = %d\n", sprite->width, sprite->height); - printf("Coordonnées de dessin du sprite : X = %f, Y = %f\n", posX, posY); - - // Dessiner le sprite - mlx_put_image_to_window(mlx_ptr, win_ptr, sprite->frames[sprite->current_frame], posX, posY); - printf("Sprite dessiné aux coordonnées: %f, %f\n", posX, posY); - } else { - // Log en cas d'erreur - printf("Erreur lors du dessin du sprite (frame %d)\n", sprite->current_frame); - } -} diff --git a/parsing/ft_text_and_col_utils.c b/parsing/ft_text_and_col_utils.c new file mode 100644 index 0000000..031ec9f --- /dev/null +++ b/parsing/ft_text_and_col_utils.c @@ -0,0 +1,91 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_text_and_col_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: fgras-ca +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/29 20:07:44 by fgras-ca #+# #+# */ +/* Updated: 2024/01/29 20:17:23 by fgras-ca ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../cub3d.h" + +bool parse_texture_line(const char *line, t_texture *textures) +{ + char direction[3]; + char path[MAX_LINE_LENGTH]; + int i; + int j; + + i = 0; + j = 0; + while (line[i] != ' ' && line[i] != '\0' && i < 2) + direction[i++] = line[i]; + direction[i] = '\0'; + while (line[i] == ' ' && line[i] != '\0') + i++; + while (line[i] != ' ' && line[i] != '\0' && j < MAX_LINE_LENGTH - 1) + path[j++] = line[i++]; + path[j] = '\0'; + if (ft_strcmp(direction, "NO") == 0) + textures->north = ft_strdup(path); + else if (ft_strcmp(direction, "SO") == 0) + textures->south = ft_strdup(path); + else if (ft_strcmp(direction, "WE") == 0) + textures->west = ft_strdup(path); + else if (ft_strcmp(direction, "EA") == 0) + textures->east = ft_strdup(path); + return (true); +} + +bool parse_number_from_str(const char **str, int *number) +{ + *number = 0; + while (**str >= '0' && **str <= '9') + { + *number = *number * 10 + (**str - '0'); + (*str)++; + } + if (**str != ',' && **str != ' ' && **str != '\0') + { + return (false); + } + return (true); +} + +bool parse_color_line(const char *line, unsigned int *color) +{ + int r; + int g; + int b; + const char *ptr; + + r = 0; + g = 0; + b = 0; + ptr = line; + while (*ptr == ' ') + ptr++; + if (!parse_number_from_str(&ptr, &r) || *ptr++ != ',') + return (false); + while (*ptr == ' ') + ptr++; + if (!parse_number_from_str(&ptr, &g) || *ptr++ != ',') + return (false); + while (*ptr == ' ') + ptr++; + if (!parse_number_from_str(&ptr, &b)) + return (false); + *color = (r << 16) | (g << 8) | b; + return (true); +} + +bool is_valid_texture(const char *line) +{ + return (ft_strncmp(line, "NO ", 3) == 0 + || ft_strncmp(line, "SO ", 3) == 0 + || ft_strncmp(line, "WE ", 3) == 0 + || ft_strncmp(line, "EA ", 3) == 0); +} diff --git a/parsing/ft_textures_and_colors.c b/parsing/ft_textures_and_colors.c index fc57d97..3ad8a07 100644 --- a/parsing/ft_textures_and_colors.c +++ b/parsing/ft_textures_and_colors.c @@ -6,128 +6,53 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/16 16:19:13 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 18:06:00 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 20:17:57 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../cub3d.h" -bool parse_texture_line(const char *line, t_texture *textures) +bool handle_map(int fd, char **map_buffer, int *map_length) { - char direction[3]; - char path[MAX_LINE_LENGTH]; - int i; - int j; + char *line; + size_t len; + ssize_t read; + bool start_copying; + FILE *stream; - i = 0; - j = 0; - while (line[i] != ' ' && line[i] != '\0' && i < 2) - direction[i++] = line[i]; - direction[i] = '\0'; - while (line[i] == ' ' && line[i] != '\0') - i++; - while (line[i] != ' ' && line[i] != '\0' && j < MAX_LINE_LENGTH - 1) - path[j++] = line[i++]; - path[j] = '\0'; - if (ft_strcmp(direction, "NO") == 0) - textures->north = ft_strdup(path); - else if (ft_strcmp(direction, "SO") == 0) - textures->south = ft_strdup(path); - else if (ft_strcmp(direction, "WE") == 0) - textures->west = ft_strdup(path); - else if (ft_strcmp(direction, "EA") == 0) - textures->east = ft_strdup(path); - return (true); -} - -bool handle_map(int fd, char **map_buffer, int *map_length) { - FILE *stream = fdopen(fd, "r"); - if (!stream) { - perror("Error converting file descriptor to FILE *"); - return false; - } - - char *line = NULL; - size_t len = 0; - ssize_t read; - bool start_copying = false; - - *map_length = 0; - *map_buffer = NULL; - - while ((read = getline(&line, &len, stream)) != -1) { - // Vérifier si la ligne contient '1' ou '0' - if (!start_copying && (ft_strchr(line, '1') || ft_strchr(line, '0'))) { - start_copying = true; - } - - // Commencer la copie si on a trouvé une ligne contenant '1' ou '0' - if (start_copying) { - *map_buffer = realloc(*map_buffer, *map_length + read + 1); - if (!*map_buffer) { - perror("Error reallocating memory for map buffer"); - free(line); - fclose(stream); - return (false); - } - ft_memcpy(*map_buffer + *map_length, line, read); - *map_length += read; - (*map_buffer)[*map_length] = '\0'; - } - } - - free(line); - fclose(stream); - return (*map_buffer != NULL); -} - - - -bool parse_number_from_str(const char **str, int *number) -{ - *number = 0; - while (**str >= '0' && **str <= '9') - { - *number = *number * 10 + (**str - '0'); - (*str)++; - } - if (**str != ',' && **str != ' ' && **str != '\0') + stream = fdopen(fd, "r"); + line = NULL; + len = 0; + start_copying = false; + *map_length = 0; + *map_buffer = NULL; + if (!stream) { + perror("Error converting file descriptor to FILE *"); return (false); } - return (true); -} - -bool parse_color_line(const char *line, unsigned int *color) -{ - int r; - int g; - int b; - const char *ptr; - - r = 0; - g = 0; - b = 0; - ptr = line; - while (*ptr == ' ') ptr++; - if (!parse_number_from_str(&ptr, &r) || *ptr++ != ',') - return (false); - while (*ptr == ' ') ptr++; - if (!parse_number_from_str(&ptr, &g) || *ptr++ != ',') - return (false); - while (*ptr == ' ') ptr++; - if (!parse_number_from_str(&ptr, &b)) - return (false); - *color = (r << 16) | (g << 8) | b; - return (true); -} - -bool is_valid_texture(const char *line) -{ - return (ft_strncmp(line, "NO ", 3) == 0 - || ft_strncmp(line, "SO ", 3) == 0 - || ft_strncmp(line, "WE ", 3) == 0 - || ft_strncmp(line, "EA ", 3) == 0); + while ((read = getline(&line, &len, stream)) != -1) + { + if (!start_copying && (ft_strchr(line, '1') || ft_strchr(line, '0'))) + start_copying = true; + if (start_copying) + { + *map_buffer = realloc(*map_buffer, *map_length + read + 1); + if (!*map_buffer) + { + perror("Error reallocating memory for map buffer"); + free(line); + fclose(stream); + return (false); + } + ft_memcpy(*map_buffer + *map_length, line, read); + *map_length += read; + (*map_buffer)[*map_length] = '\0'; + } + } + free(line); + fclose(stream); + return (*map_buffer != NULL); } bool handle_textures(int fd, t_texture *textures) diff --git a/window/ft_map.c b/window/ft_map.c index 3a6eb57..ec95e99 100644 --- a/window/ft_map.c +++ b/window/ft_map.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 20:19:01 by fgras-ca #+# #+# */ -/* Updated: 2024/01/25 18:36:59 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 15:47:34 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ void draw_map_line(t_structure_main *w, int y, int lineLength) x = 0; while (x < lineLength) { - index = y * w->s_map.mapX + x; + index = y * w->s_map.map_x + x; if (w->s_map.map[index] == '1') color = 0xFFFFFF; else if (w->s_map.map[index] == '0') @@ -48,12 +48,12 @@ void draw_map(t_structure_main *w) printf("Erreur: La carte n'a pas été chargée correctement.\n"); return ; } - while (y < w->s_map.mapY) + while (y < w->s_map.map_y) { linelength = 0; - while (linelength < w->s_map.mapX - && w->s_map.map[y * w->s_map.mapX + linelength] - != '\n' && w->s_map.map[y * w->s_map.mapX + linelength] != '\0') + while (linelength < w->s_map.map_x + && w->s_map.map[y * w->s_map.map_x + linelength] + != '\n' && w->s_map.map[y * w->s_map.map_x + linelength] != '\0') { linelength++; } diff --git a/window/ft_player.c b/window/ft_player.c index 9288b9d..0f25f05 100644 --- a/window/ft_player.c +++ b/window/ft_player.c @@ -6,29 +6,34 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 20:09:23 by fgras-ca #+# #+# */ -/* Updated: 2024/01/23 18:38:11 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 20:21:37 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "../cub3d.h" -void init_player(t_structure_main *w) { - w->s_player.px = w->s_map.player_x; - w->s_player.py = w->s_map.player_y; - - // Remplacer le switch par des if - if (w->s_map.player_direction == 'N') { - w->s_player.pa = M_PI; - } else if (w->s_map.player_direction == 'S') { - w->s_player.pa = 0; - } else if (w->s_map.player_direction == 'E') { - w->s_player.pa = M_PI / 2; - } else if (w->s_map.player_direction == 'W') { - w->s_player.pa = 3 * M_PI / 2; - } - - w->s_player.pdx = cos(w->s_player.pa) * 5; - w->s_player.pdy = sin(w->s_player.pa) * 5; +void init_player(t_structure_main *w) +{ + w->s_player.px = w->s_map.player_x; + w->s_player.py = w->s_map.player_y; + if (w->s_map.player_direction == 'N') + { + w->s_player.pa = M_PI; + } + else if (w->s_map.player_direction == 'S') + { + w->s_player.pa = 0; + } + else if (w->s_map.player_direction == 'E') + { + w->s_player.pa = M_PI / 2; + } + else if (w->s_map.player_direction == 'W') + { + w->s_player.pa = 3 * M_PI / 2; + } + w->s_player.pdx = cos(w->s_player.pa) * 5; + w->s_player.pdy = sin(w->s_player.pa) * 5; } void init_mlx_and_window(t_structure_main *w) diff --git a/window/ft_refresh_window.c b/window/ft_refresh_window.c index 6654247..95986bd 100644 --- a/window/ft_refresh_window.c +++ b/window/ft_refresh_window.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 19:50:24 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 22:04:52 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 20:23:13 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,10 +19,10 @@ void rescale_sprite(t_structure_main *w, t_state *state) params.original_img = w->s_img.roomadslam[state->jkl]; params.original_width = 112; params.original_height = 112; - params.new_width = w->s_map.mapS; - params.new_height = w->s_map.mapS; - params.px = w->s_player.px - w->s_map.mapS / 2; - params.py = w->s_player.py - w->s_map.mapS / 2; + params.new_width = w->s_map.map_s; + params.new_height = w->s_map.map_s; + params.px = w->s_player.px - w->s_map.map_s / 2; + params.py = w->s_player.py - w->s_map.map_s / 2; rescale_image(¶ms, w); } @@ -35,8 +35,6 @@ void refresh_window(t_structure_main *w, t_state *state) &(w->s_img.bpp), &(w->s_img.line_len), &(w->s_img.endian)); draw_map(w); drawrays2d(w); - update_sprite_frame(&w->sprite); - draw_sprite(&w->sprite, w->s_win.mlx, w->s_win.win, w->s_win.width, w->s_win.height); mlx_put_image_to_window(w->s_win.mlx, w->s_win.win, w->s_img.buffer, 0, 0); rescale_sprite(w, state); } @@ -48,11 +46,11 @@ void handle_mouse_movement(t_structure_main *w) mlx_mouse_get_pos(w->s_win.mlx, w->s_win.win, &x, &y); if ((x > 0 && x < w->s_win.width) && (y > 0 && y < w->s_win.height)) - { - if (x < w->s_win.width/2-40) - deal_key(65361,w); - else if (x > w->s_win.width/2+40) - deal_key(65363,w); + { + if (x < w->s_win.width / 2 - 40) + deal_key(65361, w); + else if (x > w->s_win.width / 2 + 40) + deal_key(65363, w); } } diff --git a/window/ft_window.c b/window/ft_window.c index c71b422..cad008c 100644 --- a/window/ft_window.c +++ b/window/ft_window.c @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/14 19:15:53 by fgras-ca #+# #+# */ -/* Updated: 2024/01/28 21:57:21 by fgras-ca ### ########.fr */ +/* Updated: 2024/01/29 15:47:48 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -76,12 +76,12 @@ void calculate_map_scale(t_structure_main *w) int maps_x; int maps_y; - maps_x = w->s_win.width / (w->s_map.mapX * 4); - maps_y = w->s_win.height / (w->s_map.mapY * 2); + maps_x = w->s_win.width / (w->s_map.map_x * 4); + maps_y = w->s_win.height / (w->s_map.map_y * 2); if (maps_x < maps_y) - w->s_map.mapS = maps_x; + w->s_map.map_s = maps_x; else - w->s_map.mapS = maps_y; + w->s_map.map_s = maps_y; } void init_windows(t_structure_main *w) @@ -93,7 +93,6 @@ void init_windows(t_structure_main *w) load_textures(w, &temp); init_buffer(w); load_wall_textures(w); - load_sprite_frames(&w->sprite, w->s_win.mlx); printf("Window Dimensions: Width = %d, Height = %d\n", w->s_win.width, w->s_win.height); printf("Texture Dimensions: Width = %d, Height = %d\n",