-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.c
78 lines (70 loc) · 1.98 KB
/
routes.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* routes.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oltkache <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/05/13 10:55:44 by oltkache #+# #+# */
/* Updated: 2018/05/13 10:55:45 by oltkache ### ########.fr */
/* */
/* ************************************************************************** */
#include "lemin.h"
void ft_help_add(t_room *tmp, char *s, t_node **nodes)
{
ft_find_rooom(&tmp, s);
ft_add_node(nodes, tmp);
}
void ft_get_nodes(t_room **rooms, t_link *links)
{
t_room *tmp;
t_link *l;
t_room *h;
t_room *start;
h = *rooms;
while (h)
{
l = links;
h->nodes = (t_node*)malloc(sizeof(t_node));
h->nodes->next = NULL;
while (l)
{
tmp = *rooms;
if (ft_strcmp(l->s1, h->name) == 0)
ft_help_add(tmp, l->s2, &(h->nodes));
if (ft_strcmp(l->s2, h->name) == 0)
ft_help_add(tmp, l->s1, &(h->nodes));
l = l->next;
}
if (h->start == 1)
start = h;
h = h->next;
}
}
void create_route(t_route **route, t_room *rooms)
{
t_room *add;
add = NULL;
*route = (t_route*)malloc(sizeof(t_route));
ft_roomadd(&add, rooms->x, rooms->y, rooms->name);
add->id = 1;
(*route)->rooms = add;
(*route)->next = NULL;
}
void ft_mark(t_room **rooms, char *name)
{
t_room *tmp;
tmp = *rooms;
while (*rooms)
{
if (ft_strcmp((*rooms)->name, name) == 0)
{
if ((*rooms)->end != 1)
(*rooms)->id = 1;
*rooms = tmp;
return ;
}
(*rooms) = (*rooms)->next;
}
*rooms = tmp;
}