diff --git a/finders.c b/finders.c index 4e0a394..3fac035 100644 --- a/finders.c +++ b/finders.c @@ -534,6 +534,10 @@ static void *baseQuadWitchHutSearchThread(void *data) sprintf(fnam, "%s.part%d", info.fnam, info.threadID); FILE *fp = fopen(fnam, "a+"); + if (fp == NULL) { + fprintf(stderr, "Could not open \"%s\" for writing.\n", fnam); + exit(-1); + } seed = start; @@ -620,6 +624,10 @@ void baseQuadWitchHutSearch(const char *fnam, const int threads, const int quali char fnamThread[256]; char buffer[4097]; FILE *fp = fopen(fnam, "w"); + if (fp == NULL) { + fprintf(stderr, "Could not open \"%s\" for writing.\n", fnam); + exit(-1); + } FILE *fpart; int n; @@ -663,6 +671,8 @@ void baseQuadWitchHutSearch(const char *fnam, const int threads, const int quali /* getBiomeAtPos * ---------------- * Returns the biome for the specified block position. + * (Alternatives should be considered in performance critical code.) + * This function is not threadsafe. */ int getBiomeAtPos(const LayerStack g, const Pos pos) { @@ -812,7 +822,7 @@ Pos getMansionPos(long seed, const long area80X, const long area80Z) pos.z += (seed >> 17) % 60; pos.x = area80X*80 + (pos.x >> 1); - pos.z = area80X*80 + (pos.z >> 1); + pos.z = area80Z*80 + (pos.z >> 1); pos.x = pos.x*16 + 8; pos.z = pos.z*16 + 8; return pos; diff --git a/finders.h b/finders.h index cfc69b0..798f785 100644 --- a/finders.h +++ b/finders.h @@ -129,6 +129,7 @@ void baseQuadWitchHutSearch(const char *fnam, int threads, int quality); * ---------------- * Returns the biome for the specified block position. * (Alternatives should be considered in performance critical code.) + * This function is not threadsafe. */ int getBiomeAtPos(const LayerStack g, const Pos pos); diff --git a/layers.c b/layers.c index 3c6d648..7d37557 100644 --- a/layers.c +++ b/layers.c @@ -861,6 +861,7 @@ void mapBiomeEdge(Layer *l, int * __restrict out, int areaX, int areaZ, int area } +/* This function is not threadsafe. */ void mapHills(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidth, int areaHeight) { int pX = areaX - 1; diff --git a/layers.h b/layers.h index 9dfefcf..f707efc 100644 --- a/layers.h +++ b/layers.h @@ -376,6 +376,7 @@ void mapDeepOcean(Layer *l, int * __restrict out, int x, int z, int w, int h); void mapBiome(Layer *l, int * __restrict out, int x, int z, int w, int h); void mapRiverInit(Layer *l, int * __restrict out, int x, int z, int w, int h); void mapBiomeEdge(Layer *l, int * __restrict out, int x, int z, int w, int h); +/* This function is not threadsafe. */ void mapHills(Layer *l, int * __restrict out, int x, int z, int w, int h); void mapRiver(Layer *l, int * __restrict out, int x, int z, int w, int h); void mapSmooth(Layer *l, int * __restrict out, int x, int z, int w, int h);