-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.c
79 lines (69 loc) · 1.08 KB
/
usage.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
79
#include "lem_in.h"
void ft_error(int id)
{
if (id == 1 || id == 2)
{
id == 1 ? ft_printf("ERROR\n") : 0;
id == 2 ? ft_printf("ERROR\n") : 0;
exit(0);
}
}
void print_ants(int *ant, char *s, t_lemin **lemin, int id)
{
char *end;
end = is_end(lemin);
if (!id)
ft_printf(RED"L%d-%s "END, *ant, s);
if (s && id && ft_strcmp(end, s))
ft_printf(GRN"L%d-%s "END, *ant, s);
if (s && !ft_strcmp(end, s))
ft_printf(BLU"L%d-%s "END, *ant, s);
}
void *free_twodem_str(char **s)
{
int i;
i = 0;
while (s[i])
{
free(s[i]);
s[i] = NULL;
i++;
}
free(s);
return (NULL);
}
int move_all_old(t_routes **routes, t_lemin **lemin)
{
t_routes *rs;
t_route *r;
rs = (*routes);
while (rs)
{
r = rs->route->next;
while (r->next->room)
{
if (!r->move && r->ant)
return (0);
r = r->next;
}
rs = rs->next;
}
return (1);
}
void move_all_null(t_routes **routes, t_lemin **lemin)
{
t_routes *rs;
t_route *r;
rs = (*routes);
while (rs)
{
r = rs->route->next;
while (r->next->room)
{
if (r->move)
r->move = 0;
r = r->next;
}
rs = rs->next;
}
}