Fixed various crashes, synchronization bugs
This commit is contained in:
@@ -15,13 +15,13 @@ import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.impl.TimedEntity;
|
||||
import io.anuke.ucore.entities.trait.DrawTrait;
|
||||
import io.anuke.ucore.entities.trait.PosTrait;
|
||||
import io.anuke.ucore.function.Callable;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.effectGroup;
|
||||
import static io.anuke.mindustry.Vars.threads;
|
||||
|
||||
public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
private Vector2 from = new Vector2();
|
||||
@@ -30,7 +30,7 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
private Item item;
|
||||
private float seed;
|
||||
private PosTrait to;
|
||||
private Callable done;
|
||||
private Runnable done;
|
||||
|
||||
@Remote(in = In.entities, called = Loc.server, unreliable = true)
|
||||
public static void transferAmmo(Item item, float x, float y, Unit to){
|
||||
@@ -60,7 +60,7 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
tile.entity.items.addItem(item, amount);
|
||||
}
|
||||
|
||||
public static void create(Item item, float fromx, float fromy, PosTrait to, Callable done){
|
||||
public static void create(Item item, float fromx, float fromy, PosTrait to, Runnable done){
|
||||
ItemTransfer tr = Pools.obtain(ItemTransfer.class);
|
||||
tr.item = item;
|
||||
tr.from.set(fromx, fromy);
|
||||
@@ -90,7 +90,9 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
done.run();
|
||||
if(done != null){
|
||||
threads.run(done);
|
||||
}
|
||||
Pools.free(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class BlockRenderer{
|
||||
|
||||
if(!expanded && block != Blocks.air && world.isAccessible(worldx, worldy)){
|
||||
synchronized (Tile.tileSetLock) {
|
||||
block.drawShadow(tile);
|
||||
tile.block().drawShadow(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,6 @@ public class BlockRenderer{
|
||||
}
|
||||
|
||||
BlockRequest req = requests.get(iterateidx);
|
||||
Block block = req.tile.block();
|
||||
|
||||
if(req.layer != lastLayer){
|
||||
if(lastLayer != null) layerEnds(lastLayer);
|
||||
@@ -133,6 +132,8 @@ public class BlockRenderer{
|
||||
}
|
||||
|
||||
synchronized (Tile.tileSetLock) {
|
||||
Block block = req.tile.block();
|
||||
|
||||
if (req.layer == Layer.block) {
|
||||
block.draw(req.tile);
|
||||
} else if (req.layer == block.layer) {
|
||||
@@ -157,12 +158,15 @@ public class BlockRenderer{
|
||||
|
||||
BlockRequest req = requests.get(index);
|
||||
if(req.tile.getTeam() != team) continue;
|
||||
Block block = req.tile.block();
|
||||
|
||||
if(req.layer == block.layer){
|
||||
block.drawLayer(req.tile);
|
||||
}else if(req.layer == block.layer2){
|
||||
block.drawLayer2(req.tile);
|
||||
synchronized (Tile.tileSetLock) {
|
||||
Block block = req.tile.block();
|
||||
|
||||
if (req.layer == block.layer) {
|
||||
block.drawLayer(req.tile);
|
||||
} else if (req.layer == block.layer2) {
|
||||
block.drawLayer2(req.tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public class ArtilleryTurret extends ItemTurret {
|
||||
entity.heat = 1f;
|
||||
|
||||
AmmoType type = peekAmmo(tile);
|
||||
useAmmo(tile);
|
||||
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
|
||||
@@ -37,5 +36,6 @@ public class ArtilleryTurret extends ItemTurret {
|
||||
entity.rotation + Mathf.range(inaccuracy + type.inaccuracy), dst/maxTraveled);
|
||||
|
||||
effects(tile);
|
||||
useAmmo(tile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user