Skip to content

Commit

Permalink
Added comments so its less of an impenetrable mess.
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Mar 19, 2016
1 parent d5ef474 commit 12a01c1
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 61 deletions.
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -16,7 +16,7 @@ Unless otherwise specified per file, or per package via the package-info.java fi

Copyright © 2015 - Dries007 - Available under [GPLv3](license.md)

This program conains code from the [Terrafirmacraft mod](https://github.com/Deadrik/TFCraft).
This program contains code from the [Terrafirmacraft mod](https://github.com/Deadrik/TFCraft).

Done/Todo
----
Expand Down
23 changes: 15 additions & 8 deletions src/main/java/net/dries007/tfc/seedmaker/CommandLineInterface.java
Expand Up @@ -55,23 +55,26 @@ public void run()
System.out.println("- maps: " + maps);

final JsonArray rootArray = new JsonArray();
Thread[] threadAray = new Thread[threads];
if (!seeds.isEmpty())
final Thread[] threadArray = new Thread[threads];

if (!seeds.isEmpty()) // We got seeds via CLI
{
// Queue up all the seeds
final ConcurrentLinkedQueue<WorldGen> queue = new ConcurrentLinkedQueue<>();
for (String seed : seeds) queue.add(new WorldGen(seed, treesAboveWater, rocksInWater, radius, chunkSize, maps));

// Make a bunch of worker threads
for (int i = 0; i < threads; i++)
{
threadAray[i] = new Thread(new Runnable()
threadArray[i] = new Thread(new Runnable()
{
@Override
public void run()
{
while (!queue.isEmpty())
{
WorldGen worldGen = queue.poll();
if (worldGen == null) continue;
if (worldGen == null) continue; // Just in case

worldGen.run();

Expand All @@ -81,12 +84,14 @@ public void run()
});
}
}
else
else // We didn't get seeds via CLI, make some at random
{
// todo: evaluate so we actually only count good seeds
final AtomicInteger goodCount = new AtomicInteger();
// Make a bunch of worker threads
for (int i = 0; i < threads; i++)
{
threadAray[i] = new Thread(new Runnable()
threadArray[i] = new Thread(new Runnable()
{
@Override
public void run()
Expand All @@ -104,12 +109,14 @@ public void run()
}
}

for (int i = 0; i < threads; i++) threadAray[i].start();
// Now actually start the threads
for (int i = 0; i < threads; i++) threadArray[i].start();

// Output routine, quick and dirty.
while (true)
{
boolean done = true;
for (int i = 0; i < threads; i++) if (threadAray[i].isAlive()) done = false;
for (int i = 0; i < threads; i++) if (threadArray[i].isAlive()) done = false;
if (done) break;
try
{
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/net/dries007/tfc/seedmaker/util/Helper.java
Expand Up @@ -40,10 +40,13 @@ public static <K, V> JsonElement toJson(Map<K, V> biomeMap)
return object;
}

public static PngWriter[] prepareGraphics(String[] filenames, int size, File folder, boolean[] maps)
/**
* 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[filenames.length];
for (int i = 0; i < out.length; i++) if (maps[i]) out[i] = new PngWriter(new File(folder, filenames[i] + ".png"), new ImageInfo(size, size, 8, false), true);
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;
}
}
28 changes: 28 additions & 0 deletions src/main/java/net/dries007/tfc/seedmaker/util/Layers.java
@@ -0,0 +1,28 @@
package net.dries007.tfc.seedmaker.util;

/**
* @author Dries007
*/
public enum Layers
{
COMBINED(false),
BIOMES(false),
ROCK_TOP(true),
ROCK_MIDDLE(true),
ROCK_BOTTOM(true),
TREE_0(true),
TREE_1(true),
TREE_2(true),
EVT(false),
RAIN(false),
STABILITY(false),
PH(false),
DRAINAGE(false);

public final boolean addToCombined;

Layers(boolean addToCombined)
{
this.addToCombined = addToCombined;
}
}

0 comments on commit 12a01c1

Please sign in to comment.