#include #include #include #include "../src/types.h" #define MAPDIR "map/" #define MAPNAME "mt_map" #define FBUF_SIZE 1024*256 char *filebuf; char *filesig = "\n" ""; int import_map(MapCollec *mapcollec, FILE *mapfile){ int32_t fbuf_pos = 0; int32_t fbuf_max = fread(filebuf, 1, FBUF_SIZE, mapfile); if(strncmp(filebuf, filesig, sizeof(filesig))){ printf("Error: Invalid file header.\n"); return 1; } return 0; } FILE *maps[100] = {NULL}; int import_maps(MapCollec *mapcollec){ char tmpname[256]; int i; for(i = 0; i < 100; i++){ snprintf(tmpname, 256, MAPDIR MAPNAME "%d.tmx", i); printf("Loading map \"%s\"...\n", tmpname); maps[i] = fopen(tmpname, "r"); if(!maps[i]){ printf("Failed to load map, stopping here\n"); break; } if(import_map(mapcollec, maps[i])) return 0; } return i; } void clean_maps(){ for(int i = 0; i < 100; i++){ if(maps[i]) fclose(maps[i]); } } int export_maps(MapCollec *mapcollec){ } int main(){ MapCollec mapcollec; filebuf = malloc(FBUF_SIZE); if(!filebuf) return 1; if(!import_maps(&mapcollec)) return 1; clean_maps(); free(filebuf); return 0; }