github to gitea
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* cub.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/22 14:56:25 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/10/07 12:14:42 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#ifndef CUB_H
|
||||
|
||||
# define CUB_H
|
||||
|
||||
# include "parsing.h"
|
||||
# include "../libft/include/libft.h"
|
||||
# include "../gnl/include/get_next_line.h"
|
||||
|
||||
# define ERROR_PREFIX "Error\n"
|
||||
# define ERROR_EXT "Invalid file extension. Only .cub files are accepted."
|
||||
# define ERROR_EMPT_PATH "Invalid map file path."
|
||||
# define ERROR_INIT_DATA "Initialization of the data structure failed."
|
||||
# define ERROR_INIT_TEX "Initialization of the textures structure failed."
|
||||
# define ERROR_INIT_PARS "Initialization of the parsing structure failed."
|
||||
# define ERROR_EMPTY "You have provided an empty file."
|
||||
# define ERROR_COL "The RGB values provided are not valid or absent."
|
||||
# define ERROR_NULL_P "Player not found or multiple players."
|
||||
# define ERROR_BAD_CHAR "Invalid character in map."
|
||||
# define ERROR_POS "Player position not found."
|
||||
# define ERROR_ALLOC "Allocation failed."
|
||||
# define ERROR_PLAYER "Player not found or multiple players."
|
||||
# define ERROR_CHAR "Invalid character in map."
|
||||
# define ERROR_DOUBLE "Multiple images/colors have been provided \
|
||||
for the same texture."
|
||||
# define ERROR_NOT_CLOSE "Map is not closed by walls."
|
||||
# define ERROR_NOT_XMP "The texture file is not an xpm image."
|
||||
|
||||
typedef struct s_data
|
||||
{
|
||||
char **map;
|
||||
char *map_path;
|
||||
t_textures *texture;
|
||||
t_data_parsing parsing;
|
||||
} t_data;
|
||||
|
||||
//utils
|
||||
void ft_error(char *message);
|
||||
void free_char_array(char **array);
|
||||
int ft_arrlen(char **arr);
|
||||
void print_array(char **array);//temp
|
||||
|
||||
//init
|
||||
int init_data(t_data *data, char *path);
|
||||
void free_data(t_data *data);
|
||||
|
||||
#endif
|
||||
@@ -1,89 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parsing.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/22 14:08:04 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/10/07 12:16:07 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PARSING_H
|
||||
# define PARSING_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
struct s_data;
|
||||
typedef struct s_data t_data;
|
||||
|
||||
typedef struct s_textures
|
||||
{
|
||||
char *north;
|
||||
char *south;
|
||||
char *east;
|
||||
char *west;
|
||||
int floor[3];
|
||||
int ceiling[3];
|
||||
} t_textures;
|
||||
|
||||
typedef struct s_data_parsing
|
||||
{
|
||||
char **raw_map;
|
||||
int fd_map;
|
||||
int fd_map_dup;
|
||||
int player[3];
|
||||
} t_data_parsing;
|
||||
//player -> 0 = x, 1 = y, 2 = head
|
||||
|
||||
//parsing
|
||||
int parsing(t_data *data);
|
||||
|
||||
//check_file
|
||||
int check_extension(char *map_path);
|
||||
int check_file(char *map_path, t_data_parsing *parsing);
|
||||
|
||||
//get_map
|
||||
int get_map(t_data *data);
|
||||
int line_counter(int fd);
|
||||
int put_map_on_array(t_data *data);
|
||||
char *clean_line(char *raw_line);
|
||||
|
||||
//init_parsing
|
||||
int init_parsing(t_data_parsing *parsing);
|
||||
int init_textures(t_textures *textures);
|
||||
int free_textures(t_textures *textures);
|
||||
|
||||
//line_detect
|
||||
int is_config_line(char *line);
|
||||
int is_empty_line(char *line);
|
||||
int is_texture_line(char *line);
|
||||
int is_color_line(char *line);
|
||||
int check_extension_2(char *str);
|
||||
|
||||
//get_textures
|
||||
int get_texture_path(char *line, t_textures *texture, int *j);
|
||||
int validate_and_convert_rgb(char **parts, int rgb[3]);
|
||||
int get_rgb_values(char *line, int rgb[3]);
|
||||
int is_valid_number(char *str);
|
||||
|
||||
//check_colors
|
||||
int check_colors(t_textures *texture);
|
||||
int is_rgb(int color[3]);
|
||||
|
||||
// check_map
|
||||
int check_map_char(char **map);
|
||||
void find_player_pos(char **map, int *player);
|
||||
int flood_fill(char **map_cp, int x, int y);
|
||||
int rep_ex_wall(char **map_cp, int x, int y);
|
||||
int check_char_and_count(char c, int *p);
|
||||
|
||||
//check_map_2
|
||||
int hasivalidchar(char **map);
|
||||
int validate_map(char **map, int *player);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user