Fixed StackOverFlow exception thrown with certain block designs

This commit is contained in:
Anuken
2018-02-18 11:31:09 -05:00
parent dbd84103cb
commit 1c3bad0aca
8 changed files with 17 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Sat Feb 17 20:42:58 EST 2018 #Sun Feb 18 11:29:39 EST 2018
version=beta version=beta
androidBuildCode=235 androidBuildCode=235
name=Mindustry name=Mindustry

View File

@@ -30,7 +30,7 @@ public class Packets {
} }
public static class SyncPacket implements Packet{ public static class SyncPacket implements Packet, UnimportantPacket{
public byte[] data; public byte[] data;
@Override @Override
@@ -99,7 +99,7 @@ public class Packets {
} }
} }
public static class StateSyncPacket implements Packet{ public static class StateSyncPacket implements Packet, UnimportantPacket{
public int[] items; public int[] items;
public float countdown, time; public float countdown, time;
public int enemies, wave; public int enemies, wave;

View File

@@ -90,6 +90,8 @@ public class Block{
public Array<BlockBar> bars = Array.with(new BlockBar(Color.RED, false, tile -> tile.entity.health / (float)tile.block().health)); public Array<BlockBar> bars = Array.with(new BlockBar(Color.RED, false, tile -> tile.entity.health / (float)tile.block().health));
/**whether this block can be replaced in all cases*/ /**whether this block can be replaced in all cases*/
public boolean alwaysReplace = false; public boolean alwaysReplace = false;
/**whether this block has instant transfer checking. used for calculations to prevent infinite loops.*/
public boolean instantTransfer = false;
public Block(String name) { public Block(String name) {
this.name = name; this.name = name;

View File

@@ -16,6 +16,7 @@ public class Junction extends Block{
super(name); super(name);
update = true; update = true;
solid = true; solid = true;
instantTransfer = true;
} }
@Override @Override

View File

@@ -24,6 +24,7 @@ public class Sorter extends Block{
super(name); super(name);
update = true; update = true;
solid = true; solid = true;
instantTransfer = true;
} }
@Override @Override
@@ -70,13 +71,17 @@ public class Sorter extends Block{
}else{ }else{
Tile a = dest.getNearby(Mathf.mod(dir - 1, 4)); Tile a = dest.getNearby(Mathf.mod(dir - 1, 4));
Tile b = dest.getNearby(Mathf.mod(dir + 1, 4)); Tile b = dest.getNearby(Mathf.mod(dir + 1, 4));
boolean ac = a.block().acceptItem(item, a, dest); boolean ac = !(a.block().instantTransfer && source.block().instantTransfer) &&
boolean bc = b.block().acceptItem(item, b, dest); a.block().acceptItem(item, a, dest);
boolean bc = !(b.block().instantTransfer && source.block().instantTransfer) &&
b.block().acceptItem(item, b, dest);
if(ac && !bc){ if(ac && !bc){
to = a; to = a;
}else if(bc && !ac){ }else if(bc && !ac){
to = b; to = b;
}else if(!bc && !ac){
return null;
}else{ }else{
if(dest.getDump() == 0){ if(dest.getDump() == 0){
to = a; to = a;

View File

@@ -9,6 +9,8 @@ public class Splitter extends Block{
public Splitter(String name){ public Splitter(String name){
super(name); super(name);
solid = true;
instantTransfer = true;
} }
@Override @Override

View File

@@ -19,6 +19,7 @@ public class TunnelConveyor extends Block{
update = true; update = true;
solid = true; solid = true;
health = 70; health = 70;
instantTransfer = true;
} }
@Override @Override

View File

@@ -54,7 +54,7 @@ public class KryoServer implements ServerProvider {
int lastconnection = 0; int lastconnection = 0;
public KryoServer(){ public KryoServer(){
server = new Server(4096*2, 2048, connection -> new ByteSerializer()); //TODO tweak server = new Server(4096*2, 2048, connection -> new ByteSerializer());
server.setDiscoveryHandler((datagramChannel, fromAddress) -> { server.setDiscoveryHandler((datagramChannel, fromAddress) -> {
ByteBuffer buffer = KryoRegistrator.writeServerData(); ByteBuffer buffer = KryoRegistrator.writeServerData();
buffer.position(0); buffer.position(0);