thpatch / thcrap

Touhou Community Reliant Automatic Patcher
https://www.thpatch.net
The Unlicense
551 stars 41 forks source link

th155/lang_zh-hans: Some Chinese characters missing #183

Closed xitieshiz2 closed 9 months ago

xitieshiz2 commented 2 years ago

Note : I do not have this issue on my own machine , but someone asked me about this.

It seems that someone would have character missing problem in th155 Chinese patch (With tpZHCNex/taso installed) There're two different people having this problem for now , so this should be a bug. image image log file here : https://gist.github.com/xitieshiz2/b7c1305f9b8306f1a66d4c7198c63f02 log file and file tree of the second person : https://gist.github.com/xitieshiz2/f11ba04dc11f799fcccd0f629b9f950b We already asked brliron about this , and got this answer : image But this does not work , the problem still exist (And those file just appear again when the game launch). We tried using th155 1.19_beta4 , using old thcrap command line configure tool , and even send my thcrap files , but none of them works.

brliron commented 2 years ago

Sorry for taking so much time to come back to you.

Can you tell your friend to put that file in the bin directory of their thcrap installation (replacing the existing one), run the game, and send me the log file? A few notes and warnings:

xitieshiz2 commented 1 year ago

here's the log file https://1drv.ms/u/s!AhNysW5VU31jiieuoPF7eTdL63gg?e=sNJMbT

xitieshiz2 commented 11 months ago

@brliron We found that this issue seems only happens when the game directory includes non-ASCII characters (like Chinese, Japnese etc.), can this information help you to solve this? Or is this issue from tpZHCNex/taso?

brliron commented 11 months ago

Hmm...

I don't really see how the game directory having non-ASCII characters would cause this issue (the game either loads the entire th155.dat, or doesn't load it at all). On the other hand, if the thcrap directory also has non-ASCII characters, we read files from many places and in many different ways, and one of them could have a bug.

If the thcrap directory contains non-ASCII characters, we call add_files_in_directory at https://github.com/thpatch/thcrap/blob/e3895c2ec8ec35f6b7d894fd9030f8da144073e5/thcrap_tasofro/src/th155_bmp_font.cpp#L185 with patch->archive, which should be a full UTF-8 path. This path is used to generate the filename passed to json_load_file in https://github.com/thpatch/thcrap/blob/e3895c2ec8ec35f6b7d894fd9030f8da144073e5/thcrap_tasofro/src/th155_bmp_font.cpp#L110C11-L110C11 . And in https://github.com/akheron/jansson/blob/60097f0096f337393b42d0ad13d403294ff4e782/src/load.c#L1042 , json_load_file will try to use this UTF-8 path as a parameter to fopen, which expects a path in the current locale. add_json_file would then receive a NULL file, which won't crash but won't do anything useful either.

And both log files attached with this issue have Chinese characters in the thcrap path as well.

Yeah, I think that's where this bug comes from. I'll have to test it this evening.

brliron commented 11 months ago

Fixed in ffda608 (which will be included in the next thcrap release)

brliron commented 11 months ago

And the next thcrap release have been released.

@xitieshiz2 Can you ask your friends if it works with the new thcrap version?