Marker instruction rework
This commit is contained in:
@@ -44,6 +44,15 @@ public class JsonIO{
|
||||
}
|
||||
};
|
||||
|
||||
public static void writeBytes(Object value, Class<?> elementType, DataOutputStream output){
|
||||
json.setWriter(new UBJsonWriter(output));
|
||||
json.writeValue(value, value == null ? null : value.getClass(), elementType);
|
||||
}
|
||||
|
||||
public static <T> T readBytes(Class<T> type, Class<?> elementType, DataInputStream input) throws IOException{
|
||||
return json.readValue(type, elementType, new UBJsonReader().parseWihoutClosing(input));
|
||||
}
|
||||
|
||||
public static String write(Object object){
|
||||
return json.toJson(object, object.getClass());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SaveIO{
|
||||
/** Save format header. */
|
||||
public static final byte[] header = {'M', 'S', 'A', 'V'};
|
||||
public static final IntMap<SaveVersion> versions = new IntMap<>();
|
||||
public static final Seq<SaveVersion> versionArray = Seq.with(new Save1(), new Save2(), new Save3(), new Save4(), new Save5(), new Save6(), new Save7());
|
||||
public static final Seq<SaveVersion> versionArray = Seq.with(new Save1(), new Save2(), new Save3(), new Save4(), new Save5(), new Save6(), new Save7(), new Save8());
|
||||
|
||||
static{
|
||||
for(SaveVersion version : versionArray){
|
||||
|
||||
@@ -6,12 +6,14 @@ import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.content.TechTree.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.MapObjectives.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.maps.Map;
|
||||
@@ -74,6 +76,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
try{
|
||||
region("map", stream, counter, in -> readMap(in, context));
|
||||
region("entities", stream, counter, this::readEntities);
|
||||
if(version >= 8) region("markers", stream, counter, this::readMarkers);
|
||||
region("custom", stream, counter, this::readCustomChunks);
|
||||
}finally{
|
||||
content.setTemporaryMapper(null);
|
||||
@@ -85,6 +88,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
region("content", stream, this::writeContentHeader);
|
||||
region("map", stream, this::writeMap);
|
||||
region("entities", stream, this::writeEntities);
|
||||
region("markers", stream, this::writeMarkers);
|
||||
region("custom", stream, s -> writeCustomChunks(s, false));
|
||||
}
|
||||
|
||||
@@ -395,6 +399,14 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
writeWorldEntities(stream);
|
||||
}
|
||||
|
||||
public void writeMarkers(DataOutput stream) throws IOException{
|
||||
JsonIO.writeBytes(Vars.state.markers, ObjectiveMarker.class, (DataOutputStream)stream);
|
||||
}
|
||||
|
||||
public void readMarkers(DataInput stream) throws IOException{
|
||||
Vars.state.markers = JsonIO.readBytes(IntMap.class, ObjectiveMarker.class, (DataInputStream)stream);
|
||||
}
|
||||
|
||||
public void readTeamBlocks(DataInput stream) throws IOException{
|
||||
int teamc = stream.readInt();
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import arc.util.serialization.*;
|
||||
import mindustry.ai.*;
|
||||
import mindustry.ai.types.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
@@ -631,6 +630,14 @@ public class TypeIO{
|
||||
return KickReason.values()[read.b()];
|
||||
}
|
||||
|
||||
public static void writeMarkerControl(Writes write, LMarkerControl reason){
|
||||
write.b((byte)reason.ordinal());
|
||||
}
|
||||
|
||||
public static LMarkerControl readMarkerControl(Reads read){
|
||||
return LMarkerControl.all[read.ub()];
|
||||
}
|
||||
|
||||
public static void writeRules(Writes write, Rules rules){
|
||||
String string = JsonIO.write(rules);
|
||||
byte[] bytes = string.getBytes(charset);
|
||||
|
||||
10
core/src/mindustry/io/versions/Save8.java
Normal file
10
core/src/mindustry/io/versions/Save8.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package mindustry.io.versions;
|
||||
|
||||
import mindustry.io.*;
|
||||
|
||||
public class Save8 extends SaveVersion{
|
||||
|
||||
public Save8(){
|
||||
super(8);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user