Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge world config screen into preview screen #1726

Merged
merged 11 commits into from May 24, 2015

Conversation

msteiger
Copy link
Member

This PR merges the Config and the Preview screen into one, allowing for interactive changes:

image

It also contains a few related fixes and features:

However, it

  • changes the WorldConfigurator interface
  • changes the WorldBuilderclass

This requires fixes in all modules with world generators 馃槩

@Cervator
Copy link
Member

Looking forward to playing with this in the weekend!

I'm not too worried about changing a few world-bearing modules, that's not a big deal :-)

However, at least in the case of WorldConfigurator.java, couldn't we just take advantage of Java 8 and provide a default interface method? We could even replace WorldConfiguratorAdapter that way entirely if I'm not mistaken?

Which I may well be - taking a while to get used to the new stuff :D

There are some other (unrelated) places we can do that too, I believe.

ResolutionResult result = resolver.resolve(moduleName);
if (result.isSuccess()) {
environment = moduleManager.loadEnvironment(result.getModules(), false);
CoreRegistry.put(WorldGeneratorPluginLibrary.class, new TempWorldGeneratorPluginLibrary(environment));
CoreRegistry.get(AssetManager.class).setEnvironment(environment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently trying to remove CoreRegistry usage. The AssetManager can also be obtained via depenendcy injection. e.g. by adding a private AssetManager field with an @in annotation.

The registration can be done after #1721 is merged by obtaining a Context instance via dependency injection. It offers a put method like CoreRegistry. Although I find a bit strange of a location for registering objects.

@flo
Copy link
Contributor

flo commented May 16, 2015

@msteiger I tried it out, it's a cool feature. Do you plan to make it recalculate automatically at every value change? That would be even cooler 8)

Also a randomize button next to the seen value would be qutie useful. Maybe we could call it "Next" to keep it simpler

Changing the high map caused some exceptions to be logged, but game didn't crash:
http://paste.ubuntu.com/11165495/

@msteiger
Copy link
Member Author

Thanks for the review. I will wait until #1721 is resolved and update this PR accordingly. Functional changes/improvements will be in the next PR :-)

@Cervator I don't know what's best here, so I tend to stick with well-approved approaches. Also there are some issues with default methods to keep in mind.

@Cervator
Copy link
Member

Merge of #1721 is complete, update away :-)

Thanks for the article link, interesting content and good things to watch out for. I think we're pretty safe here, as long as we don't go crazy. Want to try throwing away the old adapter class?

Also take a look at PolyWorld with the PR just merged, there was a broken (as in, fail to compile) unit test in there after the merge, IIRC (you saw it earlier, unsure if there's a fix already waiting)

@GooeyHub
Copy link
Member

Refer to this link for build results (access rights to CI server needed):
http://jenkins.terasology.org/job/TerasologyPRs/82/
Hooray Jenkins reported success with all tests good!

@GooeyHub
Copy link
Member

Refer to this link for build results (access rights to CI server needed):
http://jenkins.terasology.org/job/TerasologyPRs/83/
Hooray Jenkins reported success with all tests good!

@msteiger
Copy link
Member Author

I've updated the code and rebased it on top of develop.

It still uses CoreRegistry, since this is where WorldBuilder is looking for plugins. I'm not sure how this could be changed reasonably as it would require injecting different Context instances (as I understand it). In any case I consider this out of scope for this PR and can be dealt with separately.

@Cervator
Copy link
Member

Looked at this some more. A few of the module worlds are easy fixes (just remove the seed parameter from createWorld right?) but a few others are more tricky.

Cities, LightAndShadow, and Pathfinding have their world gens extend AbstractBaseWorldGenerator, which now means they require getConfigurator. Yet if I add that and just return null it would seem badness can happen in PreviewWorldScreen.configureProperties, and a few other places in that class have NPE warnings in IntelliJ

Is that class just obsolete now or something? Seemingly used in CreateGameScreen, which also has NPE warnings.

WoodAndStoneWorldGenerator extends PluggableWorldGenerator and has a getConfigurator, but that now a wrong return type. That was the main place I saw I could just return null but that would probably lead to NPEs

@msteiger want to add some more NPE hardening and/or merge this then apply fixes to the modules directly next? Two trivial fixes in AnotherWorld + TutorialWorldGeneration, same fix in Pathfinding but it also needs more.

I couldn't replicate the same errors @flo reported in the HeightMap world, although I did crash on shutdown:

01:26:36.111 [main] INFO  o.terasology.engine.TerasologyEngine - Shutting down Terasology...
01:26:36.371 [main] INFO  o.t.p.i.ReadWriteStorageManager - Saving - Creating game snapshot
01:26:36.392 [main] INFO  o.t.p.i.ReadWriteStorageManager - Saving - Snapshot created: Writing phase starts
01:26:36.394 [main] INFO  o.t.n.internal.NetworkSystemImpl - Client disconnected: Cervator
01:26:36.408 [main] INFO  o.t.logic.console.ConsoleImpl - [NOTIFICATION] Player "Cervator" has left the game
01:26:36.411 [main] INFO  o.t.n.internal.NetworkSystemImpl - Network shutdown
01:26:36.599 [Chunk-Updater-0] ERROR o.t.u.concurrency.TaskProcessor - Error in thread Chunk-Updater-0
java.lang.NullPointerException: null
    at org.terasology.world.chunks.internal.ChunkImpl.getSunlight(ChunkImpl.java:206) ~[classes/:na]
    at org.terasology.world.chunks.internal.ChunkImpl.getSunlight(ChunkImpl.java:201) ~[classes/:na]
    at org.terasology.world.internal.ChunkViewCoreImpl.getSunlight(ChunkViewCoreImpl.java:138) ~[classes/:na]
    at org.terasology.world.internal.ChunkViewCoreImpl.getSunlight(ChunkViewCoreImpl.java:113) ~[classes/:na]
    at org.terasology.rendering.primitives.ChunkTessellator.calcLightingValuesForVertexPos(ChunkTessellator.java:179) ~[classes/:na]
    at org.terasology.rendering.primitives.ChunkTessellator.generateOptimizedBuffers(ChunkTessellator.java:116) ~[classes/:na]
    at org.terasology.rendering.primitives.ChunkTessellator.generateMesh(ChunkTessellator.java:69) ~[classes/:na]
    at org.terasology.rendering.world.ChunkMeshUpdateManager$ChunkUpdateTask.run(ChunkMeshUpdateManager.java:169) ~[classes/:na]
    at org.terasology.utilities.concurrency.TaskProcessor.run(TaskProcessor.java:50) ~[classes/:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_31]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]
01:26:36.603 [Chunk-Updater-6] ERROR o.t.u.concurrency.TaskProcessor - Error in thread Chunk-Updater-6
java.lang.NullPointerException: null
...

Seemed to happen again even after resetting saves + config. Reverted to plain develop and it went away.

As for @flo's earlier comment about updating the preview for every change I think that's how it worked at one point, but it would stall the UI while regenerating which got annoying if you wanted to change multiple settings, thus the apply button :-) Unsure if that would be an issue still. +1 for a "Random!" button shuffling seed + all config :D

@msteiger
Copy link
Member Author

I could replicate the error @flo reported, but it's not related to this PR. It doesn't reload the asset properly, since it doesn't get notified on parameter changes. We'll need a notification system first. I'll just deactivate it until this is in place.

I'll also prepare a few PRs in the affected modules, so we can merge them at the same time.

I cannot imagine how this PR could affect chunk generation and sunlight computation in particular. Does it happen after you start the game or in the preview screen?

@Cervator
Copy link
Member

It happened on exiting the game from inside a height map world. Nothing special done or set up, just default everything, new game in heightmap, exit game, boom.

I don't imagine it relates to sunlight so much as some hidden issue leaving the game in an unstable state at the time of exit. I'll try it again tonight in case there was something wrong with my system last night.

If the tiny PR modules are a hassle you can just self-merge this then push the fixes directly to modules after :-)

