implemented multi level saving and loading. they use new long[] system instead of long[][][]
This commit is contained in:
@@ -6,18 +6,21 @@ import com.seibel.lod.util.LodUtil;
|
||||
import com.seibel.lod.util.ThreadMapUtil;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class VerticalLevelContainer implements LevelContainer
|
||||
{
|
||||
|
||||
public final byte detailLevel;
|
||||
public final int size;
|
||||
public final int maxVerticalData;
|
||||
|
||||
public final long[][][] dataContainer;
|
||||
|
||||
public VerticalLevelContainer(byte detailLevel)
|
||||
{
|
||||
this.detailLevel = detailLevel;
|
||||
int size = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
size = 1 << (LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
dataContainer = new long[size][size][1];
|
||||
}
|
||||
|
||||
@@ -61,30 +64,37 @@ public class VerticalLevelContainer implements LevelContainer
|
||||
return DataPointUtil.doesItExist(data[0]);
|
||||
}
|
||||
|
||||
public VerticalLevelContainer(String inputString)
|
||||
public VerticalLevelContainer(byte inputData[])
|
||||
{
|
||||
|
||||
throw new InvalidParameterException("loading not yet implemented");
|
||||
|
||||
/*
|
||||
int tempIndex;
|
||||
int index = 0;
|
||||
int lastIndex = 0;
|
||||
|
||||
|
||||
index = inputString.indexOf(DATA_DELIMITER, 0);
|
||||
this.detailLevel = (byte) Integer.parseInt(inputString.substring(0, index));
|
||||
int size = (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
|
||||
this.dataContainer = new long[size][size][1];
|
||||
for (int x = 0; x < size; x++)
|
||||
long newData;
|
||||
detailLevel = inputData[index];
|
||||
index++;
|
||||
maxVerticalData = inputData[index];
|
||||
index++;
|
||||
size = (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel);
|
||||
this.dataContainer = new long[size * size * maxVerticalData];
|
||||
int x, y, z = 0;
|
||||
for (x = 0; x < size; x++)
|
||||
{
|
||||
for (int z = 0; z < size; z++)
|
||||
for (z = 0; z < size; z++)
|
||||
{
|
||||
lastIndex = index;
|
||||
index = inputString.indexOf(DATA_DELIMITER, lastIndex + 1);
|
||||
dataContainer[x][z][0] = Long.parseLong(inputString.substring(lastIndex + 1, index), 16);
|
||||
for (y = 0; y < maxVerticalData; y++) {
|
||||
newData = 0;
|
||||
if (inputData[index] == 0)
|
||||
index++;
|
||||
else if (index + 7 >= inputData.length)
|
||||
break;
|
||||
else {
|
||||
for (tempIndex = 0; tempIndex < 8; tempIndex++)
|
||||
newData += (((long) inputData[index + tempIndex]) & 0xff) << (8 * tempIndex);
|
||||
index = index + 8;
|
||||
}
|
||||
dataContainer[(x * size + z) * maxVerticalData + y] = newData;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public LevelContainer expand(){
|
||||
@@ -116,8 +126,37 @@ public class VerticalLevelContainer implements LevelContainer
|
||||
|
||||
public byte[] toDataString()
|
||||
{
|
||||
byte[] temp = {};
|
||||
return temp;
|
||||
int index = 0;
|
||||
int tempIndex;
|
||||
byte[] tempData = new byte[2 + (size * size * maxVerticalData * 8)];
|
||||
tempData[index] = detailLevel;
|
||||
index++;
|
||||
tempData[index] = maxVerticalData;
|
||||
index++;
|
||||
int x, y, z = 0;
|
||||
for (x = 0; x < size; x++)
|
||||
{
|
||||
for (z = 0; z < size; z++)
|
||||
{
|
||||
for (y = 0; y < maxVerticalData; y++)
|
||||
{
|
||||
if (dataContainer[(x * size + z) * maxVerticalData + y] == 0)
|
||||
{
|
||||
tempData[index] = 0;
|
||||
index++;
|
||||
} else if (dataContainer[(x * size + z) * maxVerticalData + y] == 3)
|
||||
{
|
||||
tempData[index] = 3;
|
||||
index++;
|
||||
} else {
|
||||
for (tempIndex = 0; tempIndex < 8; tempIndex++)
|
||||
tempData[index + tempIndex] = (byte) (dataContainer[(x * size + z) * maxVerticalData + y] >>> (8 * tempIndex));
|
||||
index += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Arrays.copyOfRange(tempData, 0, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user