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