@Cervator
Copy link
Member

Okay, now I can't replicate the crash. Weird.

@msteiger please merge this at your convenience then tweak the affected modules :-)

@flo
Copy link
Contributor

flo commented May 23, 2015

@msteiger about the Context: You can use the available Context instance everywhere were you use the CoreRegistry as the former is just forwarding the calls to the context.

About the deletion: I suggest we go for no deletion but create a issue for it. The issue doesn't need to be addressed in this pull request.

Conflicts:
	engine/src/main/java/org/terasology/engine/modes/loadProcesses/CreateWorldEntity.java
	engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/ConfigWorldGenScreen.java
	engine/src/main/java/org/terasology/rendering/nui/layers/mainMenu/PreviewWorldScreen.java
	engine/src/main/java/org/terasology/world/generator/plugin/TempWorldGeneratorPluginLibrary.java
@GooeyHub
Copy link
Member

Refer to this link for build results (access rights to CI server needed):
http://jenkins.terasology.org/job/TerasologyPRs/98/
Hooray Jenkins reported success with all tests good!

@GooeyHub
Copy link
Member

Refer to this link for build results (access rights to CI server needed):
http://jenkins.terasology.org/job/TerasologyPRs/100/
Hooray Jenkins reported success with all tests good!

@msteiger
Copy link
Member Author

Afaict, all issues are resolved now. I'm merging this now so we can move on with follow-up changes without getting straight into merge conflict hell.

msteiger added a commit that referenced this pull request May 24, 2015
Merge world config screen into preview screen
@msteiger msteiger merged commit b2bcc42 into MovingBlocks:develop May 24, 2015
@Cervator Cervator added this to the !NEXT: v0.54.0 milestone May 25, 2015
@msteiger
Copy link
Member Author

All affected modules have been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants