pmrowla / pylivemaker

Python package for manipulating LiveMaker game resources
https://pylivemaker.readthedocs.io/en/latest/
GNU General Public License v3.0
63 stars 16 forks source link

Failing to patch a translated lmpatch some.exe 00000001.lsb #134

Closed allrobot closed 6 months ago

allrobot commented 6 months ago

Description

I executed the command lmpatch stopping.exe 00000001.lsb on the already translated file 00000001.csv through a cmd command. However, after starting the game, I found that the text remained unchanged, still in the original language.

What I Did

F:\[Nighthawk]\ストッピング!!! 陸上競技編\game_files>lmlsb extractcsv --encoding=utf-8-sig 00000001.lsb 00000001.csv
Extracting 00000001.lsb ...
File 00000001.csv already exists. Please use --overwrite or --append option.

## translated 00000001.csv

F:\[Nighthawk]\ストッピング!!! 陸上競技編\game_files>lmlsb insertcsv --encoding=utf-8-sig 00000001.lsb 00000001.csv
Patching 00000001.lsb ...
  Translated 0 lines
  Failed to translate 0 lines
  Ignored 336 untranslated lines

F:\[Nighthawk]\ストッピング!!! 陸上競技編\game_files>move 00000001.lsb ..\00000001.lsb
moved         1 file。

F:\[Nighthawk]\ストッピング!!! 陸上競技編\game_files>cd ..

F:\[Nighthawk]\ストッピング!!! 陸上競技編>lmpatch stopping.exe 00000001.lsb
F:\[Nighthawk]\ストッピング!!! 陸上競技編\stopping.exe.bak already exists

F:\[Nighthawk]\ストッピング!!! 陸上競技編>

csv content:

ID,Label,Context,Original text,Translated text
pylm:text:00000001.lsb:8:0,00000003,,"この度は体験版をダウンロードしていただき\n誠にありがとうございます。",这次请下载体验版。\n非常感谢。
pylm:text:00000001.lsb:8:2,00000003,,街の図書館で勉学にいそしむ少女たちが、どんどん汚されていくさまを、お楽しみいただけます。,在城市图书馆勤奋学习的少女们,会被不断污染,让您尽情享受。

Afterwards, when I executed lmar x stopping.exe -o game_files, I found that the text in the extracted 00000001.lsp file remained unchanged, still in the original language. Why is that? Here is the download link for the game's main files: https://pixeldrain.com/u/tGZj5Ymd

translated file: 00000001.csv

pmrowla commented 6 months ago

It looks like there is something wrong with the formatting in your CSV, the insertcsv command is not modifying any lines:

  Translated 0 lines
  Failed to translate 0 lines
  Ignored 336 untranslated lines

At a quick glance, the issue is probably that for translated lines with a newline \n, you need to make sure they are quoted properly, your csv should be something like

ID,Label,Context,Original text,Translated text
pylm:text:00000001.lsb:8:0,00000003,,"この度は体験版をダウンロードしていただき\n誠にありがとうございます。","这次请下载体验版。\n非常感谢"。
pylm:text:00000001.lsb:8:2,00000003,,街の図書館で勉学にいそしむ少女たちが、どんどん汚されていくさまを、お楽しみいただけます。,在城市图书馆勤奋学习的少女们,会被不断污染,让您尽情享受。

(with quotes around your translation in the first text line like "这次请下载体验版。\n非常感谢"。)

pmrowla commented 6 months ago

Based on the linked discussion it looks like this isn't a pylm issue

allrobot commented 6 months ago

Indeed, it is not until the SExtract tool is used to replace with JIS fonts that pylivemaker can inject the translation.

Pylivemaker only supports JIS injection, not font injection in GBK encoding. Can you write GBK-encoded fonts in binary form? If binary writing is perhaps supported and the livemaker engine is launched with GBK encoding, the game will be able to display GBK text. I'm not sure if this applies to pylivemaker.

pmrowla commented 6 months ago

It's not a font issue, it's a text encoding issue. The LM engine is hard coded to only support Windows CP932 encoding (Microsoft's Shift-JIS codepage) which is why pylivemaker only allows CP932 text to be inserted into an LSB.

It is possible to patch (with a hex editor) the LM game exe to use a different hardcoded Windows codepage, for simplified Chinese you would use Windows CP936. From there you can modify the pylm code to also allow that codepage to be inserted. See this discussion for details: https://github.com/pmrowla/pylivemaker/issues/14#issuecomment-626230411

(This is not supported out of the box in pylm and not something I can help you with directly. It requires finding the correct byte offset to hexedit in your game's version of the engine exe, which may or may not be the same as the one in the linked issue)