Data patch save format changes

This commit is contained in:
Anuken
2026-05-27 14:50:59 -04:00
parent 3d970138ca
commit a620647376
2 changed files with 9 additions and 3 deletions

View File

@@ -520,7 +520,8 @@ public abstract class SaveVersion extends SaveFileReader{
} }
public void skipDataPatches(DataInput stream) throws IOException{ public void skipDataPatches(DataInput stream) throws IOException{
int amount = stream.readShort(); stream.readInt(); //version - ignored for now
int amount = stream.readInt();
for(int i = 0; i < amount; i++){ for(int i = 0; i < amount; i++){
int len = stream.readInt(); int len = stream.readInt();
stream.skipBytes(len); stream.skipBytes(len);
@@ -536,9 +537,11 @@ public abstract class SaveVersion extends SaveFileReader{
} }
public void readDataPatches(DataInput stream) throws IOException{ public void readDataPatches(DataInput stream) throws IOException{
stream.readInt(); //version - ignored for now
Seq<String> patches = new Seq<>(); Seq<String> patches = new Seq<>();
int patchAmount = stream.readShort(); int patchAmount = stream.readInt();
for(int i = 0; i < patchAmount; i++){ for(int i = 0; i < patchAmount; i++){
int len = stream.readInt(); int len = stream.readInt();
byte[] bytes = new byte[len]; byte[] bytes = new byte[len];
@@ -572,8 +575,10 @@ public abstract class SaveVersion extends SaveFileReader{
} }
public void writeDataPatches(DataOutput stream) throws IOException{ public void writeDataPatches(DataOutput stream) throws IOException{
stream.writeInt(DataPatcher.patchFormatVersion);
var patches = state.patcher.patches; var patches = state.patcher.patches;
stream.writeShort(patches.size); stream.writeInt(patches.size);
for(var patchset : patches){ for(var patchset : patches){
byte[] bytes = patchset.patch.getBytes(Strings.utf8); byte[] bytes = patchset.patch.getBytes(Strings.utf8);
stream.writeInt(bytes.length); stream.writeInt(bytes.length);

View File

@@ -28,6 +28,7 @@ import java.util.*;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class DataPatcher{ public class DataPatcher{
public static final int maxImageSize = 1024; public static final int maxImageSize = 1024;
public static final int patchFormatVersion = 1;
private static final Object root = new Object(); private static final Object root = new Object();
private static final ObjectMap<String, ContentType> nameToType = new ObjectMap<>(); private static final ObjectMap<String, ContentType> nameToType = new ObjectMap<>();