Fixed many various crashes

This commit is contained in:
Anuken
2018-07-06 12:04:33 -04:00
parent c2c837329c
commit 64f1fbe400
10 changed files with 56 additions and 54 deletions
@@ -129,7 +129,7 @@ public class RemoteWriteGenerator {
method.beginControlFlow("if("+getCheckString(methodEntry.where)+")"); method.beginControlFlow("if("+getCheckString(methodEntry.where)+")");
//add statement to create packet from pool //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 //assign buffer
method.addStatement("packet.writeBuffer = TEMP_BUFFER"); method.addStatement("packet.writeBuffer = TEMP_BUFFER");
//assign priority //assign priority
@@ -166,7 +166,9 @@ public class Control extends Module{
Player[] old = players; Player[] old = players;
players = new Player[index + 1]; players = new Player[index + 1];
System.arraycopy(old, 0, players, 0, old.length); System.arraycopy(old, 0, players, 0, old.length);
}
if(inputs.length != index + 1){
InputHandler[] oldi = inputs; InputHandler[] oldi = inputs;
inputs = new InputHandler[index + 1]; inputs = new InputHandler[index + 1];
System.arraycopy(oldi, 0, inputs, 0, oldi.length); System.arraycopy(oldi, 0, inputs, 0, oldi.length);
@@ -494,14 +494,12 @@ public class NetServer extends Module{
return; return;
} }
String ip = player.con.address;
if(action == AdminAction.wave) { if(action == AdminAction.wave) {
//no verification is done, so admins can hypothetically spam waves //no verification is done, so admins can hypothetically spam waves
//not a real issue, because server owners may want to do just that //not a real issue, because server owners may want to do just that
state.wavetime = 0f; state.wavetime = 0f;
}else if(action == AdminAction.ban){ }else if(action == AdminAction.ban){
netServer.admins.banPlayerIP(ip); netServer.admins.banPlayerIP(other.con.address);
netServer.kick(other.con.id, KickReason.banned); netServer.kick(other.con.id, KickReason.banned);
Log.info("&lc{0} has banned {1}.", player.name, other.name); Log.info("&lc{0} has banned {1}.", player.name, other.name);
}else if(action == AdminAction.kick){ }else if(action == AdminAction.kick){
+2 -2
View File
@@ -93,11 +93,11 @@ public class World extends Module{
} }
public int width(){ public int width(){
return tiles.length; return tiles == null ? 0 : tiles.length;
} }
public int height(){ public int height(){
return tiles[0].length; return tiles == null ? 0 : tiles[0].length;
} }
public int toPacked(int x, int y){ public int toPacked(int x, int y){
@@ -368,13 +368,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
public void updateSelectedBlock(){ public void updateSelectedBlock(){
Block block = editor.getDrawBlock(); Block block = editor.getDrawBlock();
int i = 0;
for(int j = 0; j < Block.all().size; j ++){ for(int j = 0; j < Block.all().size; j ++){
if(block.id == j){ if(block.id == j && j < blockgroup.getButtons().size){
blockgroup.getButtons().get(i).setChecked(true); blockgroup.getButtons().get(j).setChecked(true);
break; break;
} }
i++;
} }
} }
@@ -91,7 +91,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable
time = Mathf.clamp(time + Timers.delta(), 0, lifetime()); time = Mathf.clamp(time + Timers.delta(), 0, lifetime());
if(time >= lifetime()){ if(time >= lifetime() || tile == null){
CallEntity.onFireRemoved(getID()); CallEntity.onFireRemoved(getID());
remove(); remove();
} }
@@ -283,7 +283,8 @@ public abstract class InputHandler extends InputAdapter{
throw new ValidateException(player, "Player cannot transfer an item."); 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;
@@ -324,9 +325,7 @@ public abstract class InputHandler extends InputAdapter{
} }
}); });
} }
});
//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) @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){ public void showFor(Tile t){
this.tile = t.target(); this.tile = t.target();
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.totalItems() == 0) return; if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.totalItems() == 0) return;
rebuild(); rebuild(true);
} }
public void hide(){ public void hide(){
@@ -71,7 +71,7 @@ public class BlockInventoryFragment extends Fragment {
tile = null; tile = null;
} }
private void rebuild(){ private void rebuild(boolean actions){
Player player = input.player; Player player = input.player;
IntSet container = new IntSet(); IntSet container = new IntSet();
@@ -99,7 +99,7 @@ public class BlockInventoryFragment extends Fragment {
int[] items = tile.entity.items.items; int[] items = tile.entity.items.items;
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
if ((items[i] == 0) == container.contains(i)) { if ((items[i] == 0) == container.contains(i)) {
rebuild(); rebuild(false);
} }
} }
} }
@@ -160,9 +160,11 @@ public class BlockInventoryFragment extends Fragment {
updateTablePosition(); updateTablePosition();
if(actions){
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true), table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out)); Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
} }
}
private String round(float f){ private String round(float f){
f = (int)f; f = (int)f;
@@ -100,6 +100,8 @@ public class BuildBlock extends Block {
return; return;
} }
if(entity.previous == null) return;
for (TextureRegion region : entity.previous.getBlockIcon()) { for (TextureRegion region : entity.previous.getBlockIcon()) {
Draw.rect(region, tile.drawx(), tile.drawy(), entity.previous.rotate ? tile.getRotation() * 90 : 0); 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.liquidUse, liquidUse * 60f, StatUnit.liquidSecond);
stats.add(BlockStat.inputLiquid, liquid); stats.add(BlockStat.inputLiquid, liquid);
stats.add(BlockStat.inputItem, item);
stats.add(BlockStat.outputItem, new ItemFilterValue(item -> { stats.add(BlockStat.outputItem, new ItemFilterValue(item -> {
for(Item i : results){ for(Item i : results){
if(item == i) return true; if(item == i) return true;