Repository: movingblocks/terasology
Issue: Worldgen seed not unique

<!-- Thanks for taking the time to submit a thorough issue report for Terasology! :-)
Please fill out whichever details below seem relevant to your issue.
Note that suggestions, general questions & support should go in the forum:
* http://forum.terasology.org/forum/suggestions.21
* http://forum.terasology.org/forum/support.20/
Bug reports and crashes likely resulting from bugs in the engine go here on GitHub. -->

### What you were trying to do
I was using noise to generate my world based on the seed provided to my world generator. I assumed this was the seed shown in the world-setup screen.

### What actually happened
Instead of the seed shown in the world-setup screen, the method `BaseFacetedWorldGenerator .setWorldSeed()` got called with parameter `LOTR World-00`. This is supposed to be unique according to docs at `WorldPreGenerationScreen.createSeed()`, but it appears that the integer which gets appended is only incremented when remaining in the menu-area. When starting a world or restarting the game, it gets reset to 0. This makes the world seed be dependant on only the world-generator name and as this stays constant, the generated noise will be the same.
### How to reproduce
* Start the game and create a world using the Perlin generator from the Core module (I used my own generator but this seems to be the case for all generators). Don't touch the seed, maybe set some breakpoints in the setSeed() method of the FacetProviders or BaseFacetedWorldGenerator to check the integer or string you get passed. Let the world generate. 

* Generate a second world and use the same approach. 

This world (if the issue is an actual issue) should be the same as the first. Note that the seed which we saw in the menu was different.

### EDIT: clearer reproduction steps

1) Run the game (either from scratch or with additional modules)
2) Select a world generator (Perlin is a good choice because you immediately see the preview, allowing you to verify more easily)
3) Run and repeat.

Changed files:
engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/WorldPreGenerationScreen.java
engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/GameManifestProvider.java

diff --git a/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/GameManifestProvider.java b/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/GameManifestProvider.java
index 7e9bea2e7..fdaf9c33f 100644
--- a/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/GameManifestProvider.java
+++ b/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/GameManifestProvider.java
@@ -78,7 +78,7 @@ public static GameManifest createGameManifest(final UniverseWrapper universeWrap
         String seed;
         if (universeWrapper.getTargetWorld() != null) {
             uri = universeWrapper.getTargetWorld().getWorldGenerator().getUri();
-            seed = universeWrapper.getTargetWorld().getWorldName().toString() + 0;
+            seed = universeWrapper.getTargetWorld().getWorldGenerator().getWorldSeed();
             gameManifest.setSeed(seed);
         } else {
             uri = config.getWorldGeneration().getDefaultGenerator();
diff --git a/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/WorldPreGenerationScreen.java b/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/WorldPreGenerationScreen.java
index 9b5edfcea..d0970ebe0 100644
--- a/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/WorldPreGenerationScreen.java
+++ b/engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/WorldPreGenerationScreen.java
@@ -267,7 +267,8 @@ private WorldSetupWrapper findWorldByName(String searchWorld) {
      * @return The seed as a string.
      */
     private String createSeed(String world) {
-        return world + seedNumber++;
+        String seed = context.get(UniverseWrapper.class).getSeed();
+        return seed + world + seedNumber++;
     }
 
     private void setWorldGenerators() {