int ft_read_second(int fd) { int y; char *tmp; char buf; y = 0; tmp = "\0"; while ((read(fd, &buf, 1)) && buf != '\n') { if ((buf != g_carac[0]) && (buf != g_carac[1])) return (0); tmp = ft_strcat(tmp, buf); g_x++; } tmp = ft_strcat(tmp, buf); if (!(ft_create_map())) return (0); g_map[y++] = tmp; while ((read(fd, g_map[y], g_x + 1)) && g_map[y]) y++; if (y != g_y) return (0); return (ft_check_map(y)); }
void ft_loop_bsq(int ac, char **av) { unsigned long long ret2; char *buf; t_bsq_data data; char **bsq; int i; i = 1; while (i < ac) { ret2 = ft_get_swap(i, av); buf = ft_read(ret2); data = ft_get_infos(buf, ret2); bsq = ft_get_bsq(data, buf); if ((ft_check_map(bsq, data) == FALSE)) write(2, "map error\n", 10); else { bsq = ft_fill_square(bsq, data, ft_check_tab(bsq, data)); ft_print_bsq(bsq, data); } ft_free_bsq(bsq, data); i++; } }
int main(int ac, char **av) { int fd; t_pos *wolf; wolf = ft_init_wolf(); if (ac != 2) ft_error(0); else { fd = ft_take_map(av[1]); ft_check_map(fd, wolf); close(fd); ft_open_window(wolf); } return (0); }
char *ft_strsub(char const *s, unsigned int start, size_t len) { size_t i; char *str; i = 0; if ((str = (char *)malloc(sizeof(*str) * len + 1))) { while (i < len) { str[i] = s[start + i]; i++; } str[i] = '\0'; return (ft_check_map(str)); } return (NULL); }
void ft_first_spawn(t_id *s, char **argv) { s->posx = ft_atoi(argv[2]); s->posy = ft_atoi(argv[3]); s->fd = open(argv[1], O_RDONLY); s->nl = 0; while ((get_next_line(s->fd, &s->line)) > 0) { s->nc = ft_get_number_of_words(s->line, ' '); ++s->nl; free(s->line); } s->map = (int **)malloc(sizeof(int *) * s->nl); s->nl = 0; s->tmp = s->nc; close(s->fd); s->fd = open(argv[1], O_RDONLY); ft_check_map(s); ft_check_borders(s); ft_check_negatives(s); close(s->fd); }
void ft_next_map(t_id *s) { ft_start_new_map(s); s->fd = open(s->niveau[s->level], O_RDONLY); s->nl = 0; while ((get_next_line(s->fd, &s->line)) > 0) { s->nc = ft_get_number_of_words(s->line, ' '); ++s->nl; free(s->line); s->line = NULL; } s->map = (int **)malloc(sizeof(int *) * s->nl); s->tmp = s->nc; s->nl = 0; close(s->fd); s->fd = open(s->niveau[s->level], O_RDONLY); ft_check_map(s); ft_check_borders(s); ft_check_negatives(s); close(s->fd); ft_corps(s); }