mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-03 13:30:25 +07:00
Fixed many various crashes
This commit is contained in:
parent
c2c837329c
commit
64f1fbe400
@ -129,7 +129,7 @@ public class RemoteWriteGenerator {
|
||||
method.beginControlFlow("if("+getCheckString(methodEntry.where)+")");
|
||||
|
||||
//add statement to create packet from pool
|
||||
method.addStatement("$1N packet = $2N.obtain($1N.class)", "io.anuke.mindustry.net.Packets.InvokePacket", "com.badlogic.gdx.utils.Pools");
|
||||
method.addStatement("$1N packet = $2N.obtain($1N.class)", "io.anuke.mindustry.net.Packets.InvokePacket", "io.anuke.ucore.util.Pooling");
|
||||
//assign buffer
|
||||
method.addStatement("packet.writeBuffer = TEMP_BUFFER");
|
||||
//assign priority
|
||||
|
@ -166,12 +166,14 @@ public class Control extends Module{
|
||||
Player[] old = players;
|
||||
players = new Player[index + 1];
|
||||
System.arraycopy(old, 0, players, 0, old.length);
|
||||
|
||||
InputHandler[] oldi = inputs;
|
||||
inputs = new InputHandler[index + 1];
|
||||
System.arraycopy(oldi, 0, inputs, 0, oldi.length);
|
||||
}
|
||||
|
||||
if(inputs.length != index + 1){
|
||||
InputHandler[] oldi = inputs;
|
||||
inputs = new InputHandler[index + 1];
|
||||
System.arraycopy(oldi, 0, inputs, 0, oldi.length);
|
||||
}
|
||||
|
||||
Player setTo = (index == 0 ? null : players[0]);
|
||||
|
||||
Player player = new Player();
|
||||
|
@ -494,14 +494,12 @@ public class NetServer extends Module{
|
||||
return;
|
||||
}
|
||||
|
||||
String ip = player.con.address;
|
||||
|
||||
if(action == AdminAction.wave) {
|
||||
//no verification is done, so admins can hypothetically spam waves
|
||||
//not a real issue, because server owners may want to do just that
|
||||
state.wavetime = 0f;
|
||||
}else if(action == AdminAction.ban){
|
||||
netServer.admins.banPlayerIP(ip);
|
||||
netServer.admins.banPlayerIP(other.con.address);
|
||||
netServer.kick(other.con.id, KickReason.banned);
|
||||
Log.info("&lc{0} has banned {1}.", player.name, other.name);
|
||||
}else if(action == AdminAction.kick){
|
||||
|
@ -93,11 +93,11 @@ public class World extends Module{
|
||||
}
|
||||
|
||||
public int width(){
|
||||
return tiles.length;
|
||||
return tiles == null ? 0 : tiles.length;
|
||||
}
|
||||
|
||||
public int height(){
|
||||
return tiles[0].length;
|
||||
return tiles == null ? 0 : tiles[0].length;
|
||||
}
|
||||
|
||||
public int toPacked(int x, int y){
|
||||
|
@ -368,13 +368,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
public void updateSelectedBlock(){
|
||||
Block block = editor.getDrawBlock();
|
||||
int i = 0;
|
||||
for(int j = 0; j < Block.all().size; j ++){
|
||||
if(block.id == j){
|
||||
blockgroup.getButtons().get(i).setChecked(true);
|
||||
if(block.id == j && j < blockgroup.getButtons().size){
|
||||
blockgroup.getButtons().get(j).setChecked(true);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable
|
||||
|
||||
time = Mathf.clamp(time + Timers.delta(), 0, lifetime());
|
||||
|
||||
if(time >= lifetime()){
|
||||
if(time >= lifetime() || tile == null){
|
||||
CallEntity.onFireRemoved(getID());
|
||||
remove();
|
||||
}
|
||||
|
@ -283,50 +283,49 @@ public abstract class InputHandler extends InputAdapter{
|
||||
throw new ValidateException(player, "Player cannot transfer an item.");
|
||||
}
|
||||
|
||||
if(player == null) return;
|
||||
threads.run(() -> {
|
||||
if (player == null || tile.entity == null) return;
|
||||
|
||||
player.isTransferring = true;
|
||||
player.isTransferring = true;
|
||||
|
||||
ItemStack stack = player.inventory.getItem();
|
||||
int accepted = tile.block().acceptStack(stack.item, stack.amount, tile, player);
|
||||
ItemStack stack = player.inventory.getItem();
|
||||
int accepted = tile.block().acceptStack(stack.item, stack.amount, tile, player);
|
||||
|
||||
boolean clear = stack.amount == accepted;
|
||||
int sent = Mathf.clamp(accepted/4, 1, 8);
|
||||
int removed = accepted/sent;
|
||||
int[] remaining = {accepted, accepted};
|
||||
boolean clear = stack.amount == accepted;
|
||||
int sent = Mathf.clamp(accepted / 4, 1, 8);
|
||||
int removed = accepted / sent;
|
||||
int[] remaining = {accepted, accepted};
|
||||
|
||||
for(int i = 0; i < sent; i ++){
|
||||
boolean end = i == sent-1;
|
||||
Timers.run(i * 3, () -> {
|
||||
tile.block().getStackOffset(stack.item, tile, stackTrns);
|
||||
for (int i = 0; i < sent; i++) {
|
||||
boolean end = i == sent - 1;
|
||||
Timers.run(i * 3, () -> {
|
||||
tile.block().getStackOffset(stack.item, tile, stackTrns);
|
||||
|
||||
ItemTransfer.create(stack.item,
|
||||
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
|
||||
new Translator(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||
ItemTransfer.create(stack.item,
|
||||
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
|
||||
new Translator(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||
|
||||
tile.block().handleStack(stack.item, removed, tile, player);
|
||||
remaining[1] -= removed;
|
||||
tile.block().handleStack(stack.item, removed, tile, player);
|
||||
remaining[1] -= removed;
|
||||
|
||||
if(end && remaining[1] > 0) {
|
||||
tile.block().handleStack(stack.item, remaining[1], tile, player);
|
||||
}
|
||||
});
|
||||
if (end && remaining[1] > 0) {
|
||||
tile.block().handleStack(stack.item, remaining[1], tile, player);
|
||||
}
|
||||
});
|
||||
|
||||
stack.amount -= removed;
|
||||
remaining[0] -= removed;
|
||||
stack.amount -= removed;
|
||||
remaining[0] -= removed;
|
||||
|
||||
if(end){
|
||||
stack.amount -= remaining[0];
|
||||
if(clear){
|
||||
player.inventory.clearItem();
|
||||
if (end) {
|
||||
stack.amount -= remaining[0];
|
||||
if (clear) {
|
||||
player.inventory.clearItem();
|
||||
}
|
||||
player.isTransferring = false;
|
||||
}
|
||||
player.isTransferring = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//ItemDrop.create(player.inventory.getItem().item, player.inventory.getItem().amount, player.x, player.y, angle);
|
||||
//player.inventory.clearItem();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.server, forward = true, in = In.blocks)
|
||||
|
@ -59,7 +59,7 @@ public class BlockInventoryFragment extends Fragment {
|
||||
public void showFor(Tile t){
|
||||
this.tile = t.target();
|
||||
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.totalItems() == 0) return;
|
||||
rebuild();
|
||||
rebuild(true);
|
||||
}
|
||||
|
||||
public void hide(){
|
||||
@ -71,7 +71,7 @@ public class BlockInventoryFragment extends Fragment {
|
||||
tile = null;
|
||||
}
|
||||
|
||||
private void rebuild(){
|
||||
private void rebuild(boolean actions){
|
||||
Player player = input.player;
|
||||
|
||||
IntSet container = new IntSet();
|
||||
@ -99,7 +99,7 @@ public class BlockInventoryFragment extends Fragment {
|
||||
int[] items = tile.entity.items.items;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if ((items[i] == 0) == container.contains(i)) {
|
||||
rebuild();
|
||||
rebuild(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,8 +160,10 @@ public class BlockInventoryFragment extends Fragment {
|
||||
|
||||
updateTablePosition();
|
||||
|
||||
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
if(actions){
|
||||
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
}
|
||||
}
|
||||
|
||||
private String round(float f){
|
||||
|
@ -100,6 +100,8 @@ public class BuildBlock extends Block {
|
||||
return;
|
||||
}
|
||||
|
||||
if(entity.previous == null) return;
|
||||
|
||||
for (TextureRegion region : entity.previous.getBlockIcon()) {
|
||||
Draw.rect(region, tile.drawx(), tile.drawy(), entity.previous.rotate ? tile.getRotation() * 90 : 0);
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public class Separator extends Block {
|
||||
|
||||
stats.add(BlockStat.liquidUse, liquidUse * 60f, StatUnit.liquidSecond);
|
||||
stats.add(BlockStat.inputLiquid, liquid);
|
||||
stats.add(BlockStat.inputItem, item);
|
||||
stats.add(BlockStat.outputItem, new ItemFilterValue(item -> {
|
||||
for(Item i : results){
|
||||
if(item == i) return true;
|
||||
|
Loading…
Reference in New Issue
Block a user