From 8733f02f8546d89b0fc1c53e8092b3d24aa1aa21 Mon Sep 17 00:00:00 2001 From: GGGuenni Date: Wed, 19 Feb 2020 13:31:46 +0100 Subject: [PATCH] Bug Fix for Multiplayer Screen (#1970) * Possible Bug Fix Testing if clipboard content == null This should have been a problem before * Moved null check into addMultiplayerGame making it more readable --- core/src/com/unciv/ui/MultiplayerScreen.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/ui/MultiplayerScreen.kt b/core/src/com/unciv/ui/MultiplayerScreen.kt index df4f05dc7f..719b6d8fa8 100644 --- a/core/src/com/unciv/ui/MultiplayerScreen.kt +++ b/core/src/com/unciv/ui/MultiplayerScreen.kt @@ -111,14 +111,11 @@ class MultiplayerScreen() : PickerScreen() { } //Adds a new Multiplayer game to the List - fun addMultiplayerGame(gameId: String, gameName: String = ""){ - if (gameIsAlreadySavedAsMultiplayer(gameId)) { - ResponsePopup("Game is already added".tr(), this) - return - } + //gameId must be nullable because clipboard content could be null + fun addMultiplayerGame(gameId: String?, gameName: String = ""){ try { //since the gameId is a String it can contain anything and has to be checked - UUID.fromString(gameId.trim()) + UUID.fromString(gameId!!.trim()) } catch (ex: Exception) { val errorPopup = Popup(this) errorPopup.addGoodSizedLabel("Invalid game ID!".tr()) @@ -127,6 +124,12 @@ class MultiplayerScreen() : PickerScreen() { errorPopup.open() return } + + if (gameIsAlreadySavedAsMultiplayer(gameId)) { + ResponsePopup("Game is already added".tr(), this) + return + } + thread(name="MultiplayerDownload") { addGameButton.setText("Working...".tr()) addGameButton.disable()