From 697be27d4fdd9c90d8c122f8e4e4c2760cad29b1 Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 7 May 2018 23:07:47 +0300 Subject: [PATCH] - NPE prevention in LobbyScreen on mobile Forge when trying to choose a variant without having a constructed deck. --- .../screens/constructed/LobbyScreen.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java index 83c512932ee..7a1e12477e9 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java +++ b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java @@ -556,25 +556,27 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { } Deck playerDeck = deck; - if (hasVariant(GameType.Archenemy) || hasVariant(GameType.ArchenemyRumble)) { - if (playerDeck == deck) { - playerDeck = new Deck(deck); //create copy that can be modified + if (deck != null) { + if (hasVariant(GameType.Archenemy) || hasVariant(GameType.ArchenemyRumble)) { + if (playerDeck == deck) { + playerDeck = new Deck(deck); //create copy that can be modified + } + playerDeck.putSection(DeckSection.Schemes, playerPanel.getSchemeDeck().get(DeckSection.Schemes)); } - playerDeck.putSection(DeckSection.Schemes, playerPanel.getSchemeDeck().get(DeckSection.Schemes)); - } - if (hasVariant(GameType.Planechase)) { - if (playerDeck == deck) { - playerDeck = new Deck(deck); //create copy that can be modified + if (hasVariant(GameType.Planechase)) { + if (playerDeck == deck) { + playerDeck = new Deck(deck); //create copy that can be modified + } + playerDeck.putSection(DeckSection.Planes, playerPanel.getPlanarDeck().get(DeckSection.Planes)); } - playerDeck.putSection(DeckSection.Planes, playerPanel.getPlanarDeck().get(DeckSection.Planes)); - } - if (hasVariant(GameType.Vanguard)) { - if (playerDeck == deck) { - playerDeck = new Deck(deck); //create copy that can be modified + if (hasVariant(GameType.Vanguard)) { + if (playerDeck == deck) { + playerDeck = new Deck(deck); //create copy that can be modified + } + CardPool avatarPool = new CardPool(); + avatarPool.add(playerPanel.getVanguardAvatar()); + playerDeck.putSection(DeckSection.Avatar, avatarPool); } - CardPool avatarPool = new CardPool(); - avatarPool.add(playerPanel.getVanguardAvatar()); - playerDeck.putSection(DeckSection.Avatar, avatarPool); } decks[playerIndex] = playerDeck;