From 8b5665a73f448e38245365bf24951baad0297448 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 17 Apr 2022 13:26:04 +0300 Subject: [PATCH] Resolved #6445 - problems in hosting Unciv server Solution from https://stackoverflow.com/questions/56533497/how-to-replace-blocking-code-for-reading-bytes-in-kotlin --- core/src/com/unciv/models/ruleset/Nation.kt | 2 +- desktop/src/com/unciv/app/desktop/UncivServer.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Nation.kt b/core/src/com/unciv/models/ruleset/Nation.kt index 86cc518eee..fdc33b95b6 100644 --- a/core/src/com/unciv/models/ruleset/Nation.kt +++ b/core/src/com/unciv/models/ruleset/Nation.kt @@ -248,7 +248,7 @@ class Nation : RulesetObject() { // This does not use the auto-linking FormattedLine(Unique) for two reasons: // would look a little chaotic as unit uniques unlike most uniques are a HashSet and thus do not preserve order // No .copy() factory on FormattedLine and no FormattedLine(Unique, all other val's) constructor either - if (unit.replacementTextForUniques.isNotEmpty()){ + if (unit.replacementTextForUniques.isNotEmpty()) { yield(FormattedLine(unit.replacementTextForUniques)) } else for (unique in unit.uniqueObjects.filterNot { it.text in originalUnit.uniques || it.hasFlag(UniqueFlag.HiddenToUsers) }) { diff --git a/desktop/src/com/unciv/app/desktop/UncivServer.kt b/desktop/src/com/unciv/app/desktop/UncivServer.kt index 0e17f8dd8a..aeac6f85b3 100644 --- a/desktop/src/com/unciv/app/desktop/UncivServer.kt +++ b/desktop/src/com/unciv/app/desktop/UncivServer.kt @@ -48,10 +48,10 @@ private class UncivServerRunner : CliktCommand() { put("/files/{fileName}") { val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!") withContext(Dispatchers.IO) { - val recievedBytes = - call.request.receiveChannel().toInputStream().readAllBytes() - val textString = String(recievedBytes) - println("Recieved text: $textString") + val receivedBytes = + call.request.receiveChannel().toInputStream().readBytes() + val textString = String(receivedBytes) + println("Received text: $textString") File(fileFolderName, fileName).writeText(textString) } }