From a756913a7134c207a7d29a1175a428b02f61b777 Mon Sep 17 00:00:00 2001 From: kartofen Date: Thu, 11 Aug 2022 23:12:12 +0300 Subject: minor bug fixes --- src/config.h | 4 ++-- src/gen_tiles.c | 10 +++++++--- src/main.c | 3 ++- src/tiles.c | 2 +- src/typedef.h | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/config.h b/src/config.h index 3bbe84f..8d30884 100644 --- a/src/config.h +++ b/src/config.h @@ -15,7 +15,7 @@ | ... | .#. | | -------------------+--------------------------| | 2: .#. plus | 3: ... line | -| ### X symetry | ### I symetry | +| ### I symetry | ### I symetry | | .#. | ... | | -------------------+--------------------------| | 4: .#. corner | | @@ -31,6 +31,6 @@ need to put in the tiles_to_load array // Array for which tiles to include the tiles.dat int tiles_to_load[] = { 2, - 4, 3, + 4, }; diff --git a/src/gen_tiles.c b/src/gen_tiles.c index de07f30..f7e030e 100644 --- a/src/gen_tiles.c +++ b/src/gen_tiles.c @@ -90,15 +90,19 @@ void save(small_t *t, small_t *c, int n, int i) fwrite(&connections, sizeof(connections), 1, fp); } -void gen_rotations() +void gen() { mkdir("files", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); mkdir("files/tiles", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); fp = fopen("files/tiles/tiles.dat", "wb"); + if(!fp) { + fprintf(stderr, "ERROR: Could not open file files/tiles/tiles.dat"); + exit(EXIT_FAILURE); + } size_t tiles_sz = sizeof(tiles_to_load)/sizeof(int); - fwrite(&tiles_sz, sizeof(size_t), sizeof(size_t), fp); + fwrite(&tiles_sz, sizeof(size_t), 1, fp); char syms[TILE_TYPES]; size_t sym_sz = 0; @@ -118,6 +122,6 @@ void gen_rotations() int main(void) { - gen_rotations(); + gen(); return 0; } diff --git a/src/main.c b/src/main.c index 5c32c13..6b70536 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,7 @@ size_t SCALE = 9; int get_least_entropy_index() { // array of indexes with the least entropy - int least_entpy[TILEMAP_CAP]; + size_t least_entpy[TILEMAP_CAP]; size_t least_entpy_sz = 0; for(size_t i = 0; i < SHEIGHT; i++) @@ -43,6 +43,7 @@ int get_least_entropy_index() size_t l1s = count_entropy(least_entpy[least_entpy_sz-1]); if(b1s == l1s) { + if(least_entpy_sz >= TILEMAP_CAP) exit(69); least_entpy[least_entpy_sz++] = index; } else if(b1s < l1s) { least_entpy[0] = index; diff --git a/src/tiles.c b/src/tiles.c index 28ec89c..cecee5a 100644 --- a/src/tiles.c +++ b/src/tiles.c @@ -55,7 +55,7 @@ static void load_tile_data(char *tc, char *ts, size_t *tid) exit(EXIT_FAILURE); } - fread(tid, sizeof(size_t), sizeof(size_t), fp); + fread(tid, sizeof(size_t), 1, fp); fread(tc, 1, *tid, fp); fread(ts, 1, *tid, fp); diff --git a/src/typedef.h b/src/typedef.h index 483c250..8924dc8 100644 --- a/src/typedef.h +++ b/src/typedef.h @@ -4,7 +4,7 @@ // useful definitions #define TILES_CAP 63 -#define TILEMAP_CAP 4096 +#define TILEMAP_CAP 16384 #include #include -- cgit v1.2.3