Added versioning to savedata
This commit is contained in:
parent
b1503be63e
commit
69809df4c3
3 changed files with 41 additions and 17 deletions
|
@ -47,10 +47,38 @@ public class DDSaveHandler
|
|||
for (File dataFile : dataFiles)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
private static PackedDimData readDimension(File dataFile, DimDataProcessor reader)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -27,20 +27,6 @@ import StevenDimDoors.mod_pocketDim.util.Point4D;
|
|||
|
||||
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
|
||||
public PackedDimData readFromStream(InputStream inputStream)
|
||||
throws ConfigurationProcessingException
|
||||
|
@ -50,12 +36,11 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
|||
JsonReader reader = new JsonReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
PackedDimData data = this.createDImDataFromJson(reader);
|
||||
return data;
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
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.nextName();
|
||||
if(reader.nextLong()!=PackedDimData.SAVE_DATA_VERSION_ID)
|
||||
{
|
||||
throw new IOException("Save data version mismatch");
|
||||
}
|
||||
|
||||
reader.nextName();
|
||||
ID = reader.nextInt();
|
||||
|
||||
|
@ -246,7 +237,10 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
|||
|
||||
return new PackedLinkData(source, parent, tail, orientation, children);
|
||||
}
|
||||
|
||||
private PackedDungeonData createDungeonDataFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
private PackedLinkTail createLinkTailFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
Point4D destination=null;
|
||||
|
|
|
@ -7,6 +7,8 @@ import StevenDimDoors.mod_pocketDim.Point3D;
|
|||
public class PackedDimData
|
||||
{
|
||||
// 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 boolean IsDungeon;
|
||||
public final boolean IsFilled;
|
||||
|
|
Loading…
Reference in a new issue