Start working on Full Datatype
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
package com.seibel.lod.core.a7.datatype.column;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.column.accessor.ColumnArrayView;
|
||||
import com.seibel.lod.core.a7.datatype.column.accessor.ColumnDataView;
|
||||
import com.seibel.lod.core.a7.datatype.column.accessor.IColumnDataView;
|
||||
import com.seibel.lod.core.logging.SpamReducedLogger;
|
||||
import com.seibel.lod.core.util.ColorUtil;
|
||||
|
||||
@@ -298,7 +298,7 @@ public class ColumnFormat
|
||||
* @param sourceData one or more columns of data
|
||||
* @param output one column of space for the result to be written to
|
||||
*/
|
||||
public static void mergeMultiData(ColumnDataView sourceData, ColumnArrayView output)
|
||||
public static void mergeMultiData(IColumnDataView sourceData, ColumnArrayView output)
|
||||
{
|
||||
if (output.dataCount() != 1) throw new IllegalArgumentException("output must be only reserved for one datapoint!");
|
||||
int inputVerticalSize = sourceData.verticalSize();
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.seibel.lod.core.a7.datatype.column.ColumnFormat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class ColumnArrayView implements ColumnDataView {
|
||||
public final class ColumnArrayView implements IColumnDataView {
|
||||
private final long[] data;
|
||||
private final int size; // size in longs
|
||||
private final int offset; // offset in longs
|
||||
@@ -47,7 +47,7 @@ public final class ColumnArrayView implements ColumnDataView {
|
||||
Arrays.fill(data, offset, offset + size, value);
|
||||
}
|
||||
|
||||
public void copyFrom(ColumnDataView source, int outputDataIndexOffset) {
|
||||
public void copyFrom(IColumnDataView source, int outputDataIndexOffset) {
|
||||
if (source.verticalSize() > vertSize) throw new IllegalArgumentException("source verticalSize must be <= self's verticalSize to copy");
|
||||
if (source.dataCount() + outputDataIndexOffset > dataCount()) throw new IllegalArgumentException("dataIndexStart + source.dataCount() must be <= self.dataCount() to copy");
|
||||
if (source.verticalSize() != vertSize) {
|
||||
@@ -61,7 +61,7 @@ public final class ColumnArrayView implements ColumnDataView {
|
||||
source.copyTo(data, offset + outputDataIndexOffset * vertSize);
|
||||
}
|
||||
}
|
||||
public void copyFrom(ColumnDataView source) {
|
||||
public void copyFrom(IColumnDataView source) {
|
||||
copyFrom(source, 0);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public final class ColumnArrayView implements ColumnDataView {
|
||||
return anyChange;
|
||||
}
|
||||
|
||||
public void changeVerticalSizeFrom(ColumnDataView source) {
|
||||
public void changeVerticalSizeFrom(IColumnDataView source) {
|
||||
if (dataCount() != source.dataCount()) {
|
||||
throw new IllegalArgumentException("Cannot copy and resize to views with different dataCounts");
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public final class ColumnArrayView implements ColumnDataView {
|
||||
}
|
||||
}
|
||||
|
||||
public void mergeMultiDataFrom(ColumnDataView source) {
|
||||
public void mergeMultiDataFrom(IColumnDataView source) {
|
||||
if (dataCount() != 1) {
|
||||
throw new IllegalArgumentException("output dataCount must be 1");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.seibel.lod.core.a7.datatype.column.accessor;
|
||||
|
||||
public class ColumnQuadView implements ColumnDataView {
|
||||
public class ColumnQuadView implements IColumnDataView {
|
||||
private final long[] data;
|
||||
private final int perRowOffset; // per row offset in longs
|
||||
private final int perColumnOffset; // per column (of columns of data) offset in longs
|
||||
private final int xSize; // x size in datapoints
|
||||
private final int zSize; // x size in datapoints
|
||||
private final int offset; // offset in longs
|
||||
@@ -15,12 +15,12 @@ public class ColumnQuadView implements ColumnDataView {
|
||||
this.xSize = xSize;
|
||||
this.zSize = zSize;
|
||||
this.vertSize = dataVertSize;
|
||||
this.perRowOffset = dataZWidth * dataVertSize;
|
||||
this.offset = (viewXOffset * perRowOffset + viewZOffset) * dataVertSize;
|
||||
this.perColumnOffset = dataZWidth * dataVertSize;
|
||||
this.offset = (viewXOffset * perColumnOffset + viewZOffset) * dataVertSize;
|
||||
}
|
||||
private ColumnQuadView(long[] data, int perRowOffset, int offset, int vertSize, int xSize, int zSize) {
|
||||
private ColumnQuadView(long[] data, int perColumnOffset, int offset, int vertSize, int xSize, int zSize) {
|
||||
this.data = data;
|
||||
this.perRowOffset = perRowOffset;
|
||||
this.perColumnOffset = perColumnOffset;
|
||||
this.offset = offset;
|
||||
this.vertSize = vertSize;
|
||||
this.xSize = xSize;
|
||||
@@ -29,32 +29,32 @@ public class ColumnQuadView implements ColumnDataView {
|
||||
|
||||
@Override
|
||||
public long get(int index) {
|
||||
int x = index % (xSize * vertSize);
|
||||
int z = index / (xSize * vertSize);
|
||||
int x = index / perColumnOffset;
|
||||
int z = (index % perColumnOffset) / vertSize;
|
||||
int v = index % vertSize;
|
||||
return get(x, z, v);
|
||||
}
|
||||
|
||||
public long get(int x, int z, int v) {
|
||||
return data[offset + x * perRowOffset + z * vertSize + v];
|
||||
return data[offset + x * perColumnOffset + z * vertSize + v];
|
||||
}
|
||||
|
||||
public long set(int x, int z, int v, long value) {
|
||||
return data[offset + x * perRowOffset + z * vertSize + v] = value;
|
||||
return data[offset + x * perColumnOffset + z * vertSize + v] = value;
|
||||
}
|
||||
|
||||
public ColumnArrayView get(int x, int z) {
|
||||
return new ColumnArrayView(data, vertSize, offset + x * perRowOffset + z * vertSize, vertSize);
|
||||
return new ColumnArrayView(data, vertSize, offset + x * perColumnOffset + z * vertSize, vertSize);
|
||||
}
|
||||
|
||||
public ColumnArrayView getRow(int x) {
|
||||
return new ColumnArrayView(data, vertSize, offset + x * perRowOffset, zSize * vertSize);
|
||||
return new ColumnArrayView(data, vertSize, offset + x * perColumnOffset, zSize * vertSize);
|
||||
}
|
||||
|
||||
public void set(int x, int z, ColumnDataView singleColumn) {
|
||||
public void set(int x, int z, IColumnDataView singleColumn) {
|
||||
if (singleColumn.verticalSize() != vertSize) throw new IllegalArgumentException("Vertical size of singleColumn must be equal to vertSize");
|
||||
if (singleColumn.dataCount() != 1) throw new IllegalArgumentException("SingleColumn must contain exactly one data point");
|
||||
singleColumn.copyTo(data, x * perRowOffset + z * vertSize);
|
||||
singleColumn.copyTo(data, x * perColumnOffset + z * vertSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,22 +73,22 @@ public class ColumnQuadView implements ColumnDataView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColumnDataView subView(int dataIndexStart, int dataCount) {
|
||||
public IColumnDataView subView(int dataIndexStart, int dataCount) {
|
||||
if (dataCount != 1) throw new UnsupportedOperationException("Fixme: subView for QUadView only support one data point!");
|
||||
int x = dataIndexStart % xSize;
|
||||
int z = dataIndexStart / xSize;
|
||||
return new ColumnArrayView(data, vertSize, offset + x * perRowOffset + z * vertSize, vertSize);
|
||||
return new ColumnArrayView(data, vertSize, offset + x * perColumnOffset + z * vertSize, vertSize);
|
||||
}
|
||||
|
||||
public ColumnQuadView subView(int xOffset, int zOffset, int xSize, int zSize) {
|
||||
if (xOffset + xSize > this.xSize || zOffset + zSize > this.zSize) throw new IllegalArgumentException("SubView is out of bounds");
|
||||
return new ColumnQuadView(data, perRowOffset, offset + xOffset * perRowOffset + zOffset * vertSize, vertSize, xSize, zSize);
|
||||
return new ColumnQuadView(data, perColumnOffset, offset + xOffset * perColumnOffset + zOffset * vertSize, vertSize, xSize, zSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(long[] target, int offset) {
|
||||
for (int x = 0; x < xSize; x++) {
|
||||
System.arraycopy(data, this.offset + x * perRowOffset, target, offset + x * xSize * vertSize, zSize * vertSize);
|
||||
System.arraycopy(data, this.offset + x * perColumnOffset, target, offset + x * xSize * vertSize, zSize * vertSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -2,7 +2,7 @@ package com.seibel.lod.core.a7.datatype.column.accessor;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface ColumnDataView {
|
||||
public interface IColumnDataView {
|
||||
long get(int index);
|
||||
|
||||
int size();
|
||||
@@ -27,7 +27,8 @@ public interface ColumnDataView {
|
||||
|
||||
int dataCount();
|
||||
|
||||
ColumnDataView subView(int dataIndexStart, int dataCount);
|
||||
IColumnDataView subView(int dataIndexStart, int dataCount);
|
||||
|
||||
@Deprecated //This is unsafe for quadViews. And its a mess for multi-columns!
|
||||
void copyTo(long[] target, int offset);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.seibel.lod.core.a7.datatype.full;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.full.accessor.FullArrayView;
|
||||
|
||||
public class ChunkSizedData extends FullArrayView {
|
||||
private final long[][] chunkDataArray = new long[16*16][];
|
||||
|
||||
public ChunkSizedData(long[][] dataArrays) {
|
||||
super(dataArrays, 16);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.seibel.lod.core.a7.datatype.full;
|
||||
|
||||
// Static class for the data format:
|
||||
// ID: blockState id Y: Height(signed) DP: Depth(signed?)
|
||||
// =======Bit layout=======
|
||||
// __ __ __ __ __ __ __ __ <-- Top bits
|
||||
// YY YY YY YY YY YY YY YY
|
||||
// YY YY YY YY DP DP DP DP
|
||||
// DP DP DP DP DP DP DP DP
|
||||
// ID ID ID ID ID ID IO ID
|
||||
// ID ID ID ID ID ID IO ID
|
||||
// ID ID ID ID ID ID IO ID
|
||||
// ID ID ID ID ID ID IO ID <-- Bottom bits
|
||||
|
||||
|
||||
public class Data {
|
||||
|
||||
public static final int ID_WIDTH = 32;
|
||||
public static final int DP_WIDTH = 12;
|
||||
public static final int Y_WIDTH = 12;
|
||||
public static final int ID_OFFSET = 0;
|
||||
public static final int DP_OFFSET = ID_OFFSET + ID_WIDTH;
|
||||
public static final int Y_OFFSET = DP_OFFSET + DP_WIDTH;
|
||||
|
||||
public static final int ID_MASK = (int)Math.pow(2, ID_WIDTH) - 1;
|
||||
public static final int DP_MASK = (int)Math.pow(2, DP_WIDTH) - 1;
|
||||
public static final int Y_MASK = (int)Math.pow(2, Y_WIDTH) - 1;
|
||||
|
||||
public static long encode(int id, int depth, int y) {
|
||||
long data = 0;
|
||||
data |= id & ID_MASK;
|
||||
data |= (long) (depth & DP_MASK) << DP_OFFSET;
|
||||
data |= (long) (y & Y_MASK) << Y_OFFSET;
|
||||
return data;
|
||||
}
|
||||
|
||||
public static int getId(long data) {
|
||||
return (int) (data & ID_MASK);
|
||||
}
|
||||
|
||||
public static int getDepth(long data) {
|
||||
return (int) (data << (64 - DP_OFFSET - DP_WIDTH) >> DP_OFFSET);
|
||||
}
|
||||
|
||||
public static int getY(long data) {
|
||||
return (int) (data << (64 - Y_OFFSET - Y_WIDTH) >> Y_OFFSET);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.seibel.lod.core.a7.datatype.full;
|
||||
|
||||
public enum EGenMode {
|
||||
Empty,
|
||||
Surface,
|
||||
Feature,
|
||||
Complete;
|
||||
public static EGenMode get(byte genMode) {
|
||||
return EGenMode.values()[genMode];
|
||||
}
|
||||
public static byte get(EGenMode genMode) {
|
||||
return (byte) genMode.ordinal();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.seibel.lod.core.a7.datatype.full;
|
||||
|
||||
import com.seibel.lod.core.a7.level.ILevel;
|
||||
import com.seibel.lod.core.a7.save.io.file.DataMetaFile;
|
||||
import com.seibel.lod.core.a7.datatype.LodDataSource;
|
||||
import com.seibel.lod.core.a7.util.IdMappingUtil;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class FullDataSource implements LodDataSource { // 1 chunk
|
||||
private DhSectionPos sectionPos;
|
||||
ArrayList<String> idMap;
|
||||
protected FullDataSource() {
|
||||
idMap = new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DhSectionPos getSectionPos() {
|
||||
return sectionPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getDataDetail() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocalVersion(int localVer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getDataVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData(ILevel level, DataMetaFile file, OutputStream dataStream) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
public static FullDataSource createNewFromChunk(IChunkWrapper chunk) {
|
||||
FullDataSource dataContainer = new FullDataSource();
|
||||
HashMap<String, Integer> idMap = new HashMap<String, Integer>();
|
||||
|
||||
idMap.put(IdMappingUtil.BLOCKSTATE_ID_AIR, 0);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int y = chunk.getMaxY(x, z);
|
||||
String currentBlockState = IdMappingUtil.BLOCKSTATE_ID_AIR;
|
||||
// FIXME: Move LodBuilder code to here
|
||||
}
|
||||
}
|
||||
return dataContainer;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +1,49 @@
|
||||
package com.seibel.lod.core.a7.datatype.full;
|
||||
|
||||
import com.seibel.lod.core.a7.level.ILevel;
|
||||
import com.seibel.lod.core.a7.save.io.file.DataMetaFile;
|
||||
import com.seibel.lod.core.a7.datatype.LodDataSource;
|
||||
import com.seibel.lod.core.a7.util.IdMappingUtil;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
// Static class for the data format:
|
||||
// ID: blockState id Y: Height(signed) DP: Depth(signed?)
|
||||
// =======Bit layout=======
|
||||
// __ __ __ __ __ __ __ __ <-- Top bits
|
||||
// YY YY YY YY YY YY YY YY
|
||||
// YY YY YY YY DP DP
|
||||
// DP DP DP DP DP DP DP DP DP DP
|
||||
// ID ID ID ID ID ID IO ID
|
||||
// ID ID ID ID ID ID IO ID
|
||||
// ID ID ID ID ID ID IO ID
|
||||
// ID ID ID ID ID ID IO ID <-- Bottom bits
|
||||
//
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
public class FullFormat {
|
||||
|
||||
public class FullFormat implements LodDataSource { // 1 chunk
|
||||
private DhSectionPos sectionPos;
|
||||
ArrayList<String> idMap;
|
||||
public static final int ID_WIDTH = 32;
|
||||
public static final int DP_WIDTH = 12;
|
||||
public static final int Y_WIDTH = 12;
|
||||
public static final int ID_OFFSET = 0;
|
||||
public static final int DP_OFFSET = ID_OFFSET + ID_WIDTH;
|
||||
public static final int Y_OFFSET = DP_OFFSET + DP_WIDTH;
|
||||
|
||||
protected FullFormat() {
|
||||
idMap = new ArrayList<String>();
|
||||
public static final int ID_MASK = (int)Math.pow(2, ID_WIDTH) - 1;
|
||||
public static final int DP_MASK = (int)Math.pow(2, DP_WIDTH) - 1;
|
||||
public static final int Y_MASK = (int)Math.pow(2, Y_WIDTH) - 1;
|
||||
|
||||
public static long encode(int id, int depth, int y) {
|
||||
long data = 0;
|
||||
data |= id & ID_MASK;
|
||||
data |= (long) (depth & DP_MASK) << DP_OFFSET;
|
||||
data |= (long) (y & Y_MASK) << Y_OFFSET;
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DhSectionPos getSectionPos() {
|
||||
return sectionPos;
|
||||
public static int getId(long data) {
|
||||
return (int) (data & ID_MASK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getDataDetail() {
|
||||
return 0;
|
||||
public static int getDepth(long data) {
|
||||
return (int) (data << (64 - DP_OFFSET - DP_WIDTH) >> DP_OFFSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocalVersion(int localVer) {
|
||||
|
||||
public static int getY(long data) {
|
||||
return (int) (data << (64 - Y_OFFSET - Y_WIDTH) >> Y_OFFSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getDataVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData(ILevel level, DataMetaFile file, OutputStream dataStream) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
public static FullFormat createNewFromChunk(IChunkWrapper chunk) {
|
||||
FullFormat dataContainer = new FullFormat();
|
||||
HashMap<String, Integer> idMap = new HashMap<String, Integer>();
|
||||
|
||||
idMap.put(IdMappingUtil.BLOCKSTATE_ID_AIR, 0);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int y = chunk.getMaxY(x, z);
|
||||
String currentBlockState = IdMappingUtil.BLOCKSTATE_ID_AIR;
|
||||
// FIXME: Move LodBuilder code to here
|
||||
}
|
||||
}
|
||||
return dataContainer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.seibel.lod.core.a7.datatype.full.accessor;
|
||||
|
||||
public class FullArrayView implements IFullDataView {
|
||||
private final long[][] dataArrays;
|
||||
private final int offset;
|
||||
private final int size;
|
||||
|
||||
public FullArrayView(long[][] dataArrays, int size) {
|
||||
if (dataArrays.length != size*size)
|
||||
throw new IllegalArgumentException(
|
||||
"tried constructing dataArrayView with invalid input!");
|
||||
this.dataArrays = dataArrays;
|
||||
this.size = size;
|
||||
offset = 0;
|
||||
}
|
||||
public FullArrayView(FullArrayView source, int size, int offsetX, int offsetZ) {
|
||||
if (source.size < size || source.size < size+offsetX || source.size < size+offsetZ)
|
||||
throw new IllegalArgumentException(
|
||||
"tried constructing dataArrayView subview with invalid input!");
|
||||
dataArrays = source.dataArrays;
|
||||
this.size = size;
|
||||
offset = source.offset + offsetX * size + offsetZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFullArrayView get(int index) {
|
||||
return new SingleFullArrayView(dataArrays, index + offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFullArrayView get(int x, int z) {
|
||||
return new SingleFullArrayView(dataArrays, x*size + z + offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int width() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFullDataView subView(int size, int ox, int oz) {
|
||||
return new FullArrayView(this, size, ox, oz);
|
||||
}
|
||||
|
||||
public void copyTo(FullArrayView target) {
|
||||
if (target.size != size)
|
||||
throw new IllegalArgumentException("Target view must have same size as this view");
|
||||
for (int x=0; x<size; x++) {
|
||||
System.arraycopy(dataArrays, offset+x*size,
|
||||
target.dataArrays, offset+x*size, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.seibel.lod.core.a7.datatype.full.accessor;
|
||||
|
||||
public interface IFullDataType {
|
||||
byte getDetailOffset();
|
||||
default int getDataSize() {
|
||||
return 1 << getDetailOffset();
|
||||
}
|
||||
long getRoughRamUsage();
|
||||
int getVerticalSize(int posX, int posZ);
|
||||
boolean doesItExist(int posX, int posZ);
|
||||
byte getGenModeAtChunk(int chunkX, int chunkZ);
|
||||
SingleFullArrayView getDataAtColumn(int posX, int posZ);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.seibel.lod.core.a7.datatype.full.accessor;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface IFullDataView {
|
||||
SingleFullArrayView get(int index);
|
||||
SingleFullArrayView get(int x, int z);
|
||||
int width();
|
||||
default Iterator<SingleFullArrayView> iterator() {
|
||||
return new Iterator<SingleFullArrayView>() {
|
||||
private int index = 0;
|
||||
private final int size = width();
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return index < size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFullArrayView next() {
|
||||
return get(index++);
|
||||
}
|
||||
};
|
||||
}
|
||||
IFullDataView subView(int size, int ox, int oz);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.seibel.lod.core.a7.datatype.full.accessor;
|
||||
|
||||
public class SingleFullArrayView implements IFullDataView {
|
||||
private final long[][] dataArrays;
|
||||
private final int offset;
|
||||
public SingleFullArrayView(long[][] dataArrays, int offset) {
|
||||
this.dataArrays = dataArrays;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public boolean doesItExist() {
|
||||
return dataArrays[offset].length!=0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFullArrayView get(int index) {
|
||||
if (index != 0) throw new IllegalArgumentException("Only contains 1 column of full data!");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleFullArrayView get(int x, int z) {
|
||||
if (x != 0 || z != 0) throw new IllegalArgumentException("Only contains 1 column of full data!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getSingle(int yIndex) {
|
||||
return dataArrays[offset][yIndex];
|
||||
}
|
||||
public void setSingle(int yIndex, long value) {
|
||||
dataArrays[offset][yIndex] = value;
|
||||
}
|
||||
public void setNew(long[] newArray) {
|
||||
dataArrays[offset] = newArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int width() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFullDataView subView(int size, int ox, int oz) {
|
||||
if (size != 1 || ox != 1 || oz != 1)
|
||||
throw new IllegalArgumentException("Getting invalid range of subView from SingleFullArrayView!");
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.seibel.lod.core.a7.datatype.transform;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.full.ChunkSizedData;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
public class LodDataBuilder {
|
||||
public static ChunkSizedData createChunkData(IChunkWrapper chunk) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.LodDataSource;
|
||||
import com.seibel.lod.core.a7.datatype.DataSourceLoader;
|
||||
import com.seibel.lod.core.a7.datatype.full.Data;
|
||||
import com.seibel.lod.core.a7.datatype.full.FullFormat;
|
||||
import com.seibel.lod.core.a7.save.io.MetaFile;
|
||||
import com.seibel.lod.core.a7.level.ILevel;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
@@ -36,13 +36,13 @@ public class DataMetaFile extends MetaFile {
|
||||
//TODO: use ConcurrentAppendSingleSwapContainer<LodDataSource> instead of below:
|
||||
private static class GuardedMultiAppendQueue {
|
||||
ReentrantReadWriteLock appendLock = new ReentrantReadWriteLock();
|
||||
ConcurrentLinkedQueue<Data> queue = new ConcurrentLinkedQueue<>();
|
||||
ConcurrentLinkedQueue<FullFormat> queue = new ConcurrentLinkedQueue<>();
|
||||
}
|
||||
AtomicReference<GuardedMultiAppendQueue> writeQueue =
|
||||
new AtomicReference<>(new GuardedMultiAppendQueue());
|
||||
GuardedMultiAppendQueue _backQueue = new GuardedMultiAppendQueue();
|
||||
|
||||
public void addToWriteQueue(Data datatype) {
|
||||
public void addToWriteQueue(FullFormat datatype) {
|
||||
GuardedMultiAppendQueue queue = writeQueue.get();
|
||||
// Using read lock is OK, because the queue's underlying data structure is thread-safe.
|
||||
// This lock is only used to insure on polling the queue, that the queue is not being
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.seibel.lod.core.a7.save.io.file;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.LodDataSource;
|
||||
import com.seibel.lod.core.a7.datatype.full.Data;
|
||||
import com.seibel.lod.core.a7.datatype.full.FullFormat;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
|
||||
import java.io.File;
|
||||
@@ -12,6 +12,6 @@ public interface IDataSourceProvider extends AutoCloseable {
|
||||
void addScannedFile(Collection<File> detectedFiles);
|
||||
|
||||
CompletableFuture<LodDataSource> read(DhSectionPos pos);
|
||||
void write(DhSectionPos sectionPos, Data chunkData);
|
||||
void write(DhSectionPos sectionPos, FullFormat chunkData);
|
||||
CompletableFuture<Void> flushAndSave();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.seibel.lod.core.a7.save.io.file;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.seibel.lod.core.a7.datatype.LodDataSource;
|
||||
import com.seibel.lod.core.a7.datatype.full.Data;
|
||||
import com.seibel.lod.core.a7.datatype.full.FullFormat;
|
||||
import com.seibel.lod.core.a7.level.IServerLevel;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
@@ -110,7 +110,7 @@ public class LocalDataFileHandler implements IDataSourceProvider {
|
||||
* This call is concurrent. I.e. it supports multiple threads calling this method at the same time.
|
||||
*/
|
||||
@Override
|
||||
public void write(DhSectionPos sectionPos, Data chunkData) {
|
||||
public void write(DhSectionPos sectionPos, FullFormat chunkData) {
|
||||
DataMetaFile metaFile = files.get(sectionPos);
|
||||
if (metaFile != null) { // Fast path: if there is a file for this section, just write to it.
|
||||
metaFile.addToWriteQueue(chunkData);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.seibel.lod.core.a7.save.io.file;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.LodDataSource;
|
||||
import com.seibel.lod.core.a7.datatype.full.Data;
|
||||
import com.seibel.lod.core.a7.datatype.full.FullFormat;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
|
||||
import java.io.File;
|
||||
@@ -20,7 +20,7 @@ public class RemoteDataFileHandler implements IDataSourceProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DhSectionPos sectionPos, Data chunkData) {
|
||||
public void write(DhSectionPos sectionPos, FullFormat chunkData) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.seibel.lod.core.a7.save.io.render;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.full.Data;
|
||||
import com.seibel.lod.core.a7.datatype.full.FullFormat;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
|
||||
import java.io.File;
|
||||
@@ -9,6 +9,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface IRenderSourceProvider extends AutoCloseable {
|
||||
void addScannedFile(Collection<File> detectedFiles);
|
||||
void write(DhSectionPos sectionPos, Data chunkData);
|
||||
void write(DhSectionPos sectionPos, FullFormat chunkData);
|
||||
CompletableFuture<Void> flushAndSave();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.seibel.lod.core.a7.save.io.render;
|
||||
|
||||
import com.seibel.lod.core.a7.datatype.RenderSourceLoader;
|
||||
import com.seibel.lod.core.a7.datatype.full.Data;
|
||||
import com.seibel.lod.core.a7.datatype.full.FullFormat;
|
||||
import com.seibel.lod.core.a7.save.io.file.IDataSourceProvider;
|
||||
import com.seibel.lod.core.a7.pos.DhSectionPos;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
@@ -36,7 +36,7 @@ public class RenderFileHandler implements IRenderSourceProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DhSectionPos sectionPos, Data chunkData) {
|
||||
public void write(DhSectionPos sectionPos, FullFormat chunkData) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user