-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_sphere.c
More file actions
58 lines (53 loc) · 1.67 KB
/
add_sphere.c
File metadata and controls
58 lines (53 loc) · 1.67 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* add_sphere.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: walnaimi <walnaimi@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/10 16:15:02 by sataskin #+# #+# */
/* Updated: 2025/01/09 14:08:24 by walnaimi ### ########.fr */
/* */
/* ************************************************************************** */
#include "minirt.h"
static int arguments(char **values, int amount)
{
int i;
i = 0;
if (values == NULL)
return (1);
if (values[0] == NULL)
return (1);
while (values[i] != NULL)
i++;
if (i == amount)
return (0);
else
return (1);
}
void add_sphere(char **values, t_minirt *rt)
{
t_arg *new;
rt->sp_count++;
if (arguments(values, 4) > 0)
{
free_split(values);
free_minirt(rt, "ERROR: Invalid Sphere\n");
}
new = ft_calloc(1, sizeof(t_arg));
if (!new)
{
free_split(values);
free_minirt(rt, "Error: MALLOC FAIL\n");
}
new->next = NULL;
new->sp = 1;
if (add_coor(values[1], new) == 1 || add_colors(values[3], new) == 1
|| add_diameter(values[2], new) == 1)
{
free_split(values);
free(new);
free_minirt(rt, "Error: Invalid Input\n");
}
ft_lstadd_back_rt(&rt->l_list, new);
}