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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_init_map.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joelecle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:22:42 by joelecle #+# #+# */
/* Updated: 2020/02/14 17:23:42 by joelecle ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stdlib.h>
#include <stdint.h>
static int8_t
ft_init_map_callocs(t_map *mlist)
{
if (!(mlist->filename = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->so_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->sprite_path = (char**)ft_calloc(9, sizeof(char*))) ||
!(mlist->nl_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->fl_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->ce_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->nlevel_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->traps_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->music_path = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->music_cmd = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) ||
!(mlist->map = (char**)ft_calloc(2, sizeof(char*))) ||
!(mlist->map[0] = (char*)ft_calloc(1, sizeof(char))))
return (-1);
return (0);
}
static int8_t
ft_calloc_sprites_path(t_map *mlist)
{
uint8_t i;
i = 0;
while (i < 9)
{
if (!(mlist->sprite_path[i] = (char*)ft_calloc(1, sizeof(char))))
return (-1);
i++;
}
return (0);
}
int8_t
ft_init_map_norme(t_map *mlist)
{
int8_t i;
mlist->darklvl = 0;
mlist->scale = 0;
mlist->nlx = 0;
mlist->nly = 0;
mlist->sprite_var = 0;
mlist->topsp = 0;
ft_bzero(mlist->sprite_nbr, (int)FT_TOTAL_SPRT * sizeof(int16_t));
i = -1;
while (++i < FT_TOTAL_SPRT)
ft_bzero(mlist->sprite_order[i], 4096);
ft_bzero(mlist->st_o, FT_TOTAL_SPRT + 1);
return (0);
}
int8_t
ft_init_map(t_map *mlist)
{
if (ft_init_map_callocs(mlist) < 0)
return (-1);
mlist->map[1] = 0;
if (ft_calloc_sprites_path(mlist) < 0)
return (-1);
mlist->map_w = 0;
mlist->map_h = 0;
mlist->mapl_len = 0;
mlist->x_step = 0;
mlist->y_step = 0;
mlist->line_chk = 0;
mlist->map_start = 0;
mlist->isspawn = 0;
mlist->isftex = 0;
mlist->isctex = 0;
mlist->isnlvl = 0;
mlist->ismusic = 0;
mlist->enemy = 1;
mlist->istraps = 0;
mlist->isheals = 0;
return (ft_init_map_norme(mlist));
}
|