From 396a7f512c81fe798b290e04f65b2929b7853993 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Sep 2022 22:26:14 -0400 Subject: [PATCH 1/2] fix minimap NPE --- megamek/src/megamek/common/Board.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/megamek/src/megamek/common/Board.java b/megamek/src/megamek/common/Board.java index 7384e41c440..283123926c7 100644 --- a/megamek/src/megamek/common/Board.java +++ b/megamek/src/megamek/common/Board.java @@ -829,6 +829,10 @@ public boolean isLegalDeployment(Coords c, Player p) { * Can the given entity be deployed at these coordinates */ public boolean isLegalDeployment(Coords c, Entity e) { + if (e == null) { + return false; + } + return isLegalDeployment(c, e.getStartingPos(), e.getStartingWidth(), e.getStartingOffset()); } From a8227bd2ea84383c98c713e12ece6716c494964c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Sep 2022 22:50:41 -0400 Subject: [PATCH 2/2] cleanup deployment zone rendering code in minimap --- .../megamek/client/ui/swing/minimap/Minimap.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java index 2c189a96e45..963cf161d57 100644 --- a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java +++ b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java @@ -571,20 +571,12 @@ private synchronized void drawMap(boolean forceDraw) { /** Indicates the deployment hexes. */ private void drawDeploymentZone(Graphics g) { if ((null != client) && (null != game) - && (GamePhase.DEPLOYMENT == game.getPhase()) && (dialog != null)) { + && (GamePhase.DEPLOYMENT == game.getPhase()) && (dialog != null) + && (bv.getDeployingEntity() != null)) { GameTurn turn = game.getTurn(); if ((turn != null) && (turn.getPlayerNum() == client.getLocalPlayer().getId())) { Entity deployingUnit = bv.getDeployingEntity(); - int dir; - // We need to draw the same deployment zone as boardview - if ((deployingUnit != null) && (deployingUnit.getOwnerId() == turn.getPlayerNum())) { - dir = deployingUnit.getStartingPos(); - } else { - // if we can't get the deploy zone from the - // board view, punt and use the players zone - dir = client.getLocalPlayer().getStartingPos(); - } - + for (int j = 0; j < board.getWidth(); j++) { for (int k = 0; k < board.getHeight(); k++) { Coords coords = new Coords(j, k);