fix: use same t_map in all code

This commit is contained in:
Camille Chauvet
2023-05-05 11:35:52 +00:00
parent c9d9faa45c
commit c9ac445103
5 changed files with 10 additions and 36 deletions

View File

@ -10,8 +10,8 @@ typedef struct s_map
void *img[4];
long long color_bot;
long long color_top;
long long spawn_x;
long long spawn_y;
double ply_x;
double ply_y;
char direction;
} t_map;

View File

@ -83,7 +83,7 @@ t_map *map_parsing(const char *path)
return (NULL);
}
map->map = body;
map->direction = map->map[map->spawn_y][map->spawn_x];
map->map[map->spawn_y][map->spawn_x] = '0';
map->direction = map->map[(size_t) map->ply_y][(size_t) map->ply_x];
map->map[(size_t) map->ply_y][(size_t) map->ply_x] = '0';
return (map);
}

View File

@ -30,7 +30,7 @@ char **get_body(const char **file_content, size_t header_size)
return (body);
}
int get_spawn_position(const char **body, long long *spawn_x, long long *spawn_y)
int get_spawn_position(const char **body, double *spawn_x, double *spawn_y)
{
size_t x;
size_t y;
@ -160,7 +160,7 @@ int body_is_valid(const char **body, t_map *map)
if (body == NULL)
return (0);
error = get_spawn_position(body, &map->spawn_x, &map->spawn_y);
error = get_spawn_position(body, &map->ply_x, &map->ply_y);
if (error == 1)
{
ft_eprintf("map: spawn position: multiple definition");