#include #include #include #include #include "typedef.h" typedef struct tile { char name[64]; char symetry; small_t connections[SIDES_MAX]; // small_t neighbours[TILES_CAP]; // size_t neigbours_sz; } tile; #include "config.h" void copy(char *tile_set, char *name, int n) { char command[512]; sprintf(command, "cp files/tilesets/%s/%s.ppm files/tiles/tile_%d.ppm", tile_set, name, n); system(command); } void gen() { system("mkdir files"); system("mkdir files/tiles"); FILE *fp = fopen("files/tiles/tiles.dat", "wb"); if(!fp) { fprintf(stderr, "ERROR: Could not open file files/tiles/tiles.dat"); exit(EXIT_FAILURE); } small_t dim = DIMENTIONS; fwrite(&dim, sizeof(small_t), 1, fp); size_t tiles_sz = sizeof(tiles_to_load)/sizeof(int); fwrite(&tiles_sz, sizeof(size_t), 1, fp); for(size_t n = 0; n < tiles_sz; n++) { int t = tiles_to_load[n]; copy(TILESET_NAME, tiles[t].name, n); fwrite(tiles[t].connections, sizeof(small_t), SIDES, fp); fwrite(&(tiles[t].symetry), sizeof(char), 1, fp); } fclose(fp); } int main(void) { puts("INFO: Generating Tile Data"); gen(); puts("INFO: Successful"); return 0; }