-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf_light.c
54 lines (49 loc) · 1.56 KB
/
f_light.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* f_light.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sboeuf <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/02/16 19:18:02 by sboeuf #+# #+# */
/* Updated: 2014/02/16 19:18:03 by sboeuf ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/rtv1.h"
t_light *get_spots(int fd)
{
int r;
char *line;
t_light *l;
l = NULL;
while ((r = get_next_line(fd, &line)) > 0 && ft_strcmp(line, "----------"))
{
if (!ft_strcmp("new:", line))
{
if (l == NULL)
l = get_spot(fd);
else
add_light(l, get_spot(fd));
}
}
if (r == -1)
exit (-1);
return (l);
}
t_light *get_spot(int fd)
{
int r;
char *line;
t_vect *pos;
t_color *color;
while ((r = get_next_line(fd, &line)) > 0 && ft_strcmp(line, "----------"))
{
if (!ft_strcmp("pos:", line))
pos = get_vector(fd);
if (!ft_strcmp("color:", line))
color = get_color(fd);
}
if (r == -1)
exit(-1);
return (new_light(pos, color));
}