-
Notifications
You must be signed in to change notification settings - Fork 69
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Further abstraction of the dependency system for non-cube dependents and bugfixing of the dependency system #18
Conversation
…being set correctly.
@@ -24,6 +24,8 @@ | |||
package cubicchunks.server; | |||
|
|||
import com.google.common.collect.Maps; | |||
|
|||
import cubicchunks.CubeProviderDebug; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to remove this before commit, it breaks the build
I tested using Custom Cubic. |
Just squash all of these small commits... this is getting a bit too messy. And undo formatting changes in |
I'll clean it up asap. I managed to confuse origin/upstream and master/dependency, leading to a jambled mess... Sorry |
@@ -95,7 +95,7 @@ private static DB initializeDBConnection(final File saveFile, final WorldProvide | |||
|
|||
file.getParentFile().mkdirs(); | |||
|
|||
DB db = DBMaker.fileDB(file).transactionEnable().make(); | |||
DB db = DBMaker.fileDB(file).make(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transactions should be enabled
5fb2a97
to
f03fcf1
Compare
- Trying to fix git synchronization issues... sorry - Trying to fix git synchronization issues... sorry - Fixed cubes not appearing on first world load (by reverting change to ServerCubeCache) - Removed unnecessary imports.
- Trying to fix git synchronization issues... sorry - Trying to fix git synchronization issues... sorry - Fixed cubes not appearing on first world load (by reverting change to ServerCubeCache) - Removed unnecessary imports.
…nto dependency
I would also really suggest switching to IntelliJ IDEA, at least for this project. This way you will avois almost all formatting changes. |
- Extracted interface Dependent and renamed former class to DependentCube in preparation for allowing non-cube dependents.
… DependentCube in preparation for permitting generic dependent entities. - Reverted changes to RegionDependency to use a singleton instead. - Removed explicit type declarations.
… DependentCube in preparation for permitting generic dependent entities. - Reverted changes to RegionDependency to use a singleton instead. - Removed explicit type declarations.
I have changed to IDEA, but I cannot guarantee an immediate improvement with regards to formatting as it is driving me nuts D: |
Just import my formatter settings. This way you will have exactly the same settings = no difference. |
} | ||
|
||
public RegionDependency(Cube cube, GeneratorStage stage, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh) { | ||
public RegionDependency(GeneratorStage targetStage, int xLow, int xHigh, int yLow, int yHigh, int zLow, int zHigh) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using Vec3i
s instead of ints here, argument order isn't obvious from code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any naming in mind? "lowerFrontLeft" and "upperBackRight" sound kinda wrong...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startPosition and endPosition? You can sort them in constructor.
…stead of individual integers. - Added todos to several classes.
CubeCoords coords = new CubeCoords(cube.getX() + x, cube.getY() + y, cube.getZ() + z); | ||
if (!cache.cubeExists(coords) || cache.getCube(coords).getCurrentStage().precedes(generatorStage)) { | ||
CubicChunks.LOGGER.error("Missing cube ({})! {}/{}", coords, cache.getCube(coords).getCurrentStage().getName(), generatorStage.getName()); | ||
System.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Never use
System.exit()
, or Forge will show a big warning when loading it that it has direct reference to it, and that it will redirect it. UseFMLCommonHandler.exitJava()
. Or thrownew Error().
- You can simply create
new FastCubeBlockAccess(cubeCache, centerCube, radius)
and modify it to also check stage (and it should check the stage, I simply forgot about that) - it will throw exception if required cube isn't loaded and it will dump information about which cubes are loaded (you can also modify that to include stage if it doesn't do that now). And maybe you could pass thatFastCubeBlockAccess
to some of these methods and use it there.
Or leave it as it's now and let me fix that later.
I want to do as few things as possible in FirstLightProcessor
because it needs to be fast. Currently it's close to vanilla initial lighting preformance. And most of the time is spent creating FastCubeBlockAccess
objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just quickly commited my current code so you can have a go at it if you want to. The check in FirstLightProcessor can go as it never encounters a missing block. If the DependencySystem were failing at delivering the required cubes properly, that loop would exit the program and it does not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, just keep in mind that before merging it, System.exit()
must be removed. Or possibly remove this check entirely. There is a check if world.checkLightFor()
returns true
(if it returns false
it means that world.isAreaLoaded(thePosition, 17, false)
returned false
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, I'll clean it up once I found this f*** bug...
Try logging the DependentCubeManager.getDependentCubeCount and DependencyManager.getRequiredCubeCount. Those should approach zero, but sometimes they don't. |
As for these cubes that are not sent to player: they seem to have wrong target stage set. After trying to see why |
Also, as of some recent changes FeatureProcessor has no dependencies as I merged surface and terrain stages. I could technically even merge terrain and features (as in vanilla). And (at least in my case) debugging showed that it's this stage that has some issues (still, it would be better to fix it properly if it works with Features as independent stage) |
I'm somewhat confident now that everything works as it was supposed to do last week... Thanks for pointing out the wrong targetStage. Apparently some reorganization of loadCube caused it not being set in all cases when loadCube was invoked with a targetStage as parameter. |
@@ -122,7 +122,7 @@ public void generate(Cube cube) { | |||
public void generate(Cube cube, GeneratorStage targetStage) { | |||
|
|||
// Make sure the proper target stage is set. | |||
if (cube.getTargetStage().precedes(targetStage)) { | |||
if (cube.getTargetStage() == null || cube.getTargetStage().precedes(targetStage)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can target stage be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently yes, because it is no longer set in all paths of ServerCubeCache.loadCube, but I'll change that to get rid of that additional check. Cleaner without it.
- Fixed Cube.targetStage not being set properly in ServerCubeCache.loadCube. - Fixed casing in comments. - Added missing comments. - Removed debug code from DependencyManager. - Removed debug code from DependentCubeManager. - Added missing annotations in RegionDependency. - Changed ServerCubeCache.loadCube such that Cube.targetStage is defined in all paths and removed a null check from GeneratorPipeline.
The dependency system makes it difficult for cubes to be unloaded during generation. Usually they end up being finished and unloaded afterwards, meaning it may take some time for them to disappear. |
The way it works is a bit weird. It works fine when moving vertically, but when moving in x/z - cubes are not getting unloaded as in screenshot above. Except that they eventually do end up unloaded because vanilla unloads all cubes that are not loaded by any players every time it saves all chunks. But this is definitely not something that you should rely on. Maybe unload a cube when there is nothing left that depends on it? |
Another approach would be to keep them in unload queue and just skip them from unloading if there is something that depends on them. This way they will be automatically unloaded as soon as possible (potentially slow for high view distance/a lot of players) |
That's what is happening right now. In unloadCube and unloadQueuedCubes the ServerCubeCache skips cubes that are currently being required for other cubes. Cubes which are not required can be unloaded (and all cubes blocked by them will be unloaded thereafter), but since the lighting stage requires the other cubes to be in the exact same stage, this doesn't change much. So to break it down: Dependents must be unloaded first, but since lots of dependents are required themselves, cubes end up not being unloaded early on. |
It's not skipping them. It's removing them from unload queue and skipping. |
Does PlayerCubeMap not put them in the queeue again regardless? |
Nope. It unloads once. And then it assumes that it's unloaded. |
Also, why don't you just read the code? |
I apologize, I'm on the phone right now and commented faster than I was thinking. |
…oUnload. - Changed ServerCubeCache to not remove skipped cubes in unloadQueuedChunks.
The ServerCubeCache no longer removes required cubes from the queue. But to be honest, I don't see a significant change. |
long cubeAddress = this.cubesToUnload.poll(); | ||
Iterator<CubeCoords> iter = this.cubesToUnload.iterator(); | ||
while (iter.hasNext()) { | ||
CubeCoords coords = iter.next(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you never limit the amount of unloaded cubes per tick. unloadQueuedChunks
should be really called tick
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. But I assume limiting it would be a good idea. If you agree I'll add a simple counter and exit once the maximum number is reached. But I'll have to postpone doing so to tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how it was done before, and this is how vanilla does it.
- Fixed CustomCubicChunksWorldType to use IndependentGeneratorStage for feature stage. - Fixed ServerCubeCache.unloadQueuedChunks to not process all queued cubes at once.
I know that unloadding still dowan't work correctly, but fixing that rewuored rewriting some parts of |
The 2d visualization code you posted does not show any unloading of cubes. However, I did make the ServerCubeCache log whenever it unloaded a cube (and loaded) and it did appear to act properly. I couldn't find any cubes not being unloaded after moving 1000 blocks to the north. One issue remaining is the world not showing up on the first generation. Saving the game and reloading solves the problem.