diff --git a/core/src/mindustry/world/blocks/logic/LogicBlock.java b/core/src/mindustry/world/blocks/logic/LogicBlock.java index d8e9387fac..8635fb6baf 100644 --- a/core/src/mindustry/world/blocks/logic/LogicBlock.java +++ b/core/src/mindustry/world/blocks/logic/LogicBlock.java @@ -128,7 +128,7 @@ public class LogicBlock extends Block{ public static String getLinkName(Block block){ String name = block.name; - if(name.contains("-")){ + if(name.indexOf('-') != -1){ String[] split = name.split("-"); //filter out 'large' at the end of block names if(split.length >= 2 && (split[split.length - 1].equals("large") || Strings.canParseFloat(split[split.length - 1]))){ @@ -259,7 +259,7 @@ public class LogicBlock extends Block{ public Seq links = new Seq<>(); public @Nullable ObjectIntMap linkMap; public boolean checkedDuplicates = false; - + public int ipt = instructionsPerTick; /** Display name, for convenience. This is currently only available for world processors. */ public @Nullable String tag; @@ -521,7 +521,9 @@ public class LogicBlock extends Block{ if(valid){ - if(lastBlock != null && cur.block != lastBlock){ + if((lastBlock != null && cur.block != lastBlock) || + //links don't store the type of block they used to be in saves, so when a link becomes valid, the only way to make sure the name is correct is an expensive string startsWith check + (lastBlock == null && !l.name.startsWith(getLinkName(cur.block)))){ l.logicVar = null; //name was reassigned because block type changed, the old cached logic var is no longer relevant l.name = ""; l.name = findLinkName(cur.block); @@ -548,7 +550,7 @@ public class LogicBlock extends Block{ if(changed){ updateLinks(); } - + if(state.rules.disableWorldProcessors && privileged) return; if(enabled && executor.initialized()){ diff --git a/tools/src/mindustry/tools/SchemaGenerator.java b/tools/src/mindustry/tools/SchemaGenerator.java index 8d0f8221a7..1d08f2cb93 100644 --- a/tools/src/mindustry/tools/SchemaGenerator.java +++ b/tools/src/mindustry/tools/SchemaGenerator.java @@ -1,5 +1,6 @@ package mindustry.tools; +import arc.audio.*; import arc.files.*; import arc.func.*; import arc.math.*; @@ -10,12 +11,15 @@ import arc.util.serialization.Jval.*; import com.github.javaparser.*; import com.github.javaparser.ast.body.*; import mindustry.*; +import mindustry.content.*; import mindustry.ctype.*; import mindustry.entities.*; import mindustry.entities.units.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.type.*; import mindustry.world.*; +import mindustry.world.meta.*; import java.lang.reflect.*; @@ -41,9 +45,7 @@ public class SchemaGenerator{ if(type.contentClass != null && all.size > 0 && all.first() instanceof UnlockableContent){ mappings.put(type.name(), type.contentClass.getCanonicalName()); var values = Jval.newObject(); - all.as().each(c -> { - values.put(c.name, Jval.valueOf((c.getClass().isAnonymousClass() ? c.getClass().getSuperclass() : c.getClass()).getCanonicalName())); - }); + all.as().each(c -> values.put(c.name, Jval.valueOf((c.getClass().isAnonymousClass() ? c.getClass().getSuperclass() : c.getClass()).getCanonicalName()))); root.asObject().put(type.name(), values); } } @@ -150,12 +152,40 @@ public class SchemaGenerator{ writeSchema(Interp.class.getCanonicalName(), """ { - "doc": "Various types of interpolation.", + "doc": "All types of interpolation.", "superclass": "Enum", "values": [%VALUES%] } """.replace("%VALUES%", Seq.with(Interp.class.getFields()).toString(", ", t -> "\"" + t.getName() + "\""))); + writeSchema("allTeams", """ + { + "doc": "All team names.", + "values": [%VALUES%] + } + """.replace("%VALUES%", Seq.with(Team.class.getFields()).select(f -> f.getType() == Team.class).toString(", ", t -> "\"" + t.getName() + "\""))); + + writeSchema("allEffects", """ + { + "doc": "All preset effect names.", + "values": [%VALUES%] + } + """.replace("%VALUES%", Seq.with(Fx.class.getFields()).select(f -> f.getType() == Effect.class).toString(", ", t -> "\"" + t.getName() + "\""))); + + writeSchema("allAttributes", """ + { + "doc": "All attribute names.", + "values": [%VALUES%] + } + """.replace("%VALUES%", Seq.with(Attribute.class.getFields()).select(f -> f.getType() == Attribute.class).toString(", ", t -> "\"" + t.getName() + "\""))); + + writeSchema("allSounds", """ + { + "doc": "All preset sound names.", + "values": [%VALUES%] + } + """.replace("%VALUES%", Seq.with(Sounds.class.getFields()).select(f -> f.getType() == Sound.class).toString(", ", t -> "\"" + t.getName() + "\""))); + new Fi("../../tools/extra-schemas").copyFilesTo(outputDir); }