Archived
1
0

sixty_percent

This commit is contained in:
Maelys
2024-09-16 15:09:07 +02:00
parent fa4c3d6d39
commit a6929e15e1
15 changed files with 270 additions and 55 deletions

View File

@ -6,25 +6,24 @@
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/04 16:58:27 by madumerg #+# #+# */
/* Updated: 2024/09/12 16:56:30 by madumerg ### ########.fr */
/* Updated: 2024/09/16 13:54:52 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
#include "libft.h"
#include "parsing.h"
t_pars init_pars(void)
{
t_pars new;
new = ft_calloc(sizeof(t_pars));
if (!new)
return (NULL);
new->f_color = 0;
new->c_color = 0;
new->coor->x = 0;
new->coor->y = 0
new.f_color = 0;
new.c_color = 0;
new.coor.x = 0;
new.coor.y = 0;
new.no_png = NULL;
new.so_png = NULL;
new.we_png = NULL;
new.ea_png = NULL;
return (new);
}
@ -32,10 +31,10 @@ int main(int ac, char **av)
{
t_pars pars;
pars = init_pars(void);
pars = init_pars();
if (check_err_arg(ac, av) == 1)
return (1);
if (verif_info_map(av[1], &pars) == 1)
return (1);
if (verif_info_file(av[1], &pars) == 1)
printf("main\n");
return (0);
}

View File

@ -0,0 +1,98 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_id_text.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/16 09:38:32 by madumerg #+# #+# */
/* Updated: 2024/09/16 14:38:35 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int check_dup_img(t_pars *pars)
{
if (!pars->no_png || !pars->so_png || !pars->we_png || !pars->ea_png)
return (err_mess(NOT_FOUND));
if (ft_strcmp(pars->no_png, pars->so_png) == 0 || \
ft_strcmp(pars->no_png, pars->we_png) == 0 || \
ft_strcmp(pars->no_png, pars->ea_png) == 0 || \
ft_strcmp(pars->so_png, pars->we_png) == 0 || \
ft_strcmp(pars->we_png, pars->ea_png) == 0)
return (err_mess(DUP_IMG));
return (0);
}
int assign_img_two(char *sign, char *path, t_pars *pars)
{
if (ft_strcmp("WE", sign) == 0)
{
if (pars->we_png == NULL)
pars->we_png = path;
else
return (err_mess(DUP_ACR));
}
else if (ft_strcmp("EA", sign) == 0)
{
if (pars->ea_png == NULL)
pars->ea_png = path;
else
return (err_mess(DUP_ACR));
}
return (0);
}
int assign_img(char *sign, char *path, t_pars *pars)
{
if (ft_strcmp("NO", sign) == 0)
{
if (pars->no_png == NULL)
pars->no_png = path;
else
return (err_mess(DUP_ACR));
}
else if (ft_strcmp("SO", sign) == 0)
{
if (pars->so_png == NULL)
pars->so_png = path;
else
return (err_mess(DUP_ACR));
}
if (assign_img_two(sign, path, pars) == 1)
return (1);
return (0);
}
int check_texture(char *sign, char *path, t_pars *pars)
{
int fd;
fd = -1;
fd = open(path, O_RDONLY, 0644);
if (fd < 0)
return (err_mess(ERR_IMG));
if (assign_img(sign, path, pars) == 1)
return (1);
return (0);
}
int detect_info(char **tab, t_pars *pars)
{
if (ft_strcmp("NO", tab[0]) == 0 && count_tab(tab) == 2)
return (check_texture(tab[0], tab[1], pars));
else if (ft_strcmp("SO", tab[0]) == 0 && count_tab(tab) == 2)
return (check_texture(tab[0], tab[1], pars));
else if (ft_strcmp("WE", tab[0]) == 0 && count_tab(tab) == 2)
return (check_texture(tab[0], tab[1], pars));
else if (ft_strcmp("EA", tab[0]) == 0 && count_tab(tab) == 2)
return (check_texture(tab[0], tab[1], pars));
else if (ft_strcmp("F", tab[0]) == 0)
check_format_rgb(tab);
else if (ft_strcmp("C", tab[0]) == 0)
check_format_rgb(tab);
else
return (err_mess(NOT_FOUND));
return (0);
}

View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_rgb.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/16 09:36:07 by madumerg #+# #+# */
/* Updated: 2024/09/16 14:59:30 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int check_format_rgb(char **tab)
{
int i = 0;
while (tab[i])
printf(".%s.\n", tab[i++]);
return (0);
}
int create_argb(int a, int r, int g, int b)
{
return (a << 24 | r << 16 | g << 8 | b);
}

View File

@ -1,6 +1,18 @@
// convertir tt les whites spaces en simple espace sur les 6 1ere lignes
//check si .png
WARNIIIIIINNNNNNNNNNNNNGGG TESTER LES MALLOC A NULL
//faire struct de coor
//faire search player
utiliser la ft pour couleur
no so
no we
no ea
so we
so ea
we ea

View File

@ -6,28 +6,53 @@
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/12 12:44:52 by madumerg #+# #+# */
/* Updated: 2024/09/12 16:49:20 by madumerg ### ########.fr */
/* Updated: 2024/09/16 14:58:26 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int check_info(char **l)
int all_data_verif(char **tab, t_pars *pars)
{
if (detect_info(tab, pars) == 1)
return (1);
return (0);
}
int verif_info_map(char *av)
int check_info(char **l, t_pars *pars)
{
char **tab;
int i;
i = 0;
tab = ft_calloc(sizeof(char *), 6);
if (!tab)
return (1);
while (l[i])
{
tab = ft_split(l[i], ' ');
if (all_data_verif(tab, pars) == 1)
return (1);
i++;
}
return (0);
}
int verif_info_file(char *av, t_pars *pars)
{
char **map;
char **f_part;
(void)pars;
map = parse_map(av);
f_part = info_map(map);
if (check_info(f_part) == 1)
return (1);
if (verif_all_map(map) == 1)
if (check_info(f_part, pars) == 1)
return (1);
// if (check_dup_img(pars) == 1)
// return (1);
// if (verif_all_map(map) == 1)
// return (1);
return (0);
}
int verif_all_map(char **map)

View File

@ -6,27 +6,50 @@
/* By: madumerg <madumerg@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/11 14:20:54 by madumerg #+# #+# */
/* Updated: 2024/09/12 16:20:31 by madumerg ### ########.fr */
/* Updated: 2024/09/16 14:55:36 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int space_line(char *line)
{
int i;
i = 0;
convert_white_s(line);
while (line[i])
{
if (line[i] == ' ' || (line[i] >= 9 && line[i] <= 13))
i++;
else
break ;
}
if (line[i] != '\0')
return (1);
return (0);
}
char **info_map(char **file)
{
char **f_part;
int i;
int j;
int i;
int j;
i = 0;
j = 0;
f_part = ft_calloc(6, sizeof(char *));
if (!f_part)
return (NULL);
while (i < 6)
while (i >= j)
{
f_part[j] = file[i];
j++;
if (j == 6)
break ;
if (space_line(file[i]) == 1)
{
f_part[j] = file[i];
j++;
}
i++;
}
return (f_part);
@ -52,3 +75,18 @@ int verif_char(char c)
return (1);
return (0);
}
int count_tab(char **tab)
{
int i;
int ct;
i = 0;
ct = 0;
while (tab[i])
{
i++;
ct++;
}
return (ct);
}