mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-02 11:10:50 +03:00
Misc bugfixes and plan optimizations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -120,7 +120,7 @@ public class SerpuloTechTree{
|
||||
});
|
||||
});
|
||||
|
||||
node(pyratiteMixer, () -> {
|
||||
node(pyratiteMixer, Seq.with(new SectorComplete(crateredBattleground)), () -> {
|
||||
node(blastMixer, Seq.with(new SectorComplete(facility32m)), () -> {
|
||||
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<BuildPlan> 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){
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user