int ft_map(char *p, t_m *m, t_p *piece) { char **map; int i; i = 0; if (!(map = ft_strsplit(p, ' '))) return (ft_perror("map ")); m->xm = ft_atoi(map[1]); map[2] = ft_strsub(map[2], 0, ft_strlen(map[2]) - 1); m->ym = ft_atoi(map[2]); free((void *)p); ft_free_char2(map); get_next_line(0, &p); free((void *)p); if (!(m->map = (char **)malloc(sizeof(char *) * (m->xm + 1)))) return (ft_perror("map ")); while (i < m->xm) { get_next_line(0, &p); m->map[i] = ft_strdup(p + 4); ++i; free((void *)p); } m->map[i] = '\0'; return (ft_piece(m, piece)); }
int ft_size_square(t_global *global) { if (global->nb < 5) return (ft_piece(global, 1)); else if (global->nb > 4 && global->nb < 7) return (ft_piece(global, 5)); else if (global->nb > 6 && global->nb < 10) return (ft_piece(global, 6)); else if (global->nb > 9 && global->nb < 13) return (ft_piece(global, 7)); else if (global->nb > 12 && global->nb < 17) return (ft_piece(global, 8)); else if (global->nb > 16 && global->nb < 21) return (ft_piece(global, 9)); else if (global->nb > 20 && global->nb < 26) return (ft_piece(global, 10)); else if (global->nb == 26) return (ft_piece(global, 11)); return (1); }