correction z negatifs pour colros

This commit is contained in:
hugogogo
2021-07-24 16:36:44 +02:00
parent 04ef5aab68
commit 331e1f3388
193 changed files with 23 additions and 6095 deletions

View File

@@ -1,31 +1,35 @@
#include "fdf.h"
void z_amplitude(t_fdf*fdf, int i)
{
if (i > fdf->max_z)
fdf->max_z = i;
if (i < fdf->min_z)
fdf->min_z = i;
}
int **split_to_map(t_fdf *fdf, char *raw)
{
int i;
int j;
int z;
int **map;
map = ft_calloc(fdf->map_height, sizeof(map));
i = -1;
z = 0;
while (++i < fdf->map_height)
{
map[i] = ft_calloc(fdf->map_width, sizeof(*map));
j = -1;
while (++j < fdf->map_width)
{
while (!ft_isdigit(*raw))
while (*raw == ' ' || *raw == '!')
raw++;
map[i][j] = ft_atoi(raw);
while (ft_isdigit(*raw))
while (ft_isdigit(*raw) || *raw == '-')
raw++;
if (map[i][j] > z)
z = map[i][j];
z_amplitude(fdf, map[i][j]);
}
}
fdf->max_z = z;
return (map);
}
@@ -39,6 +43,8 @@ int size_width(char *raw)
{
while (raw[i] == ' ')
i++;
if (raw[i] == '-')
i++;
while (ft_isdigit(raw[i]))
i++;
j++;
@@ -69,5 +75,7 @@ int **parse_map(t_fdf *fdf, int fd)
}
fdf->map_height = height;
fdf->map_width = size_width(raw);
fdf->min_z = 0;
fdf->max_z = 0;
return (split_to_map(fdf, raw));
}