Created parsing.c
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* cub3d.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/25 19:47:02 by aortigos #+# #+# */
|
||||
/* Updated: 2025/11/25 19:50:36 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CUB3D_H
|
||||
|
||||
@@ -17,4 +28,10 @@
|
||||
# define PLAYER_SPEED 3
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
int read_map(char *av, t_data *map, int *count);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
51
src/parsing/parsing.c
Normal file
51
src/parsing/parsing.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parsing.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/25 19:47:38 by aortigos #+# #+# */
|
||||
/* Updated: 2025/11/25 19:51:54 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/cub3d.h"
|
||||
|
||||
int read_map(char *av, t_data *map, int *count)
|
||||
{
|
||||
map->fd = open(av, O_RDONLY);
|
||||
if (map->fd == -1)
|
||||
return (ft_putstr_fd(ERR_INV_FILE, 2), 0);
|
||||
map->line = get_next_line(map->fd);
|
||||
if (map->line == NULL)
|
||||
return (ft_putstr_fd(ERR_EMPTY_FILE, 2), 0);
|
||||
map->ture = ft_strdup("");
|
||||
process_map(map, count);
|
||||
if (!check_count_textures(map, *count))
|
||||
return (freetl(map->ture, map->line, map->fd), 0);
|
||||
map->ture2d = ft_split(map->ture, '\n');
|
||||
if (!map->ture2d)
|
||||
return (freetl(map->ture, map->line, map->fd), 0);
|
||||
if (!read_map_(map, *count))
|
||||
return (freetl(map->ture, map->line, map->fd), free2d(map->ture2d), 0);
|
||||
return (freetl(map->ture, map->line, map->fd), 1);
|
||||
}
|
||||
|
||||
void get_x_y_player(t_data *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int check_extension_map(char *file)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = ft_strrchr(file, '.');
|
||||
return (str && !ft_strcmp(str, ".cub"));
|
||||
}
|
||||
|
||||
int parsing(int ac, char **av, t_data *data)
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user