-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_error_handling.c
More file actions
71 lines (66 loc) · 2.23 KB
/
ft_error_handling.c
File metadata and controls
71 lines (66 loc) · 2.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_error_handling.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apeposhi <apeposhi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/17 10:24:31 by apeposhi #+# #+# */
/* Updated: 2023/07/21 21:49:12 by apeposhi ### ########.fr */
/* */
/* ************************************************************************** */
#include "./include/so_long.h"
void ft_cleanup(t_data *g_d)
{
if (g_d->mlx == NULL)
return ;
mlx_clear_window(g_d->mlx, g_d->wdw);
if (g_d->images.pl)
mlx_destroy_image(g_d->mlx, g_d->images.pl);
if (g_d->images.pl2)
mlx_destroy_image(g_d->mlx, g_d->images.pl2);
if (g_d->images.enemy)
mlx_destroy_image(g_d->mlx, g_d->images.enemy);
if (g_d->images.wall)
mlx_destroy_image(g_d->mlx, g_d->images.wall);
if (g_d->images.empty)
mlx_destroy_image(g_d->mlx, g_d->images.empty);
if (g_d->images.cll)
mlx_destroy_image(g_d->mlx, g_d->images.cll);
if (g_d->images.fnsh)
mlx_destroy_image(g_d->mlx, g_d->images.fnsh);
if (g_d->images.win)
mlx_destroy_image(g_d->mlx, g_d->images.win);
if (g_d->images.lose)
mlx_destroy_image(g_d->mlx, g_d->images.lose);
mlx_destroy_window(g_d->mlx, g_d->wdw);
}
void ft_init(t_data *g_d)
{
g_d->mlx = NULL;
g_d->wdw = NULL;
g_d->c_state = NULL;
g_d->images.cll = NULL;
g_d->images.empty = NULL;
g_d->images.enemy = NULL;
g_d->images.fnsh = NULL;
g_d->images.lose = NULL;
g_d->images.pl2 = NULL;
g_d->images.pl = NULL;
g_d->images.wall = NULL;
g_d->images.win = NULL;
}
int ft_free(t_data *g_d, int return_value)
{
int i;
if (g_d->c_state != NULL)
{
i = 0;
while (g_d->c_state[i] != 0)
free(g_d->c_state[i++]);
free(g_d->c_state);
g_d->c_state = NULL;
}
ft_cleanup(g_d);
return (return_value);
}