-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrectangular.c
74 lines (68 loc) · 1.81 KB
/
rectangular.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rectangular.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amezioun <amezioun@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/10 19:46:12 by amezioun #+# #+# */
/* Updated: 2024/07/13 23:59:30 by amezioun ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void ones_line(t_map *mlx, int y)
{
int x;
x = 0;
while (mlx->map[y][x] != '\0')
{
if (mlx->map[y][x] != '1')
ft_error(mlx);
x++;
}
}
int map_len(t_map *mlx)
{
int y;
int len;
int len1;
y = 0;
len = ft_strlen(mlx->map[y]);
len1 = 0;
while (mlx->map[y])
{
len1 = ft_strlen(mlx->map[y]);
if (len != ft_strlen(mlx->map[y]))
return (1);
else if (mlx->map[y][0] != '1')
return (1);
else if (mlx->map[y][len1 - 1] != '1')
return (1);
else if (check(mlx->map[y]) == 1)
return (1);
y++;
}
ones_line(mlx, y - 1);
if (map_check(mlx) == 1)
return (1);
else
return (0);
}
int map_rectangular(t_map *mlx)
{
mlx->x = 0;
mlx->y = 0;
ones_line(mlx, 0);
if (map_len(mlx) == 1)
ft_error(mlx);
while (mlx->map[mlx->y][mlx->x])
mlx->x++;
while (mlx->map[mlx->y])
mlx->y++;
if (mlx->y > 43 || mlx->x > 80)
{
write(2, "map size bigger then mac size!\n", 31);
exit(1);
}
return (0);
}