diff --git a/find_compactbiomes.c b/find_compactbiomes.c index e06b9b4..5ccb393 100644 --- a/find_compactbiomes.c +++ b/find_compactbiomes.c @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) int minscale; // arguments - if (argc <= 0) + if (argc <= 1) { printf( "find_compactbiomes [seed_start] [seed_end] [threads] [range]\n" "\n" diff --git a/layers.c b/layers.c index e7a07b9..f9f810f 100644 --- a/layers.c +++ b/layers.c @@ -19,6 +19,7 @@ void initAddBiome(int id, int tempCat, int biometype, float temp, float height) void createMutation(int id) { + biomes[id].mutated = id + 128; biomes[id+128] = biomes[id]; biomes[id+128].id = id+128; } @@ -27,7 +28,15 @@ void createMutation(int id) void initBiomes() { int i; - for (i = 0; i < 256; i++) biomes[i].id = none; + for (i = 0; i < 256; i++) + { + biomes[i].id = none; + biomes[i].type = Void; + biomes[i].temp = 0.5; + biomes[i].height = 0; + biomes[i].tempCat = Void; + biomes[i].mutated = -1; + } const double hDefault = 0.1, hShallowWaters = -0.5, hOceans = -1.0, hDeepOceans = -1.8, hLowPlains = 0.125; const double hMidPlains = 0.2, hLowHills = 0.45, hHighPlateaus = 1.5, hMidHills = 1.0, hShores = 0.0; @@ -931,7 +940,9 @@ static inline int replaceEdge(int *out, int idx, int v10, int v21, int v01, int { if (id != baseID) return 0; - if (equalOrPlateau(v10, baseID) && equalOrPlateau(v21, baseID) && equalOrPlateau(v01, baseID) && equalOrPlateau(v12, baseID)) + // areSimilar() has not changed behaviour for ids < 128, so use the faster variant + if (areSimilar113(v10, baseID) && areSimilar113(v21, baseID) && + areSimilar113(v01, baseID) && areSimilar113(v12, baseID)) out[idx] = id; else out[idx] = edgeID; @@ -960,10 +971,9 @@ void mapBiomeEdge(Layer *l, int * __restrict out, int areaX, int areaZ, int area int v01 = out[x+0 + (z+1)*pWidth]; int v12 = out[x+1 + (z+2)*pWidth]; - if (/*!replaceEdgeIfNecessary(out, x + z*areaWidth, v10, v21, v01, v12, v11, mountains, mountain_edge) &&*/ - !replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, wooded_badlands_plateau, badlands) && - !replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, badlands_plateau, badlands) && - !replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, giant_tree_taiga, taiga)) + if (!replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, wooded_badlands_plateau, badlands) && + !replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, badlands_plateau, badlands) && + !replaceEdge(out, x + z*areaWidth, v10, v21, v01, v12, v11, giant_tree_taiga, taiga)) { if (v11 == desert) { @@ -1078,7 +1088,7 @@ void mapHills(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt case savanna: hillID = savanna_plateau; break; default: - if (equalOrPlateau(a11, wooded_badlands_plateau)) + if (areSimilar(a11, wooded_badlands_plateau)) hillID = badlands; else if (a11 == deep_ocean && mcNextInt(l, 3) == 0) hillID = (mcNextInt(l, 2) == 0) ? plains : forest; @@ -1105,10 +1115,10 @@ void mapHills(Layer *l, int * __restrict out, int areaX, int areaZ, int areaWidt int a12 = buf[x+1 + (z+2)*pWidth]; int equals = 0; - if (equalOrPlateau(a10, a11)) equals++; - if (equalOrPlateau(a21, a11)) equals++; - if (equalOrPlateau(a01, a11)) equals++; - if (equalOrPlateau(a12, a11)) equals++; + if (areSimilar(a10, a11)) equals++; + if (areSimilar(a21, a11)) equals++; + if (areSimilar(a01, a11)) equals++; + if (areSimilar(a12, a11)) equals++; if (equals >= 3) out[idx] = hillID; @@ -1156,9 +1166,13 @@ void mapHills113(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW int bn = (b11 - 2) % 29; - if (!(isOceanic(a11) || b11 < 2 || bn != 1 || a11 >= 128)) + if (!isShallowOcean(a11) && b11 >= 2 && bn == 1) { - out[idx] = (biomeExists(a11 + 128)) ? a11 + 128 : a11; + int m = biomes[a11].mutated; + if (m > 0) + out[idx] = m; + else + out[idx] = a11; } else if (mcNextInt(l, 3) == 0 || bn == 0) { @@ -1195,7 +1209,7 @@ void mapHills113(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW case savanna: hillID = savanna_plateau; break; default: - if (equalOrPlateau(a11, wooded_badlands_plateau)) + if (areSimilar113(a11, wooded_badlands_plateau)) hillID = badlands; else if (isDeepOcean(a11) && mcNextInt(l, 3) == 0) hillID = (mcNextInt(l, 2) == 0) ? plains : forest; @@ -1204,9 +1218,8 @@ void mapHills113(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW if (bn == 0 && hillID != a11) { - if (biomeExists(hillID + 128)) - hillID += 128; - else + hillID = biomes[hillID].mutated; + if (hillID < 0) hillID = a11; } @@ -1218,10 +1231,10 @@ void mapHills113(Layer *l, int * __restrict out, int areaX, int areaZ, int areaW int a12 = buf[x+1 + (z+2)*pWidth]; int equals = 0; - if (equalOrPlateau(a10, a11)) equals++; - if (equalOrPlateau(a21, a11)) equals++; - if (equalOrPlateau(a01, a11)) equals++; - if (equalOrPlateau(a12, a11)) equals++; + if (areSimilar113(a10, a11)) equals++; + if (areSimilar113(a21, a11)) equals++; + if (areSimilar113(a01, a11)) equals++; + if (areSimilar113(a12, a11)) equals++; if (equals >= 3) out[idx] = hillID; diff --git a/layers.h b/layers.h index f4df42c..d6556e3 100644 --- a/layers.h +++ b/layers.h @@ -153,6 +153,7 @@ STRUCT(Biome) double height; double temp; int tempCat; + int mutated; }; STRUCT(OceanRnd) @@ -202,21 +203,20 @@ void setWorldSeed(Layer *layer, int64_t seed); static inline int getBiomeType(int id) { - return biomes[id & 0xff].type; + return (id & (~0xff)) ? Void : biomes[id].type; } static inline int biomeExists(int id) { - return id <= 0xff && !(biomes[id].id & (~0xff)); + return !(id & (~0xff)) && !(biomes[id].id & (~0xff)); } static inline int getTempCategory(int id) { - return biomes[id & 0xff].tempCat; + return (id & (~0xff)) ? Void : biomes[id].tempCat; } - -static inline int equalOrPlateau(int id1, int id2) +static inline int areSimilar(int id1, int id2) { if (id1 == id2) return 1; if (id1 == wooded_badlands_plateau || id1 == badlands_plateau) @@ -231,13 +231,13 @@ static inline int equalOrPlateau(int id1, int id2) return getBiomeType(id1) == getBiomeType(id2); } -static inline int canBeNeighbors(int id1, int id2) +static inline int areSimilar113(int id1, int id2) { - if (equalOrPlateau(id1, id2)) return 1; + if (id1 == id2) return 1; + if (id1 == wooded_badlands_plateau || id1 == badlands_plateau) + return id2 == wooded_badlands_plateau || id2 == badlands_plateau; if (!biomeExists(id1) || !biomeExists(id2)) return 0; - int tempCat1 = getTempCategory(id1); if (tempCat1 == Lush) return 1; - int tempCat2 = getTempCategory(id2); if (tempCat2 == Lush) return 1; - return tempCat1 == tempCat2; + return getBiomeType(id1) == getBiomeType(id2); } static inline int isShallowOcean(int id) @@ -281,7 +281,7 @@ static inline int isOceanic(int id) static inline int isBiomeSnowy(int id) { - return biomeExists(id) && biomes[id&0xff].temp < 0.1; + return biomeExists(id) && biomes[id].temp < 0.1; } static inline int mcNextInt(Layer *layer, int mod) diff --git a/util.c b/util.c index 498ea93..bcf7b63 100644 --- a/util.c +++ b/util.c @@ -151,7 +151,7 @@ int biomesToImage(unsigned char *pixels, } else { - if (id < 128) { + if (id < 128 || 1) { r = biomeColours[id][0]; g = biomeColours[id][1]; b = biomeColours[id][2];