Compare commits

...

3 Commits
v141 ... v141.1

Author SHA1 Message Date
Anuken
e92d5d2d2d Fixed #8165 2023-01-12 14:42:42 -05:00
Anuken
411367f294 Revert JSON rules change 2023-01-12 14:38:11 -05:00
Anuken
f49e05a915 Fixed #8161 / Fixed #8162 2023-01-12 14:30:57 -05:00
5 changed files with 13 additions and 33 deletions

View File

@@ -629,7 +629,7 @@ public class EntityProcess extends BaseProcessor{
groupsBuilder.addField(ParameterizedTypeName.get( groupsBuilder.addField(ParameterizedTypeName.get(
ClassName.bestGuess("mindustry.entities.EntityGroup"), itype), group.name, Modifier.PUBLIC, Modifier.STATIC); ClassName.bestGuess("mindustry.entities.EntityGroup"), itype), group.name, Modifier.PUBLIC, Modifier.STATIC);
groupInit.addStatement("$L = new $T<>($L.class, $L, $L, (e, pos) -> (($L.IndexableEntity__$L)e).setIndex__$L(pos))", group.name, groupc, itype, group.spatial, group.mapping, packageName, group.name, group.name); groupInit.addStatement("$L = new $T<>($L.class, $L, $L, (e, pos) -> { if(e instanceof $L.IndexableEntity__$L ix) ix.setIndex__$L(pos); })", group.name, groupc, itype, group.spatial, group.mapping, packageName, group.name, group.name);
} }
//write the groups //write the groups

View File

@@ -69,7 +69,7 @@ public class Puddles{
if(tile.floor().solid) return; if(tile.floor().solid) return;
Puddle p = map.get(tile.pos()); Puddle p = map.get(tile.pos());
if(p == null){ if(p == null || p.liquid == null){
Puddle puddle = Puddle.create(); Puddle puddle = Puddle.create();
puddle.tile = tile; puddle.tile = tile;
puddle.liquid = liquid; puddle.liquid = liquid;
@@ -107,6 +107,8 @@ public class Puddles{
/** Reacts two liquids together at a location. */ /** Reacts two liquids together at a location. */
private static float reactPuddle(Liquid dest, Liquid liquid, float amount, Tile tile, float x, float y){ private static float reactPuddle(Liquid dest, Liquid liquid, float amount, Tile tile, float x, float y){
if(dest == null) return 0f;
if((dest.flammability > 0.3f && liquid.temperature > 0.7f) || if((dest.flammability > 0.3f && liquid.temperature > 0.7f) ||
(liquid.flammability > 0.3f && dest.temperature > 0.7f)){ //flammable liquid + hot liquid (liquid.flammability > 0.3f && dest.temperature > 0.7f)){ //flammable liquid + hot liquid
Fires.create(tile); Fires.create(tile);

View File

@@ -142,6 +142,8 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc, Syncc{
@Override @Override
public void afterSync(){ public void afterSync(){
if(liquid != null){
Puddles.register(self()); Puddles.register(self());
} }
}
} }

View File

@@ -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));
} }

View File

@@ -261,7 +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);
callback.get(host); Core.app.post(() -> 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