-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfill_adjacent_list_2.c
More file actions
80 lines (73 loc) · 2.25 KB
/
fill_adjacent_list_2.c
File metadata and controls
80 lines (73 loc) · 2.25 KB
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
80
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fill_adjacent_list_2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbeaufre <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/15 18:50:04 by rbeaufre #+# #+# */
/* Updated: 2019/12/03 13:59:29 by rbeaufre ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
int ft_check_room_exists(t_list **list, long hash, t_params **params)
{
t_list *tmp;
t_node *node;
tmp = *list;
while (tmp && tmp->content && ((t_node *)tmp->content)->name)
{
node = (t_node *)tmp->content;
if (node->name_hash == hash)
{
ft_strdel(&((*params)->non_fatal_error_type));
(*params)->non_fatal_error_type = ft_strdup("Room already exists");
return (node->id);
}
tmp = tmp->next;
}
return (-1);
}
int ft_check_tunnel_rooms_exist(t_list **list, long hash0,
long hash1, t_params **params)
{
t_list *tmp;
t_node *node;
int count;
count = 0;
tmp = *list;
while (tmp && tmp->content)
{
node = (t_node *)tmp->content;
if (node->name_hash == hash0 || node->name_hash == hash1)
count++;
tmp = tmp->next;
}
if (count == 2)
return (1);
else
{
ft_strdel(&((*params)->non_fatal_error_type));
(*params)->non_fatal_error_type = ft_strdup("Tunnel room not found");
return (-1);
}
}
int ft_check_coords_exist(t_list **list, int x, int y, t_params **params)
{
t_list *tmp;
t_node *node;
tmp = *list;
node = (t_node *)tmp->content;
while (tmp && tmp->content)
{
node = (t_node *)tmp->content;
if (x == node->x_coord && y == node->y_coord)
{
ft_strdel(&((*params)->non_fatal_error_type));
(*params)->non_fatal_error_type = ft_strdup("Coords already exist");
return (1);
}
tmp = tmp->next;
}
return (0);
}