From 3746344cba397cd7156212a04d0b495c58c2d5fa Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 15 Aug 2018 16:26:08 -0400 Subject: [PATCH] Crash fixes --- core/src/io/anuke/mindustry/ai/BlockIndexer.java | 4 ++-- core/src/io/anuke/mindustry/input/InputHandler.java | 2 +- core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java | 4 +++- core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index ba0bd7a31d..72c8bafebd 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -119,7 +119,7 @@ public class BlockIndexer{ * Get all allied blocks with a flag. */ public ObjectSet getAllied(Team team, BlockFlag type){ - return (state.teams.get(team).ally ? allyMap : enemyMap).get(type, emptyArray); + return state.teams.has(team) ? (state.teams.get(team).ally ? allyMap : enemyMap).get(type, emptyArray) : emptyArray; } /** @@ -142,7 +142,7 @@ public class BlockIndexer{ for(int ty = ry * structQuadrantSize; ty < (ry + 1) * structQuadrantSize && ty < world.height(); ty++){ Tile other = world.tile(tx, ty); - if(other == null || other.entity == null || other.getTeam() != team || !pred.test(other)) continue; + if(other == null || other.entity == null || !pred.test(other)) continue; TileEntity e = other.entity; diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index ac48267cf4..cb4afd5cec 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -93,7 +93,7 @@ public abstract class InputHandler extends InputAdapter{ 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), () -> { - if(tile.block() != block) return; + if(tile.block() != block || tile.entity == null) return; tile.block().handleStack(stack.item, removed, tile, player); remaining[1] -= removed; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index 8f93058b87..d054d8cc49 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -74,7 +74,9 @@ public class JoinDialog extends FloatingDialog{ add.shown(() -> { add.getTitleLabel().setText(renaming != null ? "$text.server.edit" : "$text.server.add"); - field.setText(renaming.ip); + if(renaming != null){ + field.setText(renaming.ip); + } }); shown(() -> { diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java index dfbdaefd96..7758af1b43 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -224,7 +224,7 @@ public class PowerNode extends PowerBlock{ } protected boolean shouldDistribute(Tile tile, Tile other){ - return other.getTeamID() == tile.getTeamID() && other.entity.power.amount / other.block().powerCapacity <= tile.entity.power.amount / powerCapacity && + return other != null && other.getTeamID() == tile.getTeamID() && other.entity.power.amount / other.block().powerCapacity <= tile.entity.power.amount / powerCapacity && !(other.block() instanceof PowerGenerator); //do not distribute to power generators }