diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-08-11 23:12:12 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-08-11 23:12:12 +0300 |
commit | a756913a7134c207a7d29a1175a428b02f61b777 (patch) | |
tree | f462a6b9f5a324467973800c6315e3cd2b37e20f | |
parent | 89a48fc3e7252e1c7941f86559ca00b38d525244 (diff) |
minor bug fixes
-rwxr-xr-x | build.sh | 2 | ||||
-rw-r--r-- | src/config.h | 4 | ||||
-rw-r--r-- | src/gen_tiles.c | 10 | ||||
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/tiles.c | 2 | ||||
-rw-r--r-- | src/typedef.h | 2 |
6 files changed, 14 insertions, 9 deletions
@@ -49,5 +49,5 @@ gcc -o $BIN/gen_tiles $ODIR/gen_tiles.o $ODIR/ppm.o $FLAGS if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null then $VALGRND $BIN/gen_tiles - $VALGRND $BIN/wfc -s 69 -m 4 + $VALGRND $BIN/wfc fi 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; } @@ -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 <stdint.h> #include <stddef.h> |