diff --git a/core/src/Mindustry.gwt.xml b/core/src/Mindustry.gwt.xml
index 1dcf056855..5fdf4b2778 100644
--- a/core/src/Mindustry.gwt.xml
+++ b/core/src/Mindustry.gwt.xml
@@ -14,4 +14,5 @@
+
\ No newline at end of file
diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java
index 39078cd2aa..f28dff41f5 100644
--- a/core/src/io/anuke/mindustry/core/NetClient.java
+++ b/core/src/io/anuke/mindustry/core/NetClient.java
@@ -10,7 +10,6 @@ import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity;
import io.anuke.mindustry.entities.enemies.Enemy;
-import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Net.SendMode;
@@ -20,7 +19,6 @@ import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Map;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.ProductionBlocks;
-import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.BaseBulletType;
import io.anuke.ucore.entities.Entities;
@@ -272,10 +270,10 @@ public class NetClient extends Module {
Net.handleClient(ItemTransferPacket.class, packet -> {
Tile tile = world.tile(packet.position);
+ if(tile == null || tile.entity == null) return;
Tile next = tile.getNearby(packet.rotation);
tile.entity.items[packet.itemid] --;
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
- Effects.effect(Fx.transfer, tile.drawx(), tile.drawy(), packet.rotation * 90);
});
}
diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java
index 0b474da29f..a25a3a7a69 100644
--- a/core/src/io/anuke/mindustry/entities/Player.java
+++ b/core/src/io/anuke/mindustry/entities/Player.java
@@ -277,7 +277,7 @@ public class Player extends SyncEntity{
interpolator.time = 0f;
interpolator.last.set(this.x, this.y);
interpolator.target.set(x, y);
- interpolator.spacing = Math.max(((TimeUtils.timeSinceMillis(time) / 1000f) * 60f), 4f);
+ interpolator.spacing = Math.min(Math.max(((TimeUtils.timeSinceMillis(time) / 1000f) * 60f), 4f), 10);
}
@Override
@@ -291,6 +291,12 @@ public class Player extends SyncEntity{
x = Tmp.v2.x;
y = Tmp.v2.y;
+ if(i.target.dst(x, y) > 128){
+ set(i.target.x, i.target.y);
+ i.time = 0f;
+ i.last.set(i.target);
+ }
+
angle = Mathf.lerpAngDelta(angle, i.targetrot, 0.6f);
if(isAndroid && i.target.dst(i.last) > 2f && Timers.get(this, "dashfx", 2)){
diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java
index b19162fd28..2fcea376bd 100644
--- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java
+++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java
@@ -142,7 +142,7 @@ public class Enemy extends SyncEntity {
interpolator.time = 0f;
interpolator.last.set(this.x, this.y);
interpolator.target.set(x, y);
- interpolator.spacing = Math.max(((TimeUtils.timeSinceMillis(time) / 1000f) * 60f), 4f);
+ interpolator.spacing = Math.min(Math.max(((TimeUtils.timeSinceMillis(time) / 1000f) * 60f), 4f), 10f);
}
@Override
diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java
index 7b7d0010af..7904665290 100644
--- a/core/src/io/anuke/mindustry/net/Net.java
+++ b/core/src/io/anuke/mindustry/net/Net.java
@@ -25,7 +25,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
public class Net{
- public static final int version = 17;
+ public static final int version = 18;
private static boolean server;
private static boolean active;
diff --git a/core/src/io/anuke/mindustry/resource/Recipes.java b/core/src/io/anuke/mindustry/resource/Recipes.java
index a6739278dd..618f6429f4 100644
--- a/core/src/io/anuke/mindustry/resource/Recipes.java
+++ b/core/src/io/anuke/mindustry/resource/Recipes.java
@@ -77,7 +77,7 @@ public class Recipes {
new Recipe(power, DefenseBlocks.shieldgenerator, stack(Item.titanium, 30), stack(Item.dirium, 30)),
- new Recipe(distribution, DistributionBlocks.teleporter, stack(Item.steel, 20), stack(Item.dirium, 15)),
+ new Recipe(distribution, DistributionBlocks.teleporter, stack(Item.steel, 30), stack(Item.dirium, 40)),
new Recipe(power, DefenseBlocks.repairturret, stack(Item.iron, 30)),
new Recipe(power, DefenseBlocks.megarepairturret, stack(Item.iron, 20), stack(Item.steel, 30)),
diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Junction.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Junction.java
index 43c8a63869..45888a7c82 100644
--- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Junction.java
+++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Junction.java
@@ -8,7 +8,8 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Bits;
public class Junction extends Block{
- float speed = 20; //frames taken to go through this junction
+ protected float speed = 20; //frames taken to go through this junction
+ protected int capacity = 16;
public Junction(String name) {
super(name);
@@ -24,37 +25,49 @@ public class Junction extends Block{
@Override
public void handleItem(Item item, Tile tile, Tile source){
JunctionEntity entity = tile.entity();
- entity.items[entity.index ++] = Bits.packInt((short)item.id, source.relativeTo(tile.x, tile.y));
+ boolean x = tile.x == source.x;
+ int value = Bits.packInt((short)item.id, source.relativeTo(tile.x, tile.y));
+ if(x){
+ entity.bx.add(value);
+ }else{
+ entity.by.add(value);
+ }
}
@Override
public void update(Tile tile){
JunctionEntity entity = tile.entity();
- if(entity.index > 0){
- entity.time += Timers.delta();
- if(entity.time >= speed){
- int i = entity.items[-- entity.index];
+ for(int i = 0; i < 2; i ++){
+ Buffer buffer = (i == 0 ? entity.bx : entity.by);
+ if(buffer.index > 0){
+ buffer.time += Timers.delta();
+ if(buffer.time >= speed){
+ int val = buffer.items[buffer.index - 1];
- int item = Bits.getLeftShort(i);
- int direction = Bits.getRightShort(i);
+ Item item = Item.getByID(Bits.getLeftShort(val));
+ int direction = Bits.getRightShort(val);
+ Tile dest = tile.getNearby(direction);
- Tile target = tile.getNearby(direction);
+ if(dest == null || !dest.block().acceptItem(item, dest, tile)) continue;
- target.block().handleItem(Item.getByID(item), target, tile);
+ dest.block().handleItem(item, dest, tile);
- entity.time = 0f;
+ buffer.time = 0f;
+ buffer.index --;
+ }
+ }else{
+ buffer.time = 0f;
}
- }else{
- entity.time = 0f;
}
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
JunctionEntity entity = tile.entity();
+ boolean x = tile.x == source.x;
- if(entity.index >= entity.items.length - 1) return false;
+ if((x && entity.bx.full()) || (!x && entity.by.full())) return false;
int dir = source.relativeTo(tile.x, tile.y);
if(dir == -1) return false;
Tile to = tile.getNearby(dir);
@@ -67,8 +80,21 @@ public class Junction extends Block{
}
class JunctionEntity extends TileEntity{
- int[] items = new int[16]; //16 item buffer
+ Buffer bx = new Buffer();
+ Buffer by = new Buffer();
+ }
+
+ class Buffer{
+ int[] items = new int[capacity];
int index;
float time;
+
+ void add(int id){
+ items[index ++] = id;
+ }
+
+ boolean full(){
+ return index >= items.length - 1;
+ }
}
}
diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java
index 89d7de6676..a543f9d42b 100644
--- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java
+++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java
@@ -1,14 +1,15 @@
package io.anuke.mindustry.world.blocks.types.distribution;
+import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
-import io.anuke.ucore.util.Bits;
-import io.anuke.ucore.util.Log;
-public class TunnelConveyor extends Junction{
+public class TunnelConveyor extends Block{
protected int maxdist = 3;
+ protected float speed = 20; //frames taken to go through this tunnel
+ protected int capacity = 16;
protected TunnelConveyor(String name) {
super(name);
@@ -16,7 +17,6 @@ public class TunnelConveyor extends Junction{
update = true;
solid = true;
health = 70;
- speed = 25;
}
@Override
@@ -26,43 +26,38 @@ public class TunnelConveyor extends Junction{
@Override
public void handleItem(Item item, Tile tile, Tile source){
+ TunnelEntity entity = tile.entity();
+
Tile tunnel = getDestTunnel(tile, item);
if(tunnel == null) return;
Tile to = tunnel.getNearby(tunnel.getRotation());
if(to == null) return;
- Block before = to.block();
-
- Timers.run(25, () -> {
- if(to.block() != before) return;
- //TODO fix
- try {
- to.block().handleItem(item, to, tunnel);
- }catch (NullPointerException e){
- Log.err(e);
- }
- });
+
+ entity.buffer[entity.index ++] = item.id;
}
@Override
public void update(Tile tile){
- JunctionEntity entity = tile.entity();
+ TunnelEntity entity = tile.entity();
if(entity.index > 0){
entity.time += Timers.delta();
if(entity.time >= speed){
- int i = entity.items[-- entity.index];
- entity.time = 0f;
+ int i = entity.buffer[entity.index - 1];
- int itemid = Bits.getLeftShort(i);
-
- Item item = Item.getByID(itemid);
+ Item item = Item.getByID(i);
Tile tunnel = getDestTunnel(tile, item);
if(tunnel == null) return;
Tile target = tunnel.getNearby(tunnel.getRotation());
if(target == null) return;
+ if(!target.block().acceptItem(item, target, tunnel)) return;
+
target.block().handleItem(item, target, tunnel);
+
+ entity.index --;
+ entity.time = 0f;
}
}else{
entity.time = 0f;
@@ -71,6 +66,10 @@ public class TunnelConveyor extends Junction{
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
+ TunnelEntity entity = tile.entity();
+
+ if(entity.index >= entity.buffer.length - 1) return false;
+
int rot = source.relativeTo(tile.x, tile.y);
if(rot != (tile.getRotation() + 2)%4) return false;
Tile tunnel = getDestTunnel(tile, item);
@@ -82,7 +81,12 @@ public class TunnelConveyor extends Junction{
return false;
}
}
-
+
+ @Override
+ public TileEntity getEntity() {
+ return new TunnelEntity();
+ }
+
Tile getDestTunnel(Tile tile, Item item){
Tile dest = tile;
int rel = (tile.getRotation() + 2)%4;
@@ -96,4 +100,10 @@ public class TunnelConveyor extends Junction{
}
return null;
}
+
+ class TunnelEntity extends TileEntity {
+ int[] buffer = new int[capacity];
+ int index;
+ float time;
+ }
}
diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java
index 3938b993fa..680a4ec1dd 100644
--- a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java
+++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java
@@ -161,8 +161,8 @@ public class Generator extends PowerBlock{
continue;
PowerAcceptor p = (PowerAcceptor) target.block();
- float transmit = entity.power * Timers.delta();
- if(p.acceptsPower(target) && entity.power >= transmit){
+ float transmit = Math.min(powerSpeed * Timers.delta(), entity.power);
+ if(p.acceptsPower(target)){
float accepted = p.addPower(target, transmit);
entity.power -= accepted;
}
diff --git a/kryonet/src/io/anuke/kryonet/KryoClient.java b/kryonet/src/io/anuke/kryonet/KryoClient.java
index 52cddac4e2..0940f4e517 100644
--- a/kryonet/src/io/anuke/kryonet/KryoClient.java
+++ b/kryonet/src/io/anuke/kryonet/KryoClient.java
@@ -91,7 +91,7 @@ public class KryoClient implements ClientProvider{
};
if(KryoRegistrator.fakeLag){
- client.addListener(new LagListener(0, KryoRegistrator.fakeLagAmount, listener));
+ client.addListener(new LagListener(KryoRegistrator.fakeLagMin, KryoRegistrator.fakeLagMax, listener));
}else{
client.addListener(listener);
}
diff --git a/kryonet/src/io/anuke/kryonet/KryoRegistrator.java b/kryonet/src/io/anuke/kryonet/KryoRegistrator.java
index 1e3ccd8ff0..a30486cbce 100644
--- a/kryonet/src/io/anuke/kryonet/KryoRegistrator.java
+++ b/kryonet/src/io/anuke/kryonet/KryoRegistrator.java
@@ -16,7 +16,8 @@ import static io.anuke.mindustry.Vars.playerGroup;
public class KryoRegistrator {
public static boolean fakeLag = false;
- public static final int fakeLagAmount = 500;
+ public static final int fakeLagMax = 1000;
+ public static final int fakeLagMin = 0;
static{
Log.set(Log.LEVEL_WARN);
diff --git a/kryonet/src/io/anuke/kryonet/KryoServer.java b/kryonet/src/io/anuke/kryonet/KryoServer.java
index 13034a186a..a8610303f2 100644
--- a/kryonet/src/io/anuke/kryonet/KryoServer.java
+++ b/kryonet/src/io/anuke/kryonet/KryoServer.java
@@ -105,7 +105,7 @@ public class KryoServer implements ServerProvider {
};
if(KryoRegistrator.fakeLag){
- server.addListener(new LagListener(0, KryoRegistrator.fakeLagAmount, listener));
+ server.addListener(new LagListener(KryoRegistrator.fakeLagMin, KryoRegistrator.fakeLagMax, listener));
}else{
server.addListener(listener);
}
diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java
index 29a6345ad2..cd7fa113a5 100644
--- a/server/src/io/anuke/mindustry/server/ServerControl.java
+++ b/server/src/io/anuke/mindustry/server/ServerControl.java
@@ -174,7 +174,7 @@ public class ServerControl extends Module {
}else{
info("&lyNo players connected.");
}
- info("&lbFPS: {0}", Gdx.graphics.getFramesPerSecond());
+ info("&lbFPS: {0}", (int)(60f/Timers.delta()));
}
});