alexpado / hoyoverse-music-unpacker

Extract music from Hoyoverse's games. Support Genshin Impact, Honkai Star Rail and Honkai Impact
70 stars 7 forks source link

Game auto-detect based on path do not work with CN version #15

Closed jbwenjoy closed 5 months ago

jbwenjoy commented 9 months ago

Hi!

Thank you for this amazing tool. But on my computer, it says it cannot detect the game at the provided path.

My game launcher path is E:\Program Files\Star Rail. Here is the error message:

PS D:\Tool Box\hoyoverse-music-unpacker> java -jar hoyoverse-music-unpacker.jar --game="E:\Program Files\Star Rail"
Detecting game...
java.lang.IllegalStateException: Could not detect to which game the provided path belongs
        at ovh.akio.hmu.interfaces.HoyoverseGame.of(HoyoverseGame.java:31)
        at ovh.akio.hmu.Application.call(Application.java:85)
        at ovh.akio.hmu.Application.call(Application.java:21)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at ovh.akio.hmu.Application.main(Application.java:70)

Thanks again and hope to hear from you soon.

alexpado commented 9 months ago

Hi, Thanks for you report. Just to be sure about what is happening:

I tried on my end to replicate your issue (even having the tool running on another disk, just like you), and I get this output:

PS E:\IdeaProjects\hoyoverse-music-unpacker\build\libs> java -jar hoyoverse-music-unpacker.jar --game="D:\Games\Star Rail"
Detecting game...
  -- Detected Honkai Star Rail !
Removing previous files...
Starting unpacking...
     Unpacking 100% [============================] 33/33 (0:00:02 / 0:00:00) OK
    Extracting 100% [==========================] 410/410 (0:01:01 / 0:00:00) OK
jbwenjoy commented 9 months ago

Thank you so much.

I double checked the path:

Game: "E:\Program Files\Star Rail\Game\StarRail.exe" Launcher: "E:\Program Files\Star Rail\launcher.exe"

I used the admin mode power shell terminal and tried both

PS D:\Tool Box\gamehacktools\hoyoverse-music-unpacker> java -jar hoyoverse-music-unpacker.jar --game="E:\Program Files\Star Rail\Game"
Detecting game...
java.lang.IllegalStateException: Could not detect to which game the provided path belongs
        at ovh.akio.hmu.interfaces.HoyoverseGame.of(HoyoverseGame.java:31)
        at ovh.akio.hmu.Application.call(Application.java:85)
        at ovh.akio.hmu.Application.call(Application.java:21)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at ovh.akio.hmu.Application.main(Application.java:70)

PS D:\Tool Box\gamehacktools\hoyoverse-music-unpacker> java -jar hoyoverse-music-unpacker.jar --game="E:\Program Files\Star Rail"
Detecting game...
java.lang.IllegalStateException: Could not detect to which game the provided path belongs
        at ovh.akio.hmu.interfaces.HoyoverseGame.of(HoyoverseGame.java:31)
        at ovh.akio.hmu.Application.call(Application.java:85)
        at ovh.akio.hmu.Application.call(Application.java:21)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at ovh.akio.hmu.Application.main(Application.java:70)

I think there are some differences in file structure between the global version of Star Rail and the Mainland China version, which is the one running on my laptop.


I just looked into your code here: https://github.com/alexpado/hoyoverse-music-unpacker/blob/26c3def33861901a8c86102841accf1d314d46ac/src/main/java/ovh/akio/hmu/games/HonkaiStarRail.java

    @Override
    public File getGameDirectory() {

        return new File(this.basePath, "Games");
    }

    @Override
    public File getAudioDirectory() {

        return new File(this.getGameDirectory(), "StarRail_Data\\StreamingAssets\\Audio\\AudioPackage\\Windows");
    }

You append Games after the provided game path. However, in the mainland China version, this is Game instead, one letter difference, very interesting. I also checked the getAudioDirectory(). The path StarRail_Data\\StreamingAssets\\Audio\\AudioPackage\\Windows is the same, no need to change.

I think this is the only the reason as I add an "s" to my game folder and changed it back after completion, and your program ran perfectly well, without needing admin mode!

PS D:\Tool Box\gamehacktools\hoyoverse-music-unpacker> java -jar hoyoverse-music-unpacker.jar --game="E:\Program Files\Star Rail" --output="E:\星铁二创\解包"
Detecting game...
  -- Detected Honkai Star Rail !
Removing previous files...
Starting unpacking...
     Unpacking 100% [============================] 33/33 (0:00:05 / 0:00:00) OK
    Extracting 100% [==========================] 410/410 (0:00:45 / 0:00:00) OK
PS D:\Tool Box\gamehacktools\hoyoverse-music-unpacker>

Do you have any plans to fix this problem, i.e. enable the program to check if appending "Games" won't work, then try "Game"?

alexpado commented 8 months ago

I'm still struggling to understand why they would do different file structure between those two version, but hey, at least we know why this don't work now !

I'll probably just add a new class extending this one and just override getGameDirectory.

Do you have any CN version of other hoyo games ? Just to be sure for other game version.

I guess Honkai Impact has the same issue as my folder is also named "Games"...

jbwenjoy commented 8 months ago

Hi!

I just checked Genshin Impact. There are differences:

image

As you can see in the picture, in mainland CN version GenshinImpact.exe is changed to YuanShen.exe, GenshinImpact_Data is instead YuanShen_Data.

I only changed these two names as below and it also worked.

image

Currently I don't have Honkai 3rd installed. I guess the differences are identical.

alexpado commented 8 months ago

Thanks you. The difference between OS/CN version of genshin is wild!

The game detection should be fixed in cn-os-compatibility branch, if you could test it on your end and tell me if its working.

I hope there is no differences for pre-download packages too :(

jbwenjoy commented 8 months ago

I built this on my laptop and it worked, both for Genshin and Star Rail! Here's the output.

PS D:\Tool Box\gamehacktools\hoyoverse-music-unpacker-cn-os-compatibility\hoyoverse-music-unpacker-cn-os-compatibility\build\libs> java -jar hoyoverse-music-unpacker-1.3.0.jar --game="E:\Program Files\Genshin Impact" --output="E:\原神二创\解包"
Detecting game...
  -- Detected Genshin Impact (CN) !
Removing previous files...
Starting unpacking...
     Unpacking 100% [============================] 33/33 (0:00:14 / 0:00:00) OK
    Extracting 100% [========================] 1020/1020 (0:03:34 / 0:00:00) OK
PS D:\Tool Box\gamehacktools\hoyoverse-music-unpacker-cn-os-compatibility\hoyoverse-music-unpacker-cn-os-compatibility\build\libs> java -jar hoyoverse-music-unpacker.jar --game="E:\Program Files\Star Rail" --output="E:\星铁二创\解包"
Error: Unable to access jarfile hoyoverse-music-unpacker.jar
PS D:\Tool Box\gamehacktools\hoyoverse-music-unpacker-cn-os-compatibility\hoyoverse-music-unpacker-cn-os-compatibility\build\libs> java -jar hoyoverse-music-unpacker-1.3.0.jar --game="E:\Program Files\Star Rail" --output="E:\星铁二创\解包"
Detecting game...
  -- Detected Honkai Star Rail (CN) !
Removing previous files...
Starting unpacking...
     Unpacking 100% [============================] 33/33 (0:00:04 / 0:00:00) OK
    Extracting 100% [==========================] 410/410 (0:00:44 / 0:00:00) OK

Thank you so much! You may close this issue now, if you want :)

Maybe we can wait for the pre-download packages for the next version 😂

alexpado commented 8 months ago

I'll prefer to wait until next patch for each game. Is there a way for me to install the mainland CN versions of each game for testing purpose ?

jbwenjoy commented 8 months ago

Yes, you can visit mihoyo.com (the CN company of HOYOverse). But I think you’ll need to switch to the desktop version of the website and also change to simplified Chinese website, which is a little bit troublesome. I can provide the link for you later. (I’m with my ipad currently, and their website always automatically jumps to the mobile version. 😡

miHoYo Product: https://www.mihoyo.com/?page=product Genshin CN: https://ys.mihoyo.com/main/, PC download: https://ys-api.mihoyo.com/event/download_porter/link/ys_cn/official/pc_default Star Rail CN: https://sr.mihoyo.com/, PC download: https://api-takumi.mihoyo.com/event/download_porter/link/hkrpg_cn/official/pc_default HK3 CN: https://bh3.mihoyo.com/, PC download: https://bundle.bh3.com/ptpublic/rel/20231218151007_IxIBzTHqdJ2uMbVL/Bh3_release_2.31.0.0.exe

alexpado commented 8 months ago

Thank you very much for the links, I will install them asap so I will be able to test every update package pre-download. Once I confirm that all 3 games work I'll merge the branch and do a new release.