This commit is contained in:
s809
2023-12-21 19:17:51 +05:00
3 changed files with 14 additions and 33 deletions
@@ -149,29 +149,27 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
int dataDetailLevel = inputStream.readShort();
if (dataDetailLevel != dataFile.baseMetaData.dataDetailLevel)
{
throw new IOException(LodUtil.formatLog("Data level mismatch: {} != {}", dataDetailLevel, dataFile.baseMetaData.dataDetailLevel));
throw new IOException("Data level mismatch: ["+dataDetailLevel+"] != ["+dataFile.baseMetaData.dataDetailLevel+"]");
}
// confirm that the detail level is correct
int sparseDetail = inputStream.readShort();
if (sparseDetail != SPARSE_UNIT_DETAIL)
{
throw new IOException((LodUtil.formatLog("Unexpected sparse detail level: {} != {}",
sparseDetail, SPARSE_UNIT_DETAIL)));
throw new IOException("Unexpected sparse detail level: ["+sparseDetail+"] != ["+SPARSE_UNIT_DETAIL+"]");
}
// confirm the scale of the data points is correct
int sectionSize = inputStream.readInt();
if (sectionSize != SECTION_SIZE)
{
throw new IOException(LodUtil.formatLog(
"Section size mismatch: {} != {} (Currently only 1 section size is supported)", sectionSize, SECTION_SIZE));
throw new IOException("Section size mismatch: ["+sectionSize+"] != ["+SECTION_SIZE+"] (Currently only 1 section size is supported)");
}
int minY = inputStream.readInt();
if (minY != level.getMinY())
{
LOGGER.warn("Data minY mismatch: " + minY + " != " + level.getMinY() + ". Will ignore data's y level");
LOGGER.warn("Data minY mismatch: [" + minY + "] != [" + level.getMinY() + "]. Will ignore data's y level");
}
EDhApiWorldGenerationStep worldGenStep = EDhApiWorldGenerationStep.fromValue(inputStream.readByte());
@@ -178,7 +178,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
public CompletableFuture<IFullDataSource> getDataSourceWithoutCachingAsync() { return this.getOrLoadCachedDataSourceAsync(false); }
public CompletableFuture<IFullDataSource> getDataSourceWithoutCachingAsync() { return this.getOrLoadCachedDataSourceAsync(true); }
public CompletableFuture<IFullDataSource> getOrLoadCachedDataSourceAsync() { return this.getOrLoadCachedDataSourceAsync(true); }
/**
* Synchronized to help prevent issues where multiple threads try to read as cached and un-cached at the same time.
@@ -299,7 +299,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
}
catch (Exception ex)
{
LOGGER.error("Full Data Load error: "+ ex.getMessage(), ex);
LOGGER.error("Full Data Load error for pos ["+this.pos+"], error: "+ ex.getMessage(), ex);
dataSourceLoadFuture.completeExceptionally(ex);
dataSourceLoadFutureRef.set(null);
@@ -277,33 +277,16 @@ public class GeneratedFullDataFileHandler extends FullDataFileHandler
else if (genTaskResult.success)
{
// generation completed, update the files and listener(s)
this.flushAndSaveAsync(pos).join();
try
// 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.
CHUNK_GEN_FINISHED_TIMER.schedule(new TimerTask()
{
// timeout necessary in case the flush gets stuck or there are issues down stream
// otherwise the world gen might get stuck and never finish
this.flushAndSaveAsync(pos).get(10_000, TimeUnit.MILLISECONDS);
// FIXME this is a bad fix to prevent full data sources saving incompletely, 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.
CHUNK_GEN_FINISHED_TIMER.schedule(new TimerTask()
{
@Override
public void run() { GeneratedFullDataFileHandler.this.flushAndSaveAsync(pos); }
}, 4_000L);
}
catch (InterruptedException | TimeoutException e)
{
LOGGER.warn("Unable to flush and save after waiting [10] seconds. Error: "+e.getMessage(), e);
}
catch (ExecutionException e)
{
LOGGER.error("Unexpected issue saving world gen result. Error: "+e.getMessage(), e);
}
@Override
public void run() { GeneratedFullDataFileHandler.this.flushAndSaveAsync(pos).join(); }
}, 4000L);
this.fireOnGenPosSuccessListeners(pos);
return;