mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-01 10:24:25 +07:00
Duplicate IP prevention / Removed overflow inventories
This commit is contained in:
parent
4aa2d9097f
commit
25b22b4f93
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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<Building> builds){
|
||||
if(builds.first() instanceof ConveyorBuild build){
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user