Firstcommit

This commit is contained in:
root
2025-08-25 20:07:37 +00:00
commit 8eea3162d5
123 changed files with 2680 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifndef CUB_H
#define CUB_H
#include "parsing.h"
#include "messages.h"
#include "../libft/include/libft.h"
#include "../gnl/include/get_next_line.h"
typedef struct s_data
{
char **map;
char *map_path;
t_textures *texture;
t_data_parsing parsing;
} t_data;
//////utils/////
//utils
void ft_error(char *message);
void free_char_array(char **array);
//init
int init_data(t_data *data, char *path);
void free_data(t_data *data);
/////debug
void print_char_array_debug(char **arr, char *name);
#endif
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* messages.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/22 15:00:45 by lfirmin #+# #+# */
/* Updated: 2025/08/22 15:01:20 by lfirmin ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MESSAGE_H
#define MESSAGE_H
#define ERROR_PREFIX "\033[1m[❌]\033[0m\033[1;31mError\033[0m: "
#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."
#define DEBUG "test"
#endif
+72
View File
@@ -0,0 +1,72 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/22 14:08:04 by lfirmin #+# #+# */
/* Updated: 2025/08/22 14:18:06 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; //Path to texture.xmp
char *south; //Path to texture.xmp
char *east; //Path to texture.xmp
char *west; //Path to texture.xmp
int floor[3]; //RGB: [0] = R, [1] = G, [2] = B
int ceiling[3]; //RGB: [0] = R, [1] = G, [2] = B
} t_textures;
typedef struct s_data_parsing
{
char **raw_map;
int fd_map;
int fd_map_dup;
} t_data_parsing;
//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);
//get_textures
int get_texture_path(char *line, t_textures *texture);
int get_rgb_values(char *line, int rgb[3]);
//check_colors
int check_colors(t_textures *texture);
int is_rgb(int color[3]);
#endif