#include "kubo_file.h" struct kubo_context kubo_file_parse(char *file_name) { static const cyaml_config_t config = { .log_fn = cyaml_log, .mem_fn = cyaml_mem, .log_level = CYAML_LOG_WARNING, }; struct kubo_file_scene *n; cyaml_err_t err = cyaml_load_file(file_name, &config, &top_schema, (cyaml_data_t **)&n, NULL); if (err != CYAML_OK) { printf("cyaml err\n"); } struct kubo_context context; kubo_context_init(&context); for (size_t i = 0; i < n->walls_count; i++) { printf("wall:\n"); struct kubo_wall *wall = malloc(sizeof(struct kubo_wall)); kubo_wall_init(wall); for (size_t j = 0; j < n->walls[i].vertices_count; j++) { printf("\t%i:%i\n", n->walls[i].vertices[j][0], n->walls[i].vertices[j][1]); Vector2 vertex = { .x = n->walls[i].vertices[j][0], .y = n->walls[i].vertices[j][1] }; kubo_wall_add_vertex(wall, vertex); } kubo_wall_arr_add(&context.walls, wall); } err = cyaml_free(&config, &top_schema, n, 0); if (err != CYAML_OK) { printf("cyaml free err\n"); } return context; }