diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index da801cc454..6a0f2f6bdc 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -182,7 +182,7 @@ public class NetServer implements ApplicationListener{ return; } - if(Groups.player.contains(player -> player.uuid().equals(packet.uuid) || player.usid().equals(packet.usid))){ + if(Groups.player.contains(player -> player.uuid().equals(packet.uuid) || player.usid().equals(packet.usid) || player.ip().equals(con.address))){ con.kick(KickReason.idInUse); return; } diff --git a/core/src/mindustry/entities/comp/PlayerComp.java b/core/src/mindustry/entities/comp/PlayerComp.java index aababe65e3..914c074d4d 100644 --- a/core/src/mindustry/entities/comp/PlayerComp.java +++ b/core/src/mindustry/entities/comp/PlayerComp.java @@ -197,6 +197,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra return unit.isNull() || !unit.isValid(); } + String ip(){ + return con == null ? "localhost" : con.address; + } + String uuid(){ return con == null ? "[LOCAL]" : con.uuid; } diff --git a/core/src/mindustry/ui/dialogs/MapsDialog.java b/core/src/mindustry/ui/dialogs/MapsDialog.java index 605a0bec1c..e0783b7965 100644 --- a/core/src/mindustry/ui/dialogs/MapsDialog.java +++ b/core/src/mindustry/ui/dialogs/MapsDialog.java @@ -72,7 +72,6 @@ public class MapsDialog extends BaseDialog{ Map map = MapIO.createMap(file, true); - //when you attempt to import a save, it will have no name, so generate one String name = map.tags.get("name", () -> { String result = "unknown"; diff --git a/core/src/mindustry/world/blocks/distribution/Conveyor.java b/core/src/mindustry/world/blocks/distribution/Conveyor.java index 4e59952084..9db976e8a5 100644 --- a/core/src/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/mindustry/world/blocks/distribution/Conveyor.java @@ -145,6 +145,12 @@ public class Conveyor extends Block implements Autotiler{ } } + @Override + public void drawCracks(){ + Draw.z(Layer.block - 0.15f); + super.drawCracks(); + } + @Override public void overwrote(Seq builds){ if(builds.first() instanceof ConveyorBuild build){ diff --git a/core/src/mindustry/world/blocks/distribution/OverflowGate.java b/core/src/mindustry/world/blocks/distribution/OverflowGate.java index 1b38cff775..0422c8f583 100644 --- a/core/src/mindustry/world/blocks/distribution/OverflowGate.java +++ b/core/src/mindustry/world/blocks/distribution/OverflowGate.java @@ -8,8 +8,6 @@ import mindustry.type.*; import mindustry.world.*; import mindustry.world.meta.*; -import static mindustry.Vars.*; - public class OverflowGate extends Block{ public float speed = 1f; public boolean invert = false; @@ -23,7 +21,7 @@ public class OverflowGate extends Block{ instantTransfer = true; unloadable = false; canOverdrive = false; - itemCapacity = 1; + itemCapacity = 0; } @Override @@ -32,73 +30,35 @@ public class OverflowGate extends Block{ } public class OverflowGateBuild extends Building{ - public Item lastItem; - public Tile lastInput; - public float time; - - @Override - public int acceptStack(Item item, int amount, Teamc source){ - return 0; - } - - @Override - public int removeStack(Item item, int amount){ - int result = super.removeStack(item, amount); - if(result != 0 && item == lastItem){ - lastItem = null; - } - return result; - } - - @Override - public void updateTile(){ - if(lastItem == null && items.total() > 0){ - items.clear(); - } - - if(lastItem != null){ - if(lastInput == null){ - lastItem = null; - return; - } - - time += 1f / speed * Time.delta; - Building target = getTileTarget(lastItem, lastInput, false); - - if(target != null && (time >= 1f)){ - getTileTarget(lastItem, lastInput, true); - target.handleItem(this, lastItem); - items.remove(lastItem, 1); - lastItem = null; - } - } - } @Override public boolean acceptItem(Building source, Item item){ - return team == source.team && lastItem == null && items.total() == 0; + Building to = getTileTarget(item, source, false); + + return to != null && to.acceptItem(this, item) && to.team == team; } @Override public void handleItem(Building source, Item item){ - items.add(item, 1); - lastItem = item; - time = 0f; - lastInput = source.tile(); + Building target = getTileTarget(item, source, true); + + if(target != null) target.handleItem(this, item); } - public @Nullable Building getTileTarget(Item item, Tile src, boolean flip){ - int from = relativeToEdge(src); + public @Nullable Building getTileTarget(Item item, Building src, boolean flip){ + int from = relativeToEdge(src.tile); if(from == -1) return null; Building to = nearby((from + 2) % 4); - boolean canForward = to != null && to.acceptItem(this, item) && to.team == team && !(to.block instanceof OverflowGate); - boolean inv = invert == enabled; + boolean + fromInst = src.block.instantTransfer, + canForward = to != null && to.acceptItem(this, item) && to.team == team && !(fromInst && to.block.instantTransfer), + inv = invert == enabled; if(!canForward || inv){ Building a = nearby(Mathf.mod(from - 1, 4)); Building b = nearby(Mathf.mod(from + 1, 4)); - boolean ac = a != null && a.acceptItem(this, item) && !(a.block instanceof OverflowGate) && a.team == team; - boolean bc = b != null && b.acceptItem(this, item) && !(b.block instanceof OverflowGate) && b.team == team; + boolean ac = a != null && a.acceptItem(this, item) && !(fromInst && a.block.instantTransfer) && a.team == team; + boolean bc = b != null && b.acceptItem(this, item) && !(fromInst && b.block.instantTransfer) && b.team == team; if(!ac && !bc){ return inv && canForward ? to : null; @@ -124,14 +84,7 @@ public class OverflowGate extends Block{ @Override public byte version(){ - return 3; - } - - @Override - public void write(Writes write){ - super.write(write); - - write.i(lastInput == null ? -1 : lastInput.pos()); + return 4; } @Override @@ -141,9 +94,10 @@ public class OverflowGate extends Block{ if(revision == 1){ new DirectionalItemBuffer(25).read(read); }else if(revision == 3){ - lastInput = world.tile(read.i()); - lastItem = items.first(); + read.i(); } + + items.clear(); } } } diff --git a/core/src/mindustry/world/blocks/distribution/Sorter.java b/core/src/mindustry/world/blocks/distribution/Sorter.java index b76037ee3d..3fe8653f06 100644 --- a/core/src/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/mindustry/world/blocks/distribution/Sorter.java @@ -81,13 +81,10 @@ public class Sorter extends Block{ @Override public void handleItem(Building source, Item item){ - Building to = getTileTarget(item, source, true); - - to.handleItem(this, item); + getTileTarget(item, source, true).handleItem(this, item); } public boolean isSame(Building other){ - // comment code below to allow sorter/gate chaining return other != null && other.block.instantTransfer; }