-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.c
More file actions
50 lines (46 loc) · 1.92 KB
/
Copy patherror.c
File metadata and controls
50 lines (46 loc) · 1.92 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoulati <mmoulati@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/10 13:30:51 by mmoulati #+# #+# */
/* Updated: 2025/03/10 23:20:01 by mmoulati ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft/libft.h"
#include "so_long.h"
#include <stdio.h>
#define ERR_MSG "\033[1;31mError\n\t"
void ft_perror(char *str)
{
ft_putstr_fd(ERR_MSG, 2);
perror(str);
exit(1);
}
void ft_map_error(t_map **map, t_map_state state)
{
if (state == OK)
return ;
ft_putstr_fd(ERR_MSG, 2);
if (state == ERR_FILENAME_INVALID)
ft_putstr_fd("Invalid filename.", 2);
if (state == ERR_MAP_CHAR_INVALID)
ft_putstr_fd("The map contains an invalid character.", 2);
if (state == ERR_MAP_COLLECTABLE)
ft_putstr_fd("The map must contain at least one collectable.", 2);
if (state == ERR_MAP_NOT_CLOSED)
ft_putstr_fd("The map is not closed.", 2);
if (state == ERR_MAP_PATH_INVALID)
ft_putstr_fd("The map is not solvable.", 2);
if (state == ERR_MAP_NOT_RECTANGLE)
ft_putstr_fd("The map must be rectangular.", 2);
if (state == ERR_MAP_ONE_EXIT)
ft_putstr_fd("The map must contain exactly one exit.", 2);
if (state == ERR_MAP_ONE_PLAYER)
ft_putstr_fd("The map must contain exactly one player.", 2);
ft_putstr_fd("\n\033[0m", 2);
ft_map_destroy(map);
exit(1);
}