t_wolf *init_map(char *av) { t_wolf *wolf; t_bunny_ini_scope *scope; t_bunny_ini *ini; if ((wolf = bunny_malloc(sizeof(t_wolf))) == NULL) return ((t_wolf *)-1); if ((ini = bunny_load_ini(av)) == NULL) return ((t_wolf *)-1); scope = bunny_ini_first(ini); scope = bunny_ini_next(ini, scope); wolf->s_name = bunny_ini_scope_name(ini, scope); wolf->width = 0; wolf->height = 0; wolf = get_dim(wolf, ini); if (check_air(wolf, ini) == -1) return ((t_wolf *)-1); wolf = get_map(wolf, ini); wolf = get_player(wolf, ini); if (init_error(wolf) == -1) return ((t_wolf *)-1); bunny_delete_ini(ini); return (wolf); }
static int load_loop(t_bunny_ini *ini, t_objs *objs) { t_bunny_ini_scope *scope; int x; if ((scope = bunny_ini_first(ini)) == NULL) return (1); load_def(scope, objs); scope = bunny_ini_next(ini, scope); x = 0; while (scope != NULL && x < objs->nb) { load_item(scope, &((objs->objs)[x])); scope = bunny_ini_next(ini, scope); x += 1; } return (0); }
int load_objs(t_bunny_ini *ini, t_objs *objs) { t_bunny_ini_scope *scope; if ((scope = bunny_ini_first(ini)) == NULL) return (1); scope = bunny_ini_next(ini, scope); objs->nb = 0; while (scope != NULL) { scope = bunny_ini_next(ini, scope); objs->nb += 1; } if ((objs->objs = bunny_malloc(sizeof(t_obj) * objs->nb)) == NULL) return (1); if (load_loop(ini, objs)) return (1); return (0); }