question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strange observation concerning UncivServer

See original GitHub issue

Platform You know I’m running Mint 20.3… This mentions running in the debugger, so Android Studio about says:

Android Studio Bumblebee | 2021.1.1 Patch 2
Build #AI-211.7628.21.2111.8193401, built on February 17, 2022
Runtime version: 11.0.11+0-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.13.0-37-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 8192M
Cores: 12
Registry: external.system.auto.import.disabled=true, ide.tooltip.initialDelay=590
Non-Bundled Plugins: org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), org.intellij.plugins.markdown (211.7142.37)
Current Desktop: X-Cinnamon

Gradle Java is: OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) Run Java is: OpenJDK Runtime Environment Temurin-16.0.2+7 (build 16.0.2+7)

Version Current master

Describe the bug I run the game in the Debugger as always, with unchanged run configuration. Large map, not huge, world wrap, max zoom setting = 2. One-click moves are off. Selecting a unit, selecting a destination, waiting for the move icon to show up and then clicking it takes around 6 (Six) seconds. Also, remember we have horrible kludges wrapping Char(Int) and Char.code calls (#6391, #6419, #6435).

Now remove UncivServer

as follows:

Index: build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/build.gradle.kts b/build.gradle.kts
--- a/build.gradle.kts	(revision 5ab44dd945af96a46e97e5a48e2ecec3f691c597)
+++ b/build.gradle.kts	(date 1648589933302)
@@ -70,13 +70,6 @@
         }
 
         "implementation"("com.github.MinnDevelopment:java-discord-rpc:v2.0.1")
-
-        // For server-side
-
-        "implementation"("io.ktor:ktor-server-core:1.6.8")
-        "implementation"("io.ktor:ktor-server-netty:1.6.8")
-        "implementation"("ch.qos.logback:logback-classic:1.2.5")
-        "implementation"("com.github.ajalt.clikt:clikt:3.4.0")
     }
 
 }
Index: core/src/com/unciv/ui/utils/KeyPressDispatcher.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/src/com/unciv/ui/utils/KeyPressDispatcher.kt b/core/src/com/unciv/ui/utils/KeyPressDispatcher.kt
--- a/core/src/com/unciv/ui/utils/KeyPressDispatcher.kt	(revision 5ab44dd945af96a46e97e5a48e2ecec3f691c597)
+++ b/core/src/com/unciv/ui/utils/KeyPressDispatcher.kt	(date 1648589410441)
@@ -64,14 +64,14 @@
         val UNKNOWN = KeyCharAndCode(Input.Keys.UNKNOWN)
 
         // Kludges because we got crashes: java.lang.NoSuchMethodError: 'int kotlin.CharCodeKt.access$getCode$p(char)'  
-        fun Char.toCode() =
-            try { code } catch (ex: Throwable) { null }
-                ?: try { @Suppress("DEPRECATION") toInt() } catch (ex: Throwable) { null }
-                ?: 0
-        fun Int.makeChar() =
-            try { Char(this) } catch (ex: Throwable) { null }
-                ?: try { toChar() } catch (ex: Throwable) { null }
-                ?: Char.MIN_VALUE
+        fun Char.toCode() = this.code
+//            try { code } catch (ex: Throwable) { null }
+//                ?: try { @Suppress("DEPRECATION") toInt() } catch (ex: Throwable) { null }
+//                ?: 0
+        fun Int.makeChar() = Char(this)
+//            try { Char(this) } catch (ex: Throwable) { null }
+//                ?: try { toChar() } catch (ex: Throwable) { null }
+//                ?: Char.MIN_VALUE
 
         /** mini-factory for control codes - case insensitive */
         fun ctrl(letter: Char) = KeyCharAndCode((letter.toCode() and 31).makeChar(),0)
Index: desktop/src/com/unciv/app/desktop/UncivServer.kt
===================================================================
diff --git a/desktop/src/com/unciv/app/desktop/UncivServer.kt b/desktop/src/com/unciv/app/desktop/UncivServer.kt
deleted file mode 100644
--- a/desktop/src/com/unciv/app/desktop/UncivServer.kt	(revision 5ab44dd945af96a46e97e5a48e2ecec3f691c597)
+++ /dev/null	(revision 5ab44dd945af96a46e97e5a48e2ecec3f691c597)
@@ -1,76 +0,0 @@
-package com.unciv.app.desktop
-
-import com.github.ajalt.clikt.core.CliktCommand
-import com.github.ajalt.clikt.parameters.options.default
-import com.github.ajalt.clikt.parameters.options.option
-import com.github.ajalt.clikt.parameters.types.int
-import com.github.ajalt.clikt.parameters.types.restrictTo
-import io.ktor.application.*
-import io.ktor.response.*
-import io.ktor.routing.*
-import io.ktor.server.engine.*
-import io.ktor.server.netty.*
-import io.ktor.utils.io.jvm.javaio.*
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.withContext
-import java.io.File
-
-
-internal object UncivServer {
-    @JvmStatic
-    fun main(args: Array<String>) = UncivServerRunner().main(args)
-}
-
-private class UncivServerRunner : CliktCommand() {
-    private val port by option(
-        "-p", "-port",
-        envvar = "UncivServerPort",
-        help = "Server port"
-    ).int().restrictTo(1024..49151).default(8080)
-
-    private val folder by option(
-        "-f", "-folder",
-        envvar = "UncivServerFolder",
-        help = "Multiplayer file's folder"
-    ).default("MultiplayerFiles")
-
-    override fun run() {
-        serverRun(port, folder)
-    }
-
-    private fun serverRun(serverPort: Int, fileFolderName: String) {
-        echo("Starting UncivServer for ${File(fileFolderName).absolutePath} on port $serverPort")
-        embeddedServer(Netty, port = serverPort) {
-            routing {
-                get("/isalive") {
-                    call.respondText("true")
-                }
-                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")
-                        File(fileFolderName, fileName).writeText(textString)
-                    }
-                }
-                get("/files/{fileName}") {
-                    val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!")
-                    println("Get file: $fileName")
-                    val file = File(fileFolderName, fileName)
-                    if (!file.exists()) throw Exception("File does not exist!")
-                    val fileText = file.readText()
-                    println("Text read: $fileText")
-                    call.respondText(fileText)
-                }
-                delete("/files/{fileName}") {
-                    val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!")
-                    val file = File(fileFolderName, fileName)
-                    if (!file.exists()) throw Exception("File does not exist!")
-                    file.delete()
-                }
-            }
-        }.start(wait = true)
-    }
-}
\ No newline at end of file
... then *Build/clean* and re-run debug. Moving a unit is as snappy as ever (limited by my body not the game). Also note the patch deactivates the Char kludges and ctrl-O, ctrl-L, ctrl-S work just fine.

I suspected loader/statics issues when that Char issue came up, but that removing the Server also speeds up my game is a surprise.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SomeTroglodytecommented, Apr 3, 2022

So no repro on Windoze. Fits the general impression that only Linux users had the Char crashes, too. The JRE it runs under is an 11 level as well, I assume. image

0reactions
GGGuennicommented, Apr 3, 2022

Just tested with a ‘desktop’ run config and doesn’t seem too slow as well. ~500ms each for selecting and move icon showing up when playing on huge world wrap. Normal when playing on large world wrap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make/join multiplayer game ? : r/Unciv - Reddit
First, find your respective Player IDs. In the Multiplayer Menu you can copy it to your clipboard. Then, someone needs to make a...
Read more >
Flathub—An app store and build service for Linux
A free offline maps app for travelers, tourists, hikers, and cyclists based on top of crowd-sourced OpenStreetMap data and curated with love by...
Read more >
Multiplayer - Unciv
Therefore, you can now host your own Unciv server on any computer that can run Java programs. This guide is written for people...
Read more >
Untitled
Common observation informs us that a taste for music, and a genius for poetry and painting, are gifts of nature bestowed only on...
Read more >
Regional Meeting on Student Behavior - AACP
information concerning any member of the University faculty, student body, ... responsibilities include developing schedules, monitoring the progress of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found