-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparsing_utils.c
69 lines (62 loc) · 1.83 KB
/
parsing_utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vilibert <vilibert@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/12 15:18:12 by jgoudema #+# #+# */
/* Updated: 2024/04/12 11:16:25 by vilibert ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void fill_player_infos(t_data *data, double dir[2], double plane[2])
{
data->player->dir.x = dir[0];
data->player->dir.y = dir[1];
data->player->plane.x = plane[0];
data->player->plane.y = plane[1];
}
void add_color(char t, t_data *data)
{
if (t == 'C')
data->map->fc[1]++;
else if (t == 'F')
data->map->fc[0]++;
}
char *strdup_to(char *line, int start)
{
char *path;
int j;
j = 0;
while (line[start] && line[start] == ' ')
start++;
path = malloc(ft_strlen(line) - start + 1);
if (!path)
return (NULL);
while (line[start] && line[start] != '\n' && line[start] != ' ')
path[j++] = line[start++];
path[j] = 0;
return (path);
}
char *fill_line(t_data *data, char *str)
{
size_t i;
char *s;
s = malloc(data->map->max + 1);
if (!s)
free_all(ERR_MALLOC, 2, data);
i = 0;
while (str[i])
{
s[i] = str[i];
if (s[i] == '\n')
s[i] = ' ';
i++;
}
while (i < data->map->max)
s[i++] = ' ';
s[i] = 0;
free(str);
return (s);
}