-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_remove_redundant_path.c
executable file
·42 lines (39 loc) · 1.38 KB
/
ft_remove_redundant_path.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_remove_redundant_path.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ioleksiu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/15 20:27:36 by ioleksiu #+# #+# */
/* Updated: 2017/08/15 20:27:42 by ioleksiu ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
void ft_remove_redundant_path(t_lemin *lem)
{
t_ways *start;
t_ways *next;
int i;
start = lem->ways;
while (start)
{
i = 1;
while (i < lem->room_num && start->way[i] != -1)
{
if (start->way[i] == lem->room_num - 1)
break ;
next = start->next;
if (next == NULL)
break ;
while (next)
{
if (ft_room_in_path(lem->room_num, next->way, start->way[i]))
ft_delete_path(&(lem->ways), &(next));
next = next->next;
}
i++;
}
start = start->next;
}
}