Revert JSON rules change
This commit is contained in:
@@ -2,7 +2,6 @@ package mindustry.io;
|
|||||||
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.struct.*;
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.serialization.*;
|
import arc.util.serialization.*;
|
||||||
import arc.util.serialization.Json.*;
|
import arc.util.serialization.Json.*;
|
||||||
@@ -79,30 +78,6 @@ public class JsonIO{
|
|||||||
json.setElementType(Rules.class, "spawns", SpawnGroup.class);
|
json.setElementType(Rules.class, "spawns", SpawnGroup.class);
|
||||||
json.setElementType(Rules.class, "loadout", ItemStack.class);
|
json.setElementType(Rules.class, "loadout", ItemStack.class);
|
||||||
|
|
||||||
json.setSerializer(Rules.class, new Serializer<>(){
|
|
||||||
@Override
|
|
||||||
public void write(Json json, Rules object, Class knownType){
|
|
||||||
json.writeObjectStart();
|
|
||||||
json.writeFields(object);
|
|
||||||
json.writeValue("envMapping", Env.idToName, IntMap.class);
|
|
||||||
json.writeObjectEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Rules read(Json json, JsonValue jsonData, Class type){
|
|
||||||
Rules out = baseObject instanceof Rules rules ? rules : new Rules();
|
|
||||||
json.readFields(out, jsonData);
|
|
||||||
|
|
||||||
// Older Rules data doesn't have env mapping.
|
|
||||||
if(jsonData.has("envMapping")){
|
|
||||||
IntMap<String> idToName = json.readValue(IntMap.class, jsonData.get("envMapping"));
|
|
||||||
out.env = Env.remap(out.env, idToName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
json.setSerializer(Color.class, new Serializer<>(){
|
json.setSerializer(Color.class, new Serializer<>(){
|
||||||
@Override
|
@Override
|
||||||
public void write(Json json, Color object, Class knownType){
|
public void write(Json json, Color object, Class knownType){
|
||||||
@@ -345,6 +320,8 @@ public class JsonIO{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//use short names for all filter types
|
//use short names for all filter types
|
||||||
for(var filter : Maps.allFilterTypes){
|
for(var filter : Maps.allFilterTypes){
|
||||||
var i = filter.get();
|
var i = filter.get();
|
||||||
@@ -352,9 +329,8 @@ public class JsonIO{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object baseObject;
|
|
||||||
|
|
||||||
static class CustomJson extends Json{
|
static class CustomJson extends Json{
|
||||||
|
private Object baseObject;
|
||||||
|
|
||||||
{ apply(this); }
|
{ apply(this); }
|
||||||
|
|
||||||
@@ -364,7 +340,7 @@ public class JsonIO{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> T fromBaseJson(Class<T> type, T base, String json){
|
public <T> T fromBaseJson(Class<T> type, T base, String json){
|
||||||
baseObject = base;
|
this.baseObject = base;
|
||||||
return readValue(type, null, new JsonReader().parse(json));
|
return readValue(type, null, new JsonReader().parse(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,9 +261,7 @@ public class ArcNetProvider implements NetProvider{
|
|||||||
}
|
}
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(packet.getData());
|
ByteBuffer buffer = ByteBuffer.wrap(packet.getData());
|
||||||
Host host = NetworkIO.readServerData((int)Time.timeSinceMillis(time), packet.getAddress().getHostAddress(), buffer);
|
Host host = NetworkIO.readServerData((int)Time.timeSinceMillis(time), packet.getAddress().getHostAddress(), buffer);
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> callback.get(host));
|
||||||
callback.get(host);
|
|
||||||
});
|
|
||||||
foundAddresses.add(packet.getAddress());
|
foundAddresses.add(packet.getAddress());
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
//don't crash when there's an error pinging a server or parsing data
|
//don't crash when there's an error pinging a server or parsing data
|
||||||
|
|||||||
Reference in New Issue
Block a user