Parsing finished
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/11/25 19:47:38 by aortigos #+# #+# */
|
/* Created: 2025/11/25 19:47:38 by aortigos #+# #+# */
|
||||||
/* Updated: 2025/11/25 19:51:54 by aortigos ### ########.fr */
|
/* Updated: 2025/11/28 19:58:50 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -34,7 +34,26 @@ int read_map(char *av, t_data *map, int *count)
|
|||||||
|
|
||||||
void get_x_y_player(t_data *data)
|
void get_x_y_player(t_data *data)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (data->sq_map[i])
|
||||||
|
{
|
||||||
|
j = 0;
|
||||||
|
while (data->sq_map[i][j])
|
||||||
|
{
|
||||||
|
if (data->sq_map[i][j] == 'N' || data->sq_map[i][j] == 'S'
|
||||||
|
|| data->sq_map[i][j] == 'W' || data->sq_map[i][j] == 'E')
|
||||||
|
{
|
||||||
|
data->p_x = j;
|
||||||
|
data->p_y = i;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_extension_map(char *file)
|
int check_extension_map(char *file)
|
||||||
@@ -47,5 +66,20 @@ int check_extension_map(char *file)
|
|||||||
|
|
||||||
int parsing(int ac, char **av, t_data *data)
|
int parsing(int ac, char **av, t_data *data)
|
||||||
{
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (ac != 2 || !check_extension_map(av[1]))
|
||||||
|
return (ft_putstr_fd(ERR_INV_COP, 2), 0);
|
||||||
|
count = 0;
|
||||||
|
if (!read_map(av[1], data, &count))
|
||||||
|
return (0);
|
||||||
|
if (!valid_map(data))
|
||||||
|
return (0);
|
||||||
|
data->t_list = NULL;
|
||||||
|
if (!lst_ture(data, &data->t_list))
|
||||||
|
return (free_map(data), freelist(&data->t_list), 0);
|
||||||
|
if (!color_ture(data, data->t_list))
|
||||||
|
return (free_map(data), freelist(&data->t_list), 0);
|
||||||
|
get_x_y_player(data);
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user