From 553a125614cc3b1dc009d591d26c8067de3d78fc Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 20 Apr 2023 19:46:19 -0500 Subject: [PATCH] refactor and minor fixes for FullData --- .../file/fullDatafile/FullDataMetaFile.java | 22 +++++++++---------- .../lod/core/file/metaData/BaseMetaData.java | 2 +- .../lod/core/util/FullDataPointUtil.java | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java b/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java index b84228e8a..81def294d 100644 --- a/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java +++ b/core/src/main/java/com/seibel/lod/core/file/fullDatafile/FullDataMetaFile.java @@ -36,7 +36,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile private final IFullDataSourceProvider handler; private boolean doesFileExist; - public AbstractFullDataSourceLoader loader; + public AbstractFullDataSourceLoader fullDataSourceLoader; public Class dataType; // The '?' type should either be: // SoftReference, or - Non-dirty file that can be GCed @@ -99,12 +99,12 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile this.handler = handler; this.level = level; LodUtil.assertTrue(metaData != null); - loader = AbstractFullDataSourceLoader.getLoader(metaData.dataTypeId, metaData.loaderVersion); - if (loader == null) { + fullDataSourceLoader = AbstractFullDataSourceLoader.getLoader(metaData.dataTypeId, metaData.loaderVersion); + if (fullDataSourceLoader == null) { throw new IOException("Invalid file: Data type loader not found: " + metaData.dataTypeId + "(v" + metaData.loaderVersion + ")"); } - dataType = loader.clazz; + dataType = fullDataSourceLoader.clazz; doesFileExist = true; } @@ -229,11 +229,11 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile } // Load the file. - IFullDataSource data; + IFullDataSource fullDataSource; try (FileInputStream fileInputStream = this.getFileInputStream(); BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream)) { - data = this.loader.loadData(this, bufferedInputStream, this.level); + fullDataSource = this.fullDataSourceLoader.loadData(this, bufferedInputStream, this.level); } catch (Exception ex) { @@ -252,8 +252,8 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile "No one should be writing to the cache while we are in the process of " + "loading one into the cache! Is this a deadlock?"); - data = this.handler.onDataFileLoaded(data, this.metaData, this::saveChanges, this::applyWriteQueue); - return data; + fullDataSource = this.handler.onDataFileLoaded(fullDataSource, this.metaData, this::saveChanges, this::applyWriteQueue); + return fullDataSource; }, this.handler.getIOExecutor()) .exceptionally((ex) -> { @@ -399,10 +399,10 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile // Write/Update data LodUtil.assertTrue(metaData != null); metaData.dataLevel = fullDataSource.getDataDetail(); - loader = AbstractFullDataSourceLoader.getLoader(fullDataSource.getClass(), fullDataSource.getDataVersion()); - LodUtil.assertTrue(loader != null, "No loader for "+fullDataSource.getClass()+" (v"+fullDataSource.getDataVersion()+")"); + fullDataSourceLoader = AbstractFullDataSourceLoader.getLoader(fullDataSource.getClass(), fullDataSource.getDataVersion()); + LodUtil.assertTrue(fullDataSourceLoader != null, "No loader for "+fullDataSource.getClass()+" (v"+fullDataSource.getDataVersion()+")"); dataType = fullDataSource.getClass(); - metaData.dataTypeId = (loader == null) ? 0 : loader.datatypeId; + metaData.dataTypeId = (fullDataSourceLoader == null) ? 0 : fullDataSourceLoader.datatypeId; metaData.loaderVersion = fullDataSource.getDataVersion(); super.writeData((outputStream) -> fullDataSource.saveData(level, this, outputStream)); doesFileExist = true; diff --git a/core/src/main/java/com/seibel/lod/core/file/metaData/BaseMetaData.java b/core/src/main/java/com/seibel/lod/core/file/metaData/BaseMetaData.java index 0d9c85f52..c88ab3b04 100644 --- a/core/src/main/java/com/seibel/lod/core/file/metaData/BaseMetaData.java +++ b/core/src/main/java/com/seibel/lod/core/file/metaData/BaseMetaData.java @@ -17,7 +17,7 @@ public class BaseMetaData public byte dataLevel; // Loader stuff // - /** indicates what data is held in this file, is generally a hash of the data's name */ + /** indicates what data is held in this file, this is generally a hash of the data's name */ public long dataTypeId; public byte loaderVersion; diff --git a/core/src/main/java/com/seibel/lod/core/util/FullDataPointUtil.java b/core/src/main/java/com/seibel/lod/core/util/FullDataPointUtil.java index 0552297db..17b9419e4 100644 --- a/core/src/main/java/com/seibel/lod/core/util/FullDataPointUtil.java +++ b/core/src/main/java/com/seibel/lod/core/util/FullDataPointUtil.java @@ -85,7 +85,7 @@ public class FullDataPointUtil public static int getBottomY(long data) { return (int) ((data >> Y_OFFSET) & Y_MASK); } public static int getLight(long data) { return (int) ((data >> LIGHT_OFFSET) & LIGHT_MASK); } - public static String toString(long data) { return "[ID:" + getId(data) + ",Y:" + getBottomY(data) + ",Height:" + getBottomY(data) + ",Light:" + getLight(data) + "]"; } + public static String toString(long data) { return "[ID:" + getId(data) + ",Y:" + getBottomY(data) + ",Height:" + getHeight(data) + ",Light:" + getLight(data) + "]"; } /** Remaps the biome/blockState ID of the given datapoint */ @Contract(pure = true)