yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.47k stars 1.57k forks source link

MOD Leader Mission 无法打开 #9468

Closed Hrin3 closed 1 year ago

Hrin3 commented 1 year ago

Platform: Desktop Version: 4.6.14-patch1 (Build 871) Rulesets: [Civ V - Gods & Kings, Leader Mission, Civ V - Vanilla, 5Hex Tileset] Last Screen: com.unciv.ui.screens.newgamescreen.NewGameScreen


OS: Windows 10 Java: Oracle Corporation 25.232-b09 Max Memory: 910 MB


Message:

java.lang.RuntimeException: Actor: TranslatedSelectBox
    at com.badlogic.gdx.scenes.scene2d.Actor.notify(Actor.java:192)
    at com.badlogic.gdx.scenes.scene2d.Actor.fire(Actor.java:152)
    at com.badlogic.gdx.scenes.scene2d.utils.Selection.fireChangeEvent(Selection.java:228)
    at com.badlogic.gdx.scenes.scene2d.ui.SelectBox$1.fireChangeEvent(SelectBox.java:71)
    at com.badlogic.gdx.scenes.scene2d.utils.Selection.choose(Selection.java:53)
    at com.badlogic.gdx.scenes.scene2d.utils.ArraySelection.choose(ArraySelection.java:24)
    at com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxScrollPane$1.clicked(SelectBox.java:448)
    at com.badlogic.gdx.scenes.scene2d.utils.ClickListener.touchUp(ClickListener.java:88)
    at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:71)
    at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:355)
    at com.unciv.ui.screens.basescreen.UncivStage.access$touchUp$s80204510(UncivStage.kt:17)
    at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:78)
    at com.unciv.ui.screens.basescreen.UncivStage$touchUp$1.invoke(UncivStage.kt:78)
    at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandling$1.invoke(CrashHandlingExtensions.kt:17)
    at com.unciv.ui.screens.basescreen.UncivStage.touchUp(UncivStage.kt:78)
    at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:70)
    at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:189)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:378)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:192)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:166)
    at com.unciv.app.desktop.DesktopLauncher.main(DesktopLauncher.kt:80)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: mods/Leader Mission/District鈥擲tudenicaMonastery.png
    at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:190)
    at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:101)
    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.load(TextureAtlas.java:87)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:80)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:76)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:71)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:61)
    at com.unciv.ui.images.ImageGetter.loadModAtlases(ImageGetter.kt:105)
    at com.unciv.ui.images.ImageGetter.setNewRuleset(ImageGetter.kt:81)
    at com.unciv.ui.screens.newgamescreen.GameOptionsTable.reloadRuleset(GameOptionsTable.kt:453)
    at com.unciv.ui.screens.newgamescreen.GameOptionsTable.onChooseMod(GameOptionsTable.kt:466)
    at com.unciv.ui.screens.newgamescreen.GameOptionsTable.access$onChooseMod(GameOptionsTable.kt:39)
    at com.unciv.ui.screens.newgamescreen.GameOptionsTable$addBaseRulesetSelectBox$1.invoke(GameOptionsTable.kt:383)
    at com.unciv.ui.screens.newgamescreen.GameOptionsTable$addBaseRulesetSelectBox$1.invoke(GameOptionsTable.kt:365)
    at com.unciv.ui.screens.newgamescreen.GameOptionsTable$addSelectBox$1.invoke(GameOptionsTable.kt:349)
    at com.unciv.ui.screens.newgamescreen.GameOptionsTable$addSelectBox$1.invoke(GameOptionsTable.kt:348)
    at com.unciv.ui.components.extensions.OnChangeListener.changed(Scene2dExtensions.kt:341)
    at com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.handle(ChangeListener.java:28)
    at com.badlogic.gdx.scenes.scene2d.Actor.notify(Actor.java:188)
    ... 20 more
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: mods\Leader Mission\District鈥擲tudenicaMonastery.png (Local)
    at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:142)
    at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:228)
    at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:187)
    ... 39 more
