-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomless_functions.c
More file actions
57 lines (51 loc) · 1.61 KB
/
homless_functions.c
File metadata and controls
57 lines (51 loc) · 1.61 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* homless_functions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nosahimi <nosahimi@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/21 01:45:59 by nosahimi #+# #+# */
/* Updated: 2025/03/27 02:30:32 by nosahimi ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void is_valid_extension(char *path)
{
if (!path)
(fd_putstr("ERROR\nINVALID EXTENSION\n", 2), exit(1));
while (*path != '.')
path++;
if (*(path - 1) == '/' || ft_strcmp(path, ".ber") != 0)
(fd_putstr("ERROR\nINVALID EXTENSION\n", 2), exit(1));
}
int is_rectangular(t_game game)
{
if (game.rectangle == 1)
(fd_putstr("ERROR\nMAP IS NOT RECTANGULAR\n", 2), exit(1));
return (0);
}
int is_all_one(char *str)
{
if (!str)
return (0);
while (*str)
{
if (*str != '1')
return (0);
str++;
}
return (1);
}
void count_moves(int nb)
{
if (nb >= 10)
count_moves(nb / 10);
ft_putchar((nb % 10) + 48);
}
void print_moves(t_game *game)
{
write(1, "moves : ", 8);
count_moves(game->moves);
write(1, "\n", 1);
}