mirror of
https://github.com/Cubitect/cubiomes.git
synced 2025-09-25 13:00:27 -04:00
Version check at getConfig()
This commit is contained in:
parent
ae227c67c2
commit
bdc765013c
106
finders.c
106
finders.c
@ -75,75 +75,101 @@ void setAttemptSeed(int64_t *s, int cx, int cz)
|
||||
next(s, 31);
|
||||
}
|
||||
|
||||
int getStructurePos(int structureType, int mc, int64_t seed, int regX, int regZ, Pos *pos)
|
||||
int getConfig(int structureType, int mc, StructureConfig *sconf)
|
||||
{
|
||||
StructureConfig sconf;
|
||||
switch (structureType)
|
||||
{
|
||||
case Feature:
|
||||
if (mc > MC_1_12) return 0;
|
||||
sconf = FEATURE_CONFIG;
|
||||
goto L_feature;
|
||||
*sconf = FEATURE_CONFIG;
|
||||
return mc <= MC_1_12;
|
||||
case Desert_Pyramid:
|
||||
*sconf = mc <= MC_1_12 ? DESERT_PYRAMID_CONFIG_112 : DESERT_PYRAMID_CONFIG;
|
||||
return mc >= MC_1_3;
|
||||
case Jungle_Pyramid:
|
||||
*sconf = mc <= MC_1_12 ? JUNGLE_PYRAMID_CONFIG_112 : JUNGLE_PYRAMID_CONFIG;
|
||||
return mc >= MC_1_3;
|
||||
case Swamp_Hut:
|
||||
*sconf = mc <= MC_1_12 ? SWAMP_HUT_CONFIG_112 : SWAMP_HUT_CONFIG;
|
||||
return mc >= MC_1_4;
|
||||
case Igloo:
|
||||
*sconf = mc <= MC_1_12 ? IGLOO_CONFIG_112 : IGLOO_CONFIG;
|
||||
return mc >= MC_1_9;
|
||||
case Village:
|
||||
*sconf = VILLAGE_CONFIG;
|
||||
return 1;
|
||||
case Ocean_Ruin:
|
||||
*sconf = mc <= MC_1_15 ? OCEAN_RUIN_CONFIG_115 : OCEAN_RUIN_CONFIG;
|
||||
return mc >= MC_1_13;
|
||||
case Shipwreck:
|
||||
*sconf = mc <= MC_1_15 ? SHIPWRECK_CONFIG_115 : SHIPWRECK_CONFIG;
|
||||
return mc >= MC_1_13;
|
||||
case Ruined_Portal:
|
||||
*sconf = RUINED_PORTAL_CONFIG;
|
||||
return mc >= MC_1_16;
|
||||
case Monument:
|
||||
*sconf = MONUMENT_CONFIG;
|
||||
return mc >= MC_1_8;
|
||||
case End_City:
|
||||
*sconf = END_CITY_CONFIG;
|
||||
return mc >= MC_1_9;
|
||||
case Mansion:
|
||||
*sconf = MANSION_CONFIG;
|
||||
return mc >= MC_1_11;
|
||||
case Outpost:
|
||||
*sconf = OUTPOST_CONFIG;
|
||||
return mc >= MC_1_14;
|
||||
case Treasure:
|
||||
*sconf = TREASURE_CONFIG;
|
||||
return mc >= MC_1_13;
|
||||
case Fortress:
|
||||
*sconf = FORTRESS_CONFIG;
|
||||
return 1;
|
||||
case Bastion:
|
||||
*sconf = FORTRESS_CONFIG;
|
||||
return mc >= MC_1_16;
|
||||
default:
|
||||
memset(sconf, 0, sizeof(StructureConfig));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int getStructurePos(int structureType, int mc, int64_t seed, int regX, int regZ, Pos *pos)
|
||||
{
|
||||
StructureConfig sconf;
|
||||
if (!getConfig(structureType, mc, &sconf))
|
||||
return 0;
|
||||
|
||||
switch (structureType)
|
||||
{
|
||||
case Feature:
|
||||
case Desert_Pyramid:
|
||||
sconf = mc <= MC_1_12 ? DESERT_PYRAMID_CONFIG_112 : DESERT_PYRAMID_CONFIG;
|
||||
goto L_feature;
|
||||
case Jungle_Pyramid:
|
||||
sconf = mc <= MC_1_12 ? JUNGLE_PYRAMID_CONFIG_112 : JUNGLE_PYRAMID_CONFIG;
|
||||
goto L_feature;
|
||||
case Swamp_Hut:
|
||||
sconf = mc <= MC_1_12 ? SWAMP_HUT_CONFIG_112 : SWAMP_HUT_CONFIG;
|
||||
goto L_feature;
|
||||
case Igloo:
|
||||
if (mc < MC_1_9) return 0;
|
||||
sconf = mc <= MC_1_12 ? IGLOO_CONFIG_112 : IGLOO_CONFIG;
|
||||
goto L_feature;
|
||||
case Village:
|
||||
sconf = VILLAGE_CONFIG;
|
||||
goto L_feature;
|
||||
case Ocean_Ruin:
|
||||
if (mc < MC_1_13) return 0;
|
||||
sconf = mc <= MC_1_15 ? OCEAN_RUIN_CONFIG_115 : OCEAN_RUIN_CONFIG;
|
||||
goto L_feature;
|
||||
case Shipwreck:
|
||||
if (mc < MC_1_13) return 0;
|
||||
sconf = mc <= MC_1_15 ? SHIPWRECK_CONFIG_115 : SHIPWRECK_CONFIG;
|
||||
goto L_feature;
|
||||
case Ruined_Portal:
|
||||
if (mc < MC_1_16) return 0;
|
||||
sconf = RUINED_PORTAL_CONFIG;
|
||||
L_feature:
|
||||
*pos = getFeaturePos(sconf, seed, regX, regZ);
|
||||
return 1;
|
||||
|
||||
case Monument:
|
||||
if (mc < MC_1_8) return 0;
|
||||
sconf = MONUMENT_CONFIG;
|
||||
goto L_large_struct;
|
||||
case End_City:
|
||||
if (mc < MC_1_9) return 0;
|
||||
sconf = END_CITY_CONFIG;
|
||||
goto L_large_struct;
|
||||
case Mansion:
|
||||
if (mc < MC_1_11) return 0;
|
||||
sconf = MANSION_CONFIG;
|
||||
L_large_struct:
|
||||
*pos = getLargeStructurePos(sconf, seed, regX, regZ);
|
||||
return 1;
|
||||
|
||||
case Outpost:
|
||||
if (mc < MC_1_14) return 0;
|
||||
*pos = getFeaturePos(OUTPOST_CONFIG, seed, regX, regZ);
|
||||
*pos = getFeaturePos(sconf, seed, regX, regZ);
|
||||
setAttemptSeed(&seed, (pos->x) >> 4, (pos->z) >> 4);
|
||||
return nextInt(&seed, 5) == 0;
|
||||
|
||||
case Treasure:
|
||||
if (mc < MC_1_13) return 0;
|
||||
pos->x = (regX << 4) + 9;
|
||||
pos->z = (regZ << 4) + 9;
|
||||
return isTreasureChunk(seed, regX, regZ);
|
||||
|
||||
case Fortress:
|
||||
sconf = FORTRESS_CONFIG;
|
||||
if (mc < MC_1_16) {
|
||||
setAttemptSeed(&seed, regX << 4, regZ << 4);
|
||||
int valid = nextInt(&seed, 3) == 0;
|
||||
@ -158,8 +184,6 @@ L_large_struct:
|
||||
}
|
||||
|
||||
case Bastion:
|
||||
if (mc < MC_1_16) return 0;
|
||||
sconf = BASTION_CONFIG;
|
||||
setSeed(&seed, regX*341873128712 + regZ*132897987541 + seed + sconf.salt);
|
||||
pos->x = (regX * sconf.regionSize + nextInt(&seed, 24)) << 4;
|
||||
pos->z = (regZ * sconf.regionSize + nextInt(&seed, 24)) << 4;
|
||||
@ -1740,7 +1764,7 @@ L_feature:
|
||||
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"isViableStructurePos: validation for structure type %d not implemented",
|
||||
"isViableStructurePos: validation for structure type %d not implemented\n",
|
||||
structureType);
|
||||
goto L_not_viable;
|
||||
}
|
||||
|
58
finders.h
58
finders.h
@ -266,6 +266,11 @@ int64_t *loadSavedSeeds(const char *fnam, int64_t *scnt);
|
||||
//==============================================================================
|
||||
|
||||
|
||||
/* Selects the structure configuration for a given version. Returns zero upon
|
||||
* failure (e.g. version does not support structure type).
|
||||
*/
|
||||
int getConfig(int structureType, int mc, StructureConfig *sconf);
|
||||
|
||||
/* Finds the block position of the structure generation attempt in a given
|
||||
* region. You can use isViableStructurePos() to test if the necessary biome
|
||||
* requirements are met for the structure to actually generate at that position.
|
||||
@ -282,12 +287,6 @@ int64_t *loadSavedSeeds(const char *fnam, int64_t *scnt);
|
||||
*/
|
||||
int getStructurePos(int structureType, int mc, int64_t seed, int regX, int regZ, Pos *pos);
|
||||
|
||||
/* Selects the structure configuration for a given version. The return value is
|
||||
* undefined if the structure type does not generate in the provided version.
|
||||
*/
|
||||
static inline __attribute__((const))
|
||||
StructureConfig getConfig(int structureType, int mc);
|
||||
|
||||
/* The inline functions below get the generation attempt position given a
|
||||
* structure configuration. Most small structures use the getFeature..
|
||||
* variants, which have a uniform distribution, while large structures
|
||||
@ -736,53 +735,6 @@ void genPotential(uint64_t *mL, uint64_t *mM, int layer, int mc, int id);
|
||||
//==============================================================================
|
||||
|
||||
|
||||
static inline __attribute__((const))
|
||||
StructureConfig getConfig(int structureType, int mc)
|
||||
{
|
||||
switch (structureType)
|
||||
{
|
||||
case Desert_Pyramid:
|
||||
if (mc <= MC_1_12) return DESERT_PYRAMID_CONFIG_112;
|
||||
return DESERT_PYRAMID_CONFIG;
|
||||
case Jungle_Pyramid:
|
||||
if (mc <= MC_1_12) return JUNGLE_PYRAMID_CONFIG_112;
|
||||
return JUNGLE_PYRAMID_CONFIG;
|
||||
case Swamp_Hut:
|
||||
if (mc <= MC_1_12) return SWAMP_HUT_CONFIG_112;
|
||||
return SWAMP_HUT_CONFIG;
|
||||
case Igloo:
|
||||
if (mc <= MC_1_12) return IGLOO_CONFIG_112;
|
||||
return IGLOO_CONFIG;
|
||||
case Village:
|
||||
return VILLAGE_CONFIG;
|
||||
case Ocean_Ruin:
|
||||
if (mc <= MC_1_15) return OCEAN_RUIN_CONFIG_115;
|
||||
return OCEAN_RUIN_CONFIG;
|
||||
case Shipwreck:
|
||||
if (mc <= MC_1_15) return SHIPWRECK_CONFIG_115;
|
||||
return SHIPWRECK_CONFIG;
|
||||
case Monument:
|
||||
return MONUMENT_CONFIG;
|
||||
case Mansion:
|
||||
return MANSION_CONFIG;
|
||||
case Outpost:
|
||||
return OUTPOST_CONFIG;
|
||||
case Ruined_Portal:
|
||||
return RUINED_PORTAL_CONFIG;
|
||||
case Treasure:
|
||||
return TREASURE_CONFIG;
|
||||
case Fortress:
|
||||
return FORTRESS_CONFIG;
|
||||
case Bastion:
|
||||
return BASTION_CONFIG;
|
||||
case End_City:
|
||||
return END_CITY_CONFIG;
|
||||
default:
|
||||
return FEATURE_CONFIG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline __attribute__((const))
|
||||
Pos getFeatureChunkInRegion(StructureConfig config, int64_t seed, int regX, int regZ)
|
||||
{
|
||||
|
5
layers.c
5
layers.c
@ -698,7 +698,8 @@ void setEndSeed(EndNoise *en, int64_t seed)
|
||||
perlinInit(en, &s);
|
||||
}
|
||||
|
||||
__attribute__(( optimize("unroll-loops") ))
|
||||
// TODO: compiler independent unroll
|
||||
//__attribute__(( optimize("unroll-loops") ))
|
||||
static int getEndBiome(int hx, int hz, const uint16_t *hmap, int hw)
|
||||
{
|
||||
int i, j;
|
||||
@ -1582,7 +1583,7 @@ const int snowBiomes[] = {snowy_tundra, snowy_tundra, snowy_tundra, snowy_taiga}
|
||||
|
||||
const int oldBiomes[] = { desert, forest, mountains, swamp, plains, taiga, jungle };
|
||||
const int oldBiomes11[] = { desert, forest, mountains, swamp, plains, taiga };
|
||||
const int lushBiomesBE[] = {forest, dark_forest, mountains, plains, plains, plains, birch_forest, swamp};
|
||||
//const int lushBiomesBE[] = {forest, dark_forest, mountains, plains, plains, plains, birch_forest, swamp};
|
||||
|
||||
int mapBiome(const Layer * l, int * out, int x, int z, int w, int h)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user