Jiangeshi commented 1 year ago

I'm very sorry, but Leader Mission mod currently does not support the desktop version. I will focus on resolving this issue.

yairm210 commented 1 year ago

It looks like the atlas doesn't match the packed image...? So just need to delete both of them and run on Desktop to rebuild them

SomeTroglodyte commented 1 year ago

@Jiangeshi - not OP

So - what happens is there's symbols outside iso-8859-* in image names, and the loadModAtlases function has an encoding mismatch when going to disk...

Excerpt from the atlas file: ``` Grave.png BuildingIcons/Grave rotate: false xy: 0,0 size: 50, 50 orig: 50, 50 offset: 0, 0 index: -1 District—StudenicaMonastery.png BuildingIcons/District—Studenica Monastery rotate: false xy: 0,0 size: 50, 50 orig: 50, 50 offset: 0, 0 index: -1 Fair.png BuildingIcons/Fair rotate: false xy: 0,0 size: 50, 50 orig: 50, 50 offset: 0, 0 index: -1 ```

Aha. Now I'm stunned. Really. Packing atlas bypassing the raison-d'être of an atlas. The map just mapping every single image as its own texture, no packing at all - almost.

But - use of an external atlas tool proven.

But I can load and start that mod: ![image](https://github.com/yairm210/Unciv/assets/63000004/388c4f64-2fb3-4b07-967e-ac1f1cd6ae7f)

... so it may be an OS thing, even just between desktop platforms.

The atlas loader (which is Gdx, not ours) is unable to autodetect an encoding for an atlas file, UTF-8 with BOM or any UCS-16 will simply crash with the exact same stacktrace. So - which encoding within an atlas file does it support? JavaDoc doesn't say, but it uses BufferedReader(InputStreamReader(packFile.read()).readLine() without explicitly specifying an encoding - and those are java.io. - a little search turns up nice things like "Java design bug", "The only safe and sane thing to do is to consider all other constructors deprecated, because they cannot be trusted to behave." - meaning not explicitly passing a CharsetDecoder argument to a stream constructor, which is what Gdx does -not.

TLDR: Unciv does not support atlas files it didn't build itself - or more specifically - Unciv does not support atlas files using UTF-8 codepoints outside the ASCII range. We could, by not using the TextureAtlasData(FileHandle) constructor, essentially rewriting a large part of Gdx.

SomeTroglodyte commented 1 year ago

delete both of them and run on Desktop to rebuild them

Yes, maybe, but in light of the above - good chances, but if that works then transporting the result to another platform will break again. Also, deleting .atlas is enough :laughing:

SomeTroglodyte commented 1 year ago

@Hrin3 - do you know what encoding your Java might default to? It's not UTF-8 or that mod should work. I'd like to test an approach, but can't trip the exception without setting mine to that same encoding.

On the other hand, if you can run the jar with additional manual command line parameters, try -Dfile.encoding=UTF-8. If that solves works around the mod error, would be interesting to know.

Alvin201777 commented 1 year ago

Leader Mission failed at the start.

Jiangeshi commented 1 year ago

After a day of hard work, it has finally been resolved that LM mod can now play on the desktop version

HydrolienF commented 1 year ago

It is caused by Java 1.8 using OS encoding. It may be fix in libgdx https://github.com/libgdx/libgdx/issues/7155

To fix it in Unciv, you can add -Dfile.encoding=UTF8 for Unciv-Windows64.zip release, but it migth break other mod that where providing OS specific file. Else you can update Java version provided in Unciv-Windows64.zip to Java 18 (or more).

Anyway it won't fix it for people that launch from Unciv.jar.

yairm210 commented 1 year ago

We forgot to close this way back when, but it's my understanding that the problem was resolved on the mod's end If that is incorrect and there is still work to do on our end, please notify me