diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 2684bf206f..5e3e5d9346 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1251,8 +1251,7 @@ Invalid ID! = # Multiplayer options menu -Current IP address = -Server's IP address = +Server address = Reset to Dropbox = Check connection to server = Awaiting response... = diff --git a/core/src/com/unciv/logic/multiplayer/Multiplayer.kt b/core/src/com/unciv/logic/multiplayer/Multiplayer.kt index c058b4d145..a669bd2522 100644 --- a/core/src/com/unciv/logic/multiplayer/Multiplayer.kt +++ b/core/src/com/unciv/logic/multiplayer/Multiplayer.kt @@ -6,7 +6,6 @@ import com.unciv.UncivGame import com.unciv.logic.GameInfo import com.unciv.logic.GameInfoPreview import com.unciv.logic.GameSaver -import com.unciv.models.metadata.checkMultiplayerServerWithPort import com.unciv.ui.saves.Gzip import com.unciv.ui.worldscreen.mainmenu.OptionsPopup import java.util.* @@ -24,8 +23,7 @@ interface IFileMetaData { -class UncivServerFileStorage(serverIpWithPort:String):IFileStorage { - val serverUrl = "http://$serverIpWithPort" +class UncivServerFileStorage(val serverUrl:String):IFileStorage { override fun saveFileData(fileName: String, data: String) { OptionsPopup.SimpleHttp.sendRequest(Net.HttpMethods.PUT, "$serverUrl/files/$fileName", data){ success: Boolean, result: String -> @@ -70,10 +68,7 @@ class OnlineMultiplayer { val settings = UncivGame.Current.settings if (settings.multiplayerServer == Constants.dropboxMultiplayerServer) fileStorage = DropboxFileStorage() - else { - val serverIpWithPort = settings.multiplayerServer.checkMultiplayerServerWithPort() - fileStorage = UncivServerFileStorage(serverIpWithPort) - } + else fileStorage = UncivServerFileStorage(settings.multiplayerServer) } fun tryUploadGame(gameInfo: GameInfo, withPreview: Boolean) { diff --git a/core/src/com/unciv/models/metadata/ExtensionFunctions.kt b/core/src/com/unciv/models/metadata/ExtensionFunctions.kt deleted file mode 100644 index bcdf8bea0b..0000000000 --- a/core/src/com/unciv/models/metadata/ExtensionFunctions.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.unciv.models.metadata - -/** Check the url, if no port, add [defaultPort], then return the url. */ -fun String.checkMultiplayerServerWithPort(defaultPort: Int = 8080): String { - return if (contains(":")) this - else "$this:$defaultPort" -} \ No newline at end of file diff --git a/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt b/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt index 5d9b9218df..8b0351b585 100644 --- a/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt @@ -16,7 +16,6 @@ import com.unciv.UncivGame import com.unciv.logic.MapSaver import com.unciv.logic.civilization.PlayerType import com.unciv.models.UncivSound -import com.unciv.models.metadata.checkMultiplayerServerWithPort import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.Ruleset.RulesetError import com.unciv.models.ruleset.Ruleset.RulesetErrorSeverity @@ -260,18 +259,17 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) { val connectionToServerButton = "Check connection to server".toTextButton() - val ipAddress = getIpAddress() - add("{Current IP address}: $ipAddress".toTextButton().onClick { - Gdx.app.clipboard.contents = ipAddress.toString() - }).row() - - val multiplayerServerTextField = TextField(settings.multiplayerServer, BaseScreen.skin) + val textToShowForMultiplayerAddress = + if (settings.multiplayerServer != Constants.dropboxMultiplayerServer) settings.multiplayerServer + else "https://..." + val multiplayerServerTextField = TextField(textToShowForMultiplayerAddress, BaseScreen.skin) multiplayerServerTextField.programmaticChangeEvents = true + multiplayerServerTextField.width = screen.stage.width / 2 val serverIpTable = Table() - serverIpTable.add("Server's IP address".toLabel().onClick { + serverIpTable.add("Server address".toLabel().onClick { multiplayerServerTextField.text = Gdx.app.clipboard.contents - }).padRight(10f) + }).row() multiplayerServerTextField.onChange { settings.multiplayerServer = multiplayerServerTextField.text settings.save() @@ -345,7 +343,7 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) { } fun successfullyConnectedToServer(action: (Boolean, String)->Unit){ - SimpleHttp.sendGetRequest("http://${settings.multiplayerServer.checkMultiplayerServerWithPort()}/isalive", action) + SimpleHttp.sendGetRequest("${settings.multiplayerServer}/isalive", action) } private fun getAdvancedTab() = Table(BaseScreen.skin).apply { diff --git a/desktop/src/com/unciv/app/desktop/UncivServer.kt b/desktop/src/com/unciv/app/desktop/UncivServer.kt index e53f4ef446..0e17f8dd8a 100644 --- a/desktop/src/com/unciv/app/desktop/UncivServer.kt +++ b/desktop/src/com/unciv/app/desktop/UncivServer.kt @@ -26,7 +26,7 @@ private class UncivServerRunner : CliktCommand() { "-p", "-port", envvar = "UncivServerPort", help = "Server port" - ).int().restrictTo(1024..49151).default(8080) + ).int().restrictTo(1024..49151).default(80) private val folder by option( "-f", "-folder", diff --git a/docs/Other/Hosting-a-Multiplayer-server.md b/docs/Other/Hosting-a-Multiplayer-server.md index 66ced4808d..da1dd9ac2f 100644 --- a/docs/Other/Hosting-a-Multiplayer-server.md +++ b/docs/Other/Hosting-a-Multiplayer-server.md @@ -22,17 +22,12 @@ Your server has now started! In Unciv itself, from the same computer, enter Options > Multiplayer. -Click the first text (Current IP address) to copy the IP to the clipboard. -Then, click the second the second (Server IP address) to put your computer's IP in the "Server IP" slot. +Enter the URL of the computer you ran the server on (or http://localhost) If you click "check connection to server" you should now get "Return result: true", which means it's working! -So far you ran the server and connected yourself to it, but now for the interesting part - connecting other people! +For other devices, you'll need an external IP, which is out of scope for this documentation since there are many ways of achieving it. -The IP should still be in your clipboard - if not, just click the 'copy to clipboard' button again. -Send the IP to the other device, there - copy it, and click 'copy from clipboard'. -You can of course enter the IP manually if that's easier for you. - -Click 'check connection' from the new device, and if you got the same result - congratulations, you're both connected to the same server and can start a multiplayer game on the server! +On the other device, do the same - enter the URL, click 'check connection' from the new device, and if you got the same result - congratulations, you're both connected to the same server and can start a multiplayer game on the server! Please note that devices NOT connected to the same server will NOT be able to participate in multiplayer games together!