15static void put_error_map_size_over(
int cols,
int rows)
17 ft_eprintf(
"%s%s: ", ERR_PROMPT, EMSG_MAP_TOO_LARGE);
18 ft_eprintf(
"%d x %d", cols, rows);
19 ft_eprintf(
" (within %d x %d)\n", MAX_COLS, MAX_ROWS);
22int check_range_map(
const char *line,
t_parse *parse)
32 while (line != NULL && ft_strchr(line,
'\n') != NULL)
34 len = ft_strchr(line,
'\n') - line;
38 if (cols > MAX_COLS || rows > MAX_ROWS)
40 line = find_next_line(line);
42 if (is_over_size ==
true)
44 put_error_map_size_over((
int)cols, (
int)rows);
45 return (EXIT_FAILURE);
48 return (EXIT_SUCCESS);
51int parse_map(
const char *line,
t_parse *parse)
53 static t_parse_map func[5] = {
54 check_last_map, check_range_map, get_map_data,
55 get_player_info, check_enclosed_by_walls};
62 status = func[i](line, parse);
63 if (status != EXIT_SUCCESS)
64 return (EXIT_FAILURE);
67 parse->flag |= BIT_MAP;
68 return (EXIT_SUCCESS);