Skip to content

Commit

Permalink
Infinite seed fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-short committed Oct 31, 2015
1 parent d4e62c8 commit 4f78c96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/net/buddat/wgenerator/TileMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import com.wurmonline.mesh.Tiles.Tile;

import net.buddat.wgenerator.util.Constants;

public class TileMap {

private Random biomeRandom;
Expand Down Expand Up @@ -216,7 +218,7 @@ public void plantBiome(int seedCount, int growthIterations, int density, int[] g
long totalSize;
int totalSeeds = 0;

while (totalSeeds < seedCount) {
for (long killCount = 0; totalSeeds < seedCount; killCount++) {
nextList.clear();
progress.setValue((int)((float)totalSeeds/seedCount*100f));

Expand All @@ -239,6 +241,10 @@ public void plantBiome(int seedCount, int growthIterations, int density, int[] g
if (totalSize != 1) {
totalSeeds++;
}
// Prevent infinite looping
if (killCount > seedCount*Constants.BIOME_SEED_LIMIT_MULTIPLIER) {
break;
}
}

log("Biome Seeding (" + type.tilename + ") completed in " + (System.currentTimeMillis() - startTime) + "ms.");
Expand Down
1 change: 1 addition & 0 deletions src/net/buddat/wgenerator/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ public class Constants {
public static final boolean MORE_LAND = true;

public static final int GRID_SIZE = 8;
public static final int BIOME_SEED_LIMIT_MULTIPLIER = 10000;

}

0 comments on commit 4f78c96

Please sign in to comment.