「🏗️」 wip: parsing map nighty percent done
This commit is contained in:
6
Makefile
6
Makefile
@ -14,7 +14,11 @@ MACRO_DIR = MacroLibX/
|
|||||||
|
|
||||||
INCLUDE = -I $(I_DIR) -I $(LIBFT_DIR)/$(I_DIR) -I $(MACRO_DIR)/$(I_DIR)
|
INCLUDE = -I $(I_DIR) -I $(LIBFT_DIR)/$(I_DIR) -I $(MACRO_DIR)/$(I_DIR)
|
||||||
|
|
||||||
SRCS = $(shell find src -name '*.c')
|
SRCS = src/utils/mess_error.c \
|
||||||
|
src/utils/parse_utils.c \
|
||||||
|
src/parsing/check_map.c \
|
||||||
|
src/parsing/check_arg.c \
|
||||||
|
src/cub3d.c
|
||||||
|
|
||||||
OBJS = $(addprefix $(OBJSDIR), $(SRCS:.c=.o))
|
OBJS = $(addprefix $(OBJSDIR), $(SRCS:.c=.o))
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */
|
/* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */
|
||||||
/* Updated: 2024/09/11 14:53:49 by madumerg ### ########.fr */
|
/* Updated: 2024/09/11 22:16:46 by madumerg ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,9 +14,11 @@
|
|||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
|
char **map;
|
||||||
|
|
||||||
if (check_err_arg(ac, av) == 1)
|
if (check_err_arg(ac, av) == 1)
|
||||||
return (1);
|
return (1);
|
||||||
char **map = parse_map(av[1]);
|
map = parse_map(av[1]);
|
||||||
if (verif_all_map(map) == 1)
|
if (verif_all_map(map) == 1)
|
||||||
return (1);
|
return (1);
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/04 21:33:35 by madumerg #+# #+# */
|
/* Created: 2024/09/04 21:33:35 by madumerg #+# #+# */
|
||||||
/* Updated: 2024/09/11 11:19:25 by madumerg ### ########.fr */
|
/* Updated: 2024/09/11 22:12:13 by madumerg ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -43,4 +43,3 @@ int check_format_file(char *file)
|
|||||||
return (1);
|
return (1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,23 +6,89 @@
|
|||||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/11 11:24:13 by madumerg #+# #+# */
|
/* Created: 2024/09/11 11:24:13 by madumerg #+# #+# */
|
||||||
/* Updated: 2024/09/11 15:24:53 by madumerg ### ########.fr */
|
/* Updated: 2024/09/11 22:14:44 by madumerg ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "cub3d.h"
|
#include "cub3d.h"
|
||||||
|
|
||||||
|
int err_not_close(char after, char before, char down, char up)
|
||||||
|
{
|
||||||
|
if (after == ' ' || after == '\0')
|
||||||
|
return (1);
|
||||||
|
else if (before == ' ' || before == '\0')
|
||||||
|
return (1);
|
||||||
|
else if (down == ' ' || down == '\0')
|
||||||
|
return (1);
|
||||||
|
else if (up == ' ' || up == '\0')
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int actual_char(char actual)
|
||||||
|
{
|
||||||
|
if (actual == '0' || actual == 'N' || actual == 'W' || \
|
||||||
|
actual == 'S' || actual == 'E')
|
||||||
|
return (0);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int check_map_close(char **map)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
y = 0;
|
||||||
|
while (map[y])
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
while (map[y][x])
|
||||||
|
{
|
||||||
|
if (actual_char(map[y][x]) == 0 && \
|
||||||
|
(err_not_close(map[y][x + 1], map[y][x - 1], \
|
||||||
|
map[y + 1][x], map[y - 1][x]) == 1))
|
||||||
|
return (1);
|
||||||
|
else
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int count_player(char **map)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
int x;
|
||||||
|
int cpt;
|
||||||
|
|
||||||
|
cpt = 0;
|
||||||
|
y = 0;
|
||||||
|
while (map[y])
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
while (map[y][x])
|
||||||
|
{
|
||||||
|
if (map[y][x] == 'N' || map[y][x] == 'S' || \
|
||||||
|
map[y][x] == 'E' || map[y][x] == 'W')
|
||||||
|
cpt++;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if (cpt != 1)
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int verif_all_map(char **map)
|
int verif_all_map(char **map)
|
||||||
{
|
{
|
||||||
if (check_char_map(map) == 1)
|
if (check_char_map(map) == 1)
|
||||||
return (err_mess(WRONG_CHAR));
|
return (err_mess(WRONG_CHAR));
|
||||||
return (0);
|
if (count_player(map) == 1)
|
||||||
}
|
return (err_mess(ERR_PLAYER));
|
||||||
|
if (check_map_close(map) == 1)
|
||||||
int verif_char(char c)
|
return (err_mess(NOT_CLOSE));
|
||||||
{
|
|
||||||
if (c != '1' && c != '0' && c != 'N' && c != 'S' && c != 'W' && c != 'E' && c != ' ')
|
|
||||||
return (1);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,5 +136,3 @@ char **parse_map(char *map)
|
|||||||
close(fd);
|
close(fd);
|
||||||
return (parse_map);
|
return (parse_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
//envoyer de 4 a 5 inclus dans check rgb format
|
//envoyer de 4 a 5 inclus dans check rgb format
|
||||||
//envoyer de 6 a jusqu a la fin dans check map
|
//envoyer de 6 a jusqu a la fin dans check map
|
||||||
|
|
||||||
// convertir tt les whites spaces en simple espace
|
// convertir tt les whites spaces en simple espace //prblm avec les tab
|
||||||
|
|
||||||
struct typedef s_pars
|
struct typedef s_pars
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/11 14:20:54 by madumerg #+# #+# */
|
/* Created: 2024/09/11 14:20:54 by madumerg #+# #+# */
|
||||||
/* Updated: 2024/09/11 14:31:27 by madumerg ### ########.fr */
|
/* Updated: 2024/09/11 22:15:23 by madumerg ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -24,3 +24,11 @@ void convert_white_s(char *str)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int verif_char(char c)
|
||||||
|
{
|
||||||
|
if (c != '1' && c != '0' && c != 'N' && c != 'S' && c != 'W' && \
|
||||||
|
c != 'E' && c != ' ')
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user