Skip to content

Commit

Permalink
Fixed more small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Feb 11, 2018
1 parent 0ad9b0e commit eaa08b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Expand Up @@ -44,6 +44,9 @@ public class CommandLineInterface implements Runnable
@Override
public void run()
{
// Don't start more threads than seeds we've asked for.
threads = Math.min(threads, targetCount);

System.out.println("Config: ");
System.out.println("- treesAboveWater: " + treesAboveWater);
System.out.println("- rocksInWater: " + rocksInWater);
Expand Down Expand Up @@ -86,9 +89,6 @@ public void run()
}
else // We didn't get seeds via CLI, make some at random
{
// Don't start more threads than seeds we've asked for.
threads = Math.min(threads, targetCount);

// todo: evaluate so we actually only count good seeds
final AtomicInteger goodCount = new AtomicInteger();

Expand Down
10 changes: 0 additions & 10 deletions src/main/java/net/dries007/tfc/seedmaker/util/Helper.java
Expand Up @@ -39,14 +39,4 @@ public static <K, V> JsonElement toJson(Map<K, V> biomeMap)
for (Map.Entry<K, V> e : biomeMap.entrySet()) object.addProperty(e.getKey().toString(), e.getValue().toString());
return object;
}

/**
* Makes array of either null (if maps[n] is false) or a new PngWriter
*/
public static PngWriter[] prepareGraphics(int size, File folder, boolean[] maps)
{
PngWriter[] out = new PngWriter[Layers.values().length];
for (int i = 0; i < out.length; i++) if (maps[i]) out[i] = new PngWriter(new File(folder, Layers.values()[i].name().toLowerCase() + ".png"), new ImageInfo(size, size, 8, false), true);
return out;
}
}
17 changes: 14 additions & 3 deletions src/main/java/net/dries007/tfc/seedmaker/util/WorldGen.java
@@ -1,5 +1,6 @@
package net.dries007.tfc.seedmaker.util;

import ar.com.hjg.pngj.ImageInfo;
import ar.com.hjg.pngj.ImageLineHelper;
import ar.com.hjg.pngj.ImageLineInt;
import ar.com.hjg.pngj.PngWriter;
Expand Down Expand Up @@ -241,8 +242,15 @@ public void run()
for (Tree type : Tree.values()) treeMap1.put(type, 0L);
for (Tree type : Tree.values()) treeMap2.put(type, 0L);

// Prepare the PNG writers
PngWriter[] writers = Helper.prepareGraphics(radius * 2, folder, maps);
// Create an array of PngWriters or null if we don't want a layer.
PngWriter[] writers = new PngWriter[Layers.values().length];
for (int i = 0; i < writers.length; i++)
{
if (maps[i])
{
writers[i] = new PngWriter(new File(folder, Layers.values()[i].name().toLowerCase() + ".png"), new ImageInfo(radius * 2, radius * 2, 8, false), true);
}
}

int chunkCount = 0;
float oceanRatio = 0;
Expand All @@ -258,7 +266,10 @@ public void run()
{
// Make one image row per row in the chunk
imageLines[i] = new ImageLineInt[chunkSize];
for (int j = 0; j < chunkSize; j++) imageLines[i][j] = new ImageLineInt(writers[0].imgInfo);
for (int j = 0; j < chunkSize; j++)
{
imageLines[i][j] = new ImageLineInt(writers[i].imgInfo);
}
}
}
// Per chunk of X lines (again, not per se 16 like in MC. The bigger the better, but more RAM intensive)
Expand Down

0 comments on commit eaa08b1

Please sign in to comment.