bandaid fix for World gen holes
This commit is contained in:
+2
-2
@@ -335,7 +335,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
|
||||
|
||||
/** This call is concurrent. I.e. it supports multiple threads calling this method at the same time. */
|
||||
@Override
|
||||
public CompletableFuture<Void> flushAndSave()
|
||||
public CompletableFuture<Void> flushAndSaveAsync()
|
||||
{
|
||||
ArrayList<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
for (FullDataMetaFile metaFile : this.loadedMetaFileBySectionPos.values())
|
||||
@@ -346,7 +346,7 @@ public class FullDataFileHandler implements IFullDataSourceProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> flushAndSave(DhSectionPos sectionPos)
|
||||
public CompletableFuture<Void> flushAndSaveAsync(DhSectionPos sectionPos)
|
||||
{
|
||||
FullDataMetaFile metaFile = this.loadedMetaFileBySectionPos.get(sectionPos);
|
||||
if (metaFile == null)
|
||||
|
||||
+13
-2
@@ -130,7 +130,7 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
|
||||
metaFile.markNeedsUpdate();
|
||||
});
|
||||
|
||||
this.flushAndSave(); // Trigger an update to the meta files
|
||||
this.flushAndSaveAsync(); // Trigger an update to the meta files
|
||||
}
|
||||
|
||||
public void clearGenerationQueue()
|
||||
@@ -270,7 +270,18 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
|
||||
else if (genTaskResult.success)
|
||||
{
|
||||
// generation completed, update the files and listener(s)
|
||||
this.flushAndSave(pos);
|
||||
this.flushAndSaveAsync(pos).join();
|
||||
|
||||
// FIXME this is a bad fix to prevent full data sources saving incomplete, causing holes in the world after generation.
|
||||
// The problem appears to be that the save may be happening too quickly,
|
||||
// potentially happening before the meta file has the newly generated data added to it.
|
||||
new Thread(() ->
|
||||
{
|
||||
try{ Thread.sleep(4000); }catch (InterruptedException e){}
|
||||
|
||||
this.flushAndSaveAsync(pos).join();
|
||||
}).start();
|
||||
|
||||
this.fireOnGenPosSuccessListeners(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,8 +32,8 @@ public interface IFullDataSourceProvider extends AutoCloseable
|
||||
{
|
||||
CompletableFuture<IFullDataSource> readAsync(DhSectionPos pos);
|
||||
void writeChunkDataToFile(DhSectionPos sectionPos, ChunkSizedFullDataAccessor chunkData);
|
||||
CompletableFuture<Void> flushAndSave();
|
||||
CompletableFuture<Void> flushAndSave(DhSectionPos sectionPos);
|
||||
CompletableFuture<Void> flushAndSaveAsync();
|
||||
CompletableFuture<Void> flushAndSaveAsync(DhSectionPos sectionPos);
|
||||
|
||||
//long getCacheVersion(DhSectionPos sectionPos);
|
||||
//boolean isCacheVersionValid(DhSectionPos sectionPos, long cacheVersion);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package com.seibel.distanthorizons.core.level;
|
||||
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandler;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.IFullDataSourceProvider;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.RemoteFullDataFileHandler;
|
||||
import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure;
|
||||
@@ -112,7 +111,7 @@ public class DhClientLevel extends DhLevel implements IDhClientLevel
|
||||
@Override
|
||||
public CompletableFuture<Void> saveAsync()
|
||||
{
|
||||
return CompletableFuture.allOf(clientside.saveAsync(), dataFileHandler.flushAndSave());
|
||||
return CompletableFuture.allOf(clientside.saveAsync(), dataFileHandler.flushAndSaveAsync());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -183,7 +183,7 @@ public class DhClientServerLevel extends DhLevel implements IDhClientLevel, IDhS
|
||||
@Override
|
||||
public CompletableFuture<Void> saveAsync()
|
||||
{
|
||||
return CompletableFuture.allOf(clientside.saveAsync(), getFileHandler().flushAndSave());
|
||||
return CompletableFuture.allOf(clientside.saveAsync(), getFileHandler().flushAndSaveAsync());
|
||||
}
|
||||
|
||||
//===============//
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFull
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.IFullDataSourceProvider;
|
||||
import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos2D;
|
||||
import com.seibel.distanthorizons.core.pos.DhLodPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
@@ -75,7 +74,7 @@ public class DhServerLevel extends DhLevel implements IDhServerLevel
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> saveAsync() { return getFileHandler().flushAndSave(); }
|
||||
public CompletableFuture<Void> saveAsync() { return getFileHandler().flushAndSaveAsync(); }
|
||||
|
||||
@Override
|
||||
public void doWorldGen()
|
||||
|
||||
Reference in New Issue
Block a user