Navigation Menu

Skip to content

Commit

Permalink
Fix wrong biome generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wickth committed Mar 25, 2012
1 parent dbea479 commit fd3bc3c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -7,13 +7,18 @@
/nbproject
/build.xml

# Idea stuff
/.idea
*.iml

# vim
.*.sw[a-p]

# various other potential build files
/build
/bin
/dist
/out
/localexport.jardesc

# Mac filesystem dust
Expand Down
Expand Up @@ -57,7 +57,7 @@ public class BukkitWorld implements LocalWorld
private int worldHeight = 256;
private int heightBits = 8;

private int CustomBiomesCount = 22;
private int CustomBiomesCount = 21;

static
{
Expand Down
Expand Up @@ -167,7 +167,7 @@ public static Layer[] Init(long paramLong, LocalWorld world)
{
int id = biomeConfig.Biome.getId();
if (biomeConfig.Biome.isCustom())
id = id - (DefaultBiome.values().length - 21); // Must be decreased by count of new biomes since 1.1 for compatible 1.1 maps
id = biomeConfig.Biome.getCustomId(); // Must be decreased by count of new biomes since 1.1 for compatible 1.1 maps

LayerBiomeInBiome layerBiome = new LayerBiomeInBiome(4000 + id, MainLayer);
layerBiome.biome = biomeConfig.Biome;
Expand Down
Expand Up @@ -805,9 +805,9 @@ protected void CorrectSettings()
this.BiomeTemperature = CheckValue(this.BiomeTemperature, 0.0F, 1.0F);
this.BiomeWetness = CheckValue(this.BiomeWetness, 0.0F, 1.0F);

this.IsleInBiome = CheckValue(this.IsleInBiome, this.worldConfig.CustomBiomes.keySet());
this.BiomeIsBorder = CheckValue(this.BiomeIsBorder, this.worldConfig.CustomBiomes.keySet());
this.NotBorderNear = CheckValue(this.NotBorderNear, this.worldConfig.CustomBiomes.keySet());
this.IsleInBiome = CheckValue(this.IsleInBiome, this.worldConfig.CustomBiomes);
this.BiomeIsBorder = CheckValue(this.BiomeIsBorder, this.worldConfig.CustomBiomes);
this.NotBorderNear = CheckValue(this.NotBorderNear, this.worldConfig.CustomBiomes);

this.volatility1 = this.volatilityRaw1 < 0.0D ? 1.0D / (Math.abs(this.volatilityRaw1) + 1.0D) : this.volatilityRaw1 + 1.0D;
this.volatility2 = this.volatilityRaw2 < 0.0D ? 1.0D / (Math.abs(this.volatilityRaw2) + 1.0D) : this.volatilityRaw2 + 1.0D;
Expand Down
Expand Up @@ -423,7 +423,7 @@ protected int CheckValue(int value, int min, int max, int minValue)
return value;
}

protected ArrayList<String> CheckValue(ArrayList<String> biomes, Set<String> customBiomes)
protected ArrayList<String> CheckValue(ArrayList<String> biomes, ArrayList<String> customBiomes)
{
ArrayList<String> output = new ArrayList<String>();

Expand Down
35 changes: 19 additions & 16 deletions common/src/com/khorn/terraincontrol/configuration/WorldConfig.java
Expand Up @@ -13,7 +13,8 @@

public class WorldConfig extends ConfigFile
{
public HashMap<String, Integer> CustomBiomes = new HashMap<String, Integer>();
public ArrayList<String> CustomBiomes = new ArrayList<String>();
public HashMap<String,Integer> CustomBiomeIds = new HashMap<String, Integer>();

public ArrayList<String> NormalBiomes = new ArrayList<String>();
public ArrayList<String> IceBiomes = new ArrayList<String>();
Expand Down Expand Up @@ -156,9 +157,9 @@ public WorldConfig(File settingsDir, LocalWorld world, boolean checkOnly)

// Check biome ids

for( String biomeName : CustomBiomes.keySet())
if(CustomBiomes.get(biomeName) == -1)
CustomBiomes.put(biomeName,world.getFreeBiomeId());
for( String biomeName : CustomBiomes)
if(CustomBiomeIds.get(biomeName) == -1)
CustomBiomeIds.put(biomeName,world.getFreeBiomeId());

// Need add check to clashes

Expand All @@ -178,12 +179,12 @@ public WorldConfig(File settingsDir, LocalWorld world, boolean checkOnly)

ArrayList<LocalBiome> biomes = new ArrayList<LocalBiome>(world.getDefaultBiomes());

for (String biomeName : this.CustomBiomes.keySet())
for (String biomeName : this.CustomBiomes)
{
if (checkOnly)
biomes.add(world.getNullBiome(biomeName));
else
biomes.add(world.AddBiome(biomeName, this.CustomBiomes.get(biomeName)));
biomes.add(world.AddBiome(biomeName, this.CustomBiomeIds.get(biomeName)));
}

this.biomeConfigs = new BiomeConfig[world.getMaxBiomesCount()];
Expand Down Expand Up @@ -235,10 +236,10 @@ protected void CorrectSettings()
this.RiverRarity = CheckValue(this.RiverRarity, 0, this.GenerationDepth);
this.RiverSize = CheckValue(this.RiverSize, 0, this.GenerationDepth - this.RiverRarity);

this.NormalBiomes = CheckValue(this.NormalBiomes, this.CustomBiomes.keySet());
this.IceBiomes = CheckValue(this.IceBiomes, this.CustomBiomes.keySet());
this.IsleBiomes = CheckValue(this.IsleBiomes, this.CustomBiomes.keySet());
this.BorderBiomes = CheckValue(this.BorderBiomes, this.CustomBiomes.keySet());
this.NormalBiomes = CheckValue(this.NormalBiomes, this.CustomBiomes);
this.IceBiomes = CheckValue(this.IceBiomes, this.CustomBiomes);
this.IsleBiomes = CheckValue(this.IsleBiomes, this.CustomBiomes);
this.BorderBiomes = CheckValue(this.BorderBiomes, this.CustomBiomes);


this.minMoisture = CheckValue(this.minMoisture, 0, 1.0F);
Expand Down Expand Up @@ -412,7 +413,8 @@ private void ReadCustomBiomes()
int id = -1;
if (keys.length == 2)
id = Integer.valueOf(keys[1]);
CustomBiomes.put(keys[0], id);
CustomBiomes.add(keys[0]);
CustomBiomeIds.put(keys[0], id);

} catch (NumberFormatException e)
{
Expand Down Expand Up @@ -652,12 +654,12 @@ private void WriteCustomBiomes() throws IOException
{
String output = "";
boolean first = true;
for (String biome : CustomBiomes.keySet())
for (String biome : CustomBiomes)
{
if (!first)
output += ",";
first = false;
output += biome + ":" + CustomBiomes.get(biome);
output += biome + ":" + CustomBiomeIds.get(biome);
}
WriteValue(TCDefaultValues.CustomBiomes.name(), output);

Expand Down Expand Up @@ -800,10 +802,10 @@ public void Serialize(DataOutputStream stream) throws IOException


stream.writeInt(this.CustomBiomes.size());
for (String name : this.CustomBiomes.keySet())
for (String name : this.CustomBiomes)
{
WriteStringToStream(stream, name);
stream.writeInt(this.CustomBiomes.get(name));
stream.writeInt(this.CustomBiomeIds.get(name));
}

BiomeConfig config = this.getConfigByName(DefaultBiome.OCEAN.Name);
Expand Down Expand Up @@ -903,7 +905,8 @@ public WorldConfig(DataInputStream stream, LocalWorld world) throws IOException
String name = ReadStringFromStream(stream);
int id = stream.readInt();
world.AddBiome(name, id);
this.CustomBiomes.put(name, id);
this.CustomBiomes.add(name);
this.CustomBiomeIds.put(name, id);
}

this.biomeConfigs = new BiomeConfig[world.getMaxBiomesCount()];
Expand Down

0 comments on commit fd3bc3c

Please sign in to comment.