Added versioning to savedata
This commit is contained in:
@@ -47,10 +47,38 @@ public class DDSaveHandler
|
|||||||
for (File dataFile : dataFiles)
|
for (File dataFile : dataFiles)
|
||||||
{
|
{
|
||||||
PackedDimData packedDim = readDimension(dataFile, reader);
|
PackedDimData packedDim = readDimension(dataFile, reader);
|
||||||
|
//packedDims.add(packedDim);
|
||||||
|
}
|
||||||
|
return unpackDimData(packedDims);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a list of packedDimData and rebuilds the DimData for it, as well as registering all of
|
||||||
|
* them and their links.
|
||||||
|
* @param packedDims
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static boolean unpackDimData(List<PackedDimData> packedDims)
|
||||||
|
{
|
||||||
|
List<PackedDimData> unpackedDims = new ArrayList<PackedDimData>();
|
||||||
|
|
||||||
|
while(!packedDims.isEmpty())
|
||||||
|
{
|
||||||
|
//Load roots
|
||||||
|
for(PackedDimData packedDim : packedDims)
|
||||||
|
{
|
||||||
|
if(packedDim.ParentID==packedDim.ID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
packedDims.removeAll(unpackedDims);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static PackedDimData readDimension(File dataFile, DimDataProcessor reader)
|
private static PackedDimData readDimension(File dataFile, DimDataProcessor reader)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -27,20 +27,6 @@ import StevenDimDoors.mod_pocketDim.util.Point4D;
|
|||||||
|
|
||||||
public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
||||||
{
|
{
|
||||||
private static final String dimID = "DIM_ID";
|
|
||||||
private static final String depth = "DEPTH";
|
|
||||||
private static final String children = "CHILDREN_DIM_IDS";
|
|
||||||
private static final String linkTails = "LINK_TAILS";
|
|
||||||
private static final String filled = "IS_FILLED";
|
|
||||||
private static final String isDungeon = "IS_DUNGEON";
|
|
||||||
private static final String orientation = "ORIENTATION";
|
|
||||||
private static final String parentID = "PARENT_DIM_ID";
|
|
||||||
private static final String rootID = "ROOT_DIM_ID";
|
|
||||||
private static final String packDepth = "PACK_DEPTH";
|
|
||||||
private static final String links = "LINKS";
|
|
||||||
private static final String origin = "ORIGIN_POINT";
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PackedDimData readFromStream(InputStream inputStream)
|
public PackedDimData readFromStream(InputStream inputStream)
|
||||||
throws ConfigurationProcessingException
|
throws ConfigurationProcessingException
|
||||||
@@ -50,12 +36,11 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
|||||||
JsonReader reader = new JsonReader(new InputStreamReader(inputStream, "UTF-8"));
|
JsonReader reader = new JsonReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||||
PackedDimData data = this.createDImDataFromJson(reader);
|
PackedDimData data = this.createDImDataFromJson(reader);
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ConfigurationProcessingException();
|
throw new ConfigurationProcessingException("Could not read packedDimData");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -109,6 +94,12 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
|||||||
|
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
|
|
||||||
|
reader.nextName();
|
||||||
|
if(reader.nextLong()!=PackedDimData.SAVE_DATA_VERSION_ID)
|
||||||
|
{
|
||||||
|
throw new IOException("Save data version mismatch");
|
||||||
|
}
|
||||||
|
|
||||||
reader.nextName();
|
reader.nextName();
|
||||||
ID = reader.nextInt();
|
ID = reader.nextInt();
|
||||||
|
|
||||||
@@ -246,7 +237,10 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
|||||||
|
|
||||||
return new PackedLinkData(source, parent, tail, orientation, children);
|
return new PackedLinkData(source, parent, tail, orientation, children);
|
||||||
}
|
}
|
||||||
|
private PackedDungeonData createDungeonDataFromJson(JsonReader reader) throws IOException
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
private PackedLinkTail createLinkTailFromJson(JsonReader reader) throws IOException
|
private PackedLinkTail createLinkTailFromJson(JsonReader reader) throws IOException
|
||||||
{
|
{
|
||||||
Point4D destination=null;
|
Point4D destination=null;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import StevenDimDoors.mod_pocketDim.Point3D;
|
|||||||
public class PackedDimData
|
public class PackedDimData
|
||||||
{
|
{
|
||||||
// These fields will be public since this is a simple data container
|
// These fields will be public since this is a simple data container
|
||||||
|
public final static long SAVE_DATA_VERSION_ID = 982405775L;
|
||||||
|
public final long SAVE_DATA_VERSION_ID_INSTANCE = SAVE_DATA_VERSION_ID;
|
||||||
public final int ID;
|
public final int ID;
|
||||||
public final boolean IsDungeon;
|
public final boolean IsDungeon;
|
||||||
public final boolean IsFilled;
|
public final boolean IsFilled;
|
||||||
|
|||||||
Reference in New Issue
Block a user