aboutsummaryrefslogtreecommitdiff
path: root/src/gen_tiles.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gen_tiles.c')
-rw-r--r--src/gen_tiles.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gen_tiles.c b/src/gen_tiles.c
index 5d6cba3..22b385f 100644
--- a/src/gen_tiles.c
+++ b/src/gen_tiles.c
@@ -1,40 +1,42 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/stat.h>
#include "typedef.h"
+#define TILESET_NAME (STR(TILESET))
+
typedef struct tile {
char name[64];
char symetry;
small_t connections[SIDES_MAX];
} tile;
-#include "config.h"
#define STR_AUX(a) #a
#define STR(a) STR_AUX(a)
-#define TILESET_PATH(name) STR(../PATH/name/tileset.h)
-// include the tileset header configuration
+#define TILESET_PATH(name) STR(../PATH/tilesets/name/tileset.h)
+
+#include "config.h"
#include TILESET_PATH(TILESET)
-#define TILESET_NAME STR(TILESET)
+#define MKDIR_FILES_SLASH_TILES STR(mkdir PATH/tiles)
+#define TILES_DOT_DAT STR(PATH/tiles/tiles.dat)
+#define COMMAND STR(cp PATH/tilesets/%s/%s.ppm PATH/tiles/tile_%d.ppm)
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",
+ sprintf(command, COMMAND,
tile_set, name, n);
system(command);
}
void gen()
{
- system("mkdir files");
- system("mkdir files/tiles");
+ system(MKDIR_FILES_SLASH_TILES);
- FILE *fp = fopen("files/tiles/tiles.dat", "wb");
+ FILE *fp = fopen(TILES_DOT_DAT, "wb");
if(!fp) {
- fprintf(stderr, "ERROR: Could not open file files/tiles/tiles.dat");
+ err("Could not open file: %s", TILES_DOT_DAT);
exit(EXIT_FAILURE);
}
@@ -58,8 +60,8 @@ void gen()
int main(void)
{
- puts("INFO: Generating Tile Data");
+ info("Generating Tile Data");
gen();
- puts("INFO: Successful");
+ info("INFO: Successful");
return 0;
}