-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_error.c
More file actions
74 lines (69 loc) · 2.39 KB
/
utils_error.c
File metadata and controls
74 lines (69 loc) · 2.39 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
72
73
74
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcogne-- <mcogne--@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/01 06:34:55 by mcogne-- #+# #+# */
/* Updated: 2024/11/09 20:38:23 by mcogne-- ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void ft_msg_error_textures(char *msg_error, t_mlx *mlx)
{
mlx_destroy_window(mlx->mlx_id, mlx->window);
mlx_loop_end(mlx->mlx_id);
mlx_destroy_display(mlx->mlx_id);
free_struct_mlx(mlx);
ft_putstr_fd("Error.\n", 0);
ft_putstr_fd(msg_error, 0);
ft_putstr_fd("\n", 0);
exit(EXIT_FAILURE);
}
void ft_msg_error_exit_user(char *msg_error, t_mlx *mlx)
{
mlx_destroy_window(mlx->mlx_id, mlx->window);
free_struct_img(mlx, mlx->img);
mlx_loop_end(mlx->mlx_id);
mlx_destroy_display(mlx->mlx_id);
free_struct_map(mlx->map);
free_struct_mlx(mlx);
ft_putstr_fd("Error.\n", 0);
ft_putstr_fd(msg_error, 0);
ft_putstr_fd("\n", 0);
exit(EXIT_FAILURE);
}
void put_error(short error, t_mlx *mlx, t_map *map)
{
free_struct_map(map);
if (error == 0)
return ;
if (error == 1)
ft_msg_put_exrror(ERROR_MSG_CHARAC);
if (error == 2)
ft_msg_put_exrror(ERROR_MSG_ITEM_START_END);
if (error == 3)
ft_msg_put_exrror(ERROR_MSG_MAP_RECTANGULAR);
if (error == 4)
ft_msg_put_exrror(ERROR_MSG_MAP_CLOSED_WALL);
if (error == 5)
ft_msg_put_exrror(ERROR_MSG_MAP_VALID_PATH);
if (error == 6)
ft_msg_put_exrror(ERROR_MSG_STRUCTURE);
if (error == 8)
ft_msg_error_textures(ERROR_MSG_STRUCTURE_LOAD, mlx);
free_struct_img(mlx, mlx->img);
free_struct_mlx(mlx);
if (error == 7)
ft_msg_put_exrror(ERROR_MSG_MLX_WIN);
if (error == 9)
ft_msg_put_exrror(ERROR_MSG_MLX_LOOP);
}
void ft_msg_put_exrror(char *msg_error)
{
ft_putstr_fd("Error.\n", 0);
ft_putstr_fd(msg_error, 0);
ft_putstr_fd("\n", 0);
exit(EXIT_FAILURE);
}