int init(char *file, int ***grid, t_unit **unit) { int fd; int x; int y; char *tmp; if (!((fd = my_strlen(file)) > 4 && my_strcmp(file + fd - 4, ".map") == 0 && (fd = open(file, O_RDONLY)) != -1)) return (my_error(EO)); my_putstr(FE); file[my_strlen(file) - 4] = 0; x = 0; y = 0; *grid = NULL; while ((tmp = get_next_line(fd)) != NULL && tmp[0] != 0) { if (add_line(tmp, grid, &x) == 1) return (my_error(GE)); y += 1; } if (x < 3 || y < 3) return (my_error(GS) - 1); return (init_end(*grid, unit, x, y, fd)); }
unit_map::unit_map() : umap_() , lmap_() , ilist_() , the_end_() { init_end(); }
unit_map::unit_map(const unit_map& that) : umap_() , lmap_() , ilist_() , the_end_() { init_end(); for (const_unit_iterator i = that.begin(); i != that.end(); ++i) { add(i->get_location(), *i); } }