refactoring

This commit is contained in:
James Seibel
2023-03-11 12:00:08 -06:00
parent ded7dde42a
commit 3c72765c9a
8 changed files with 25 additions and 24 deletions
@@ -1,6 +1,5 @@
package com.seibel.lod.core.dataObjects.render;
import com.google.common.primitives.Longs;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.dataObjects.render.columnViews.ColumnArrayView;
import com.seibel.lod.core.dataObjects.render.columnViews.ColumnQuadView;
@@ -11,7 +10,6 @@ import com.seibel.lod.core.dataObjects.transformers.FullToColumnTransformer;
import com.seibel.lod.core.level.IDhClientLevel;
import com.seibel.lod.core.pos.DhSectionPos;
import com.seibel.lod.core.render.AbstractRenderBuffer;
import com.seibel.lod.core.file.renderfile.RenderMetaDataFile;
import com.seibel.lod.core.enums.ELodDirection;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.level.IDhLevel;
@@ -435,7 +433,7 @@ public class ColumnRenderSource
return false;
}
public byte getRenderVersion() { return DATA_FORMAT_VERSION; }
public byte getRenderDataFormatVersion() { return DATA_FORMAT_VERSION; }
/**
* Whether this object is still valid. If not, a new one should be created.
@@ -282,20 +282,21 @@ public class FullDataFileHandler implements IFullDataSourceProvider
LodUtil.assertTrue(chunkPos.overlaps(sectionPos.getSectionBBoxPos()), "Chunk "+chunkPos+" does not overlap section "+sectionPos);
chunkPos = chunkPos.convertToDetailLevel((byte) this.minDetailLevel);
this.recursiveWrite(new DhSectionPos(chunkPos.detailLevel, chunkPos.x, chunkPos.z), chunkData);
this.writeChunkDataToMetaFile(new DhSectionPos(chunkPos.detailLevel, chunkPos.x, chunkPos.z), chunkData);
}
private void recursiveWrite(DhSectionPos sectionPos, ChunkSizedFullDataSource chunkData)
private void writeChunkDataToMetaFile(DhSectionPos sectionPos, ChunkSizedFullDataSource chunkData)
{
FullDataMetaFile metaFile = this.files.get(sectionPos);
if (metaFile != null)
{
// Fast path: if there is a file for this section, just write to it.
// there is a file for this position
metaFile.addToWriteQueue(chunkData);
}
if (sectionPos.sectionDetailLevel <= this.topDetailLevel.get())
{
this.recursiveWrite(sectionPos.getParentPos(), chunkData);
// recursively attempt to get the meta file for this position
this.writeChunkDataToMetaFile(sectionPos.getParentPos(), chunkData);
}
}
@@ -6,7 +6,6 @@ import java.io.File;
public class RemoteFullDataFileHandler extends FullDataFileHandler
{
public RemoteFullDataFileHandler(IDhLevel level, File saveRootDir) {
super(level, saveRootDir);
}
public RemoteFullDataFileHandler(IDhLevel level, File saveRootDir) { super(level, saveRootDir); }
}
@@ -236,6 +236,8 @@ public abstract class AbstractMetaDataContainerFile
fileChannel.close();
//LOGGER.info("Saved file: "+this.file.getName());
if (USE_ATOMIC_MOVE_REPLACE)
{
// Atomic move / replace the actual file
@@ -227,7 +227,7 @@ public class RenderMetaDataFile extends AbstractMetaDataContainerFile
private static BaseMetaData makeMetaData(ColumnRenderSource renderSource)
{
return new BaseMetaData(renderSource.getSectionPos(), -1,
renderSource.getDataDetail(), RenderSourceFileHandler.RENDER_SOURCE_TYPE_ID, renderSource.getRenderVersion());
renderSource.getDataDetail(), RenderSourceFileHandler.RENDER_SOURCE_TYPE_ID, renderSource.getRenderDataFormatVersion());
}
private FileInputStream getDataContent() throws IOException
@@ -337,7 +337,7 @@ public class RenderSourceFileHandler implements ILodRenderSourceProvider
//file.metaData.dataVersion.set(newDataVersion);
file.metaData.dataLevel = currentRenderSource.getDataDetail();
file.metaData.dataTypeId = RENDER_SOURCE_TYPE_ID;
file.metaData.loaderVersion = currentRenderSource.getRenderVersion();
file.metaData.loaderVersion = currentRenderSource.getRenderDataFormatVersion();
file.save(currentRenderSource);
}
@@ -16,7 +16,6 @@ import com.seibel.lod.core.pos.DhBlockPos2D;
import com.seibel.lod.core.config.Config;
import com.seibel.lod.core.logging.DhLoggerBuilder;
import com.seibel.lod.core.pos.DhBlockPos;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.block.IBlockStateWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
@@ -278,18 +277,19 @@ public class DhClientServerLevel extends AbstractDhClientLevel implements IDhCli
CompletableFuture<Void> closeAsync(boolean doInterrupt)
{
DhClientServerLevel.this.generatedFullDataFileHandler.clearGenerationQueue();
return this.worldGenerationQueue.startClosing(true, doInterrupt)
.exceptionally(ex ->
{
LOGGER.error("Error closing generation queue", ex);
return null;
}
).thenRun(this.chunkGenerator::close)
.exceptionally(ex ->
{
LOGGER.error("Error closing world gen", ex);
return null;
});
.exceptionally(ex ->
{
LOGGER.error("Error closing generation queue", ex);
return null;
}
).thenRun(this.chunkGenerator::close)
.exceptionally(ex ->
{
LOGGER.error("Error closing world gen", ex);
return null;
});
}
}
@@ -128,6 +128,7 @@ public class DhClientServerWorld extends AbstractDhWorld implements IDhClientWor
@Override
public void close()
{
// at this point the levels are probably unloaded, so this save call usually generally won't do anything
this.saveAndFlush().join();
for (DhClientServerLevel level : this.dhLevels)