diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index 11278ddac6..f5ff55e1e6 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -302,7 +302,7 @@ public class BlockIndexer{ returnBool = false; allBuildings(wx, wy, range, b -> { - if(pred.get(b)){ + if(pred.get(b) && !b.block.privileged){ returnBool = true; cons.get(b); } @@ -314,7 +314,7 @@ public class BlockIndexer{ var buildings = team.data().buildingTree; if(buildings == null) return false; buildings.intersect(wx - range, wy - range, range*2f, range*2f, b -> { - if(b.within(wx, wy, range + b.hitSize() / 2f) && pred.get(b)){ + if(b.within(wx, wy, range + b.hitSize() / 2f) && pred.get(b) && !b.block.privileged){ breturnArray.add(b); } }); @@ -340,7 +340,7 @@ public class BlockIndexer{ var buildings = team.data().buildingTree; if(buildings == null) return false; buildings.intersect(rect, b -> { - if(pred.get(b)){ + if(pred.get(b) && !b.block.privileged){ breturnArray.add(b); } }); diff --git a/core/src/mindustry/content/SerpuloTechTree.java b/core/src/mindustry/content/SerpuloTechTree.java index a596abd3ad..879ea6ad55 100644 --- a/core/src/mindustry/content/SerpuloTechTree.java +++ b/core/src/mindustry/content/SerpuloTechTree.java @@ -120,7 +120,7 @@ public class SerpuloTechTree{ }); }); - node(pyratiteMixer, () -> { + node(pyratiteMixer, Seq.with(new SectorComplete(crateredBattleground)), () -> { node(blastMixer, Seq.with(new SectorComplete(facility32m)), () -> { }); diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index fb299ba4d2..f7e2193588 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -49,6 +49,7 @@ public class Schematics implements Loadable{ private static final byte[] header = {'m', 's', 'c', 'h'}; private static final byte version = 1; + private static final boolean limitSchematicSize = true; private static final int padding = 2; private static final int maxPreviewsMobile = 32; @@ -553,7 +554,7 @@ public class Schematics implements Loadable{ try(DataInputStream stream = new DataInputStream(new InflaterInputStream(input))){ short width = stream.readShort(), height = stream.readShort(); - if(width > 128 || height > 128) throw new IOException("Invalid schematic: Too large (max possible size is 128x128)"); + if(limitSchematicSize && (width > 128 || height > 128)) throw new IOException("Invalid schematic: Too large (max possible size is 128x128)"); StringMap map = new StringMap(); int tags = stream.readUnsignedByte(); @@ -594,7 +595,7 @@ public class Schematics implements Loadable{ int total = stream.readInt(); - if(total > 128 * 128) throw new IOException("Invalid schematic: Too many blocks."); + if(limitSchematicSize && total > 128 * 128) throw new IOException("Invalid schematic: Too many blocks."); Reads read = new Reads(stream); diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 4c93e68b23..9486b8625c 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -2353,24 +2353,36 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ return validPlace(x, y, type, rotation, ignore, false); } + //static to avoid capture allocation + private static BuildPlan vpIgnore; + private static Block vpBlock; + private static int vpX, vpY; + + private static final Boolf vpPredicate = plan -> + plan != vpIgnore + && !plan.breaking + && !(vpBlock.canReplace(plan.block) && plan.x == vpX && plan.y == vpY); + public boolean validPlace(int x, int y, Block type, int rotation, @Nullable BuildPlan ignore, boolean ignoreUnits){ + if(!(ignoreUnits ? Build.validPlaceIgnoreUnits(type, player.team(), x, y, rotation, true, true) : Build.validPlace(type, player.team(), x, y, rotation))){ + return false; + } + if(player.isBuilder() && player.unit().plans.size > 0){ Tmp.r1.setCentered(x * tilesize + type.offset, y * tilesize + type.offset, type.size * tilesize); plansOut.clear(); playerPlanTree.intersect(Tmp.r1, plansOut); - for(int i = 0; i < plansOut.size; i++){ - var plan = plansOut.items[i]; - if(plan != ignore - && !plan.breaking - && plan.block.bounds(plan.x, plan.y, Tmp.r1).overlaps(type.bounds(x, y, Tmp.r2)) - && !(type.canReplace(plan.block) && Tmp.r1.equals(Tmp.r2))){ - return false; - } - } + float s = type.size * tilesize; + vpIgnore = ignore; + vpBlock = type; + vpX = x; + vpY = y; + + return playerPlanTree.find(x * tilesize + type.offset - s / 2f, y * tilesize + type.offset - s / 2f, s, s, vpPredicate) == null; } - return ignoreUnits ? Build.validPlaceIgnoreUnits(type, player.team(), x, y, rotation, true, true) : Build.validPlace(type, player.team(), x, y, rotation); + return true; } public boolean validBreak(int x, int y){ diff --git a/core/src/mindustry/net/ArcNetProvider.java b/core/src/mindustry/net/ArcNetProvider.java index 3110558167..d695ba9fa4 100644 --- a/core/src/mindustry/net/ArcNetProvider.java +++ b/core/src/mindustry/net/ArcNetProvider.java @@ -435,6 +435,7 @@ public class ArcNetProvider implements NetProvider{ }else{ //read length int, followed by compressed lz4 data Packet packet = Net.newPacket(id); + if(!packet.allow(net.server())) throw new RuntimeException("Invalid packet type for endpoint: " + packet.getClass()); var buffer = decompressBuffer.get(); int length = byteBuffer.getShort() & 0xffff; byte compression = byteBuffer.get(); diff --git a/core/src/mindustry/net/Packets.java b/core/src/mindustry/net/Packets.java index e766e59434..af4bc95b12 100644 --- a/core/src/mindustry/net/Packets.java +++ b/core/src/mindustry/net/Packets.java @@ -77,6 +77,11 @@ public class Packets{ public int total; public byte type; + @Override + public boolean allow(boolean server){ + return !server; + } + @Override public void write(Writes buffer){ buffer.i(id); @@ -96,6 +101,11 @@ public class Packets{ public int id; public byte[] data; + @Override + public boolean allow(boolean server){ + return !server; + } + @Override public void write(Writes buffer){ buffer.i(id); diff --git a/core/src/mindustry/net/Streamable.java b/core/src/mindustry/net/Streamable.java index c150fc26f3..f1a1c8e7e7 100644 --- a/core/src/mindustry/net/Streamable.java +++ b/core/src/mindustry/net/Streamable.java @@ -12,6 +12,11 @@ public class Streamable extends Packet{ return priorityHigh; } + @Override + public boolean allow(boolean server){ + return !server; + } + public static class StreamBuilder{ public final int id; public final byte type;