CensoredUsername / unrpyc

A ren'py script decompiler
Other
861 stars 157 forks source link

un.rpyc (1.0.8) fails to load with Ren'py 7.0.0 games that have more than a thousand script files. #74

Closed OrdosAlpha closed 5 years ago

OrdosAlpha commented 6 years ago

Tried decompiling the .rpyc files of several games compiled using Ren'Py 7.0, and un.rpyc fails to load. Works perfectly with games compiled with Ren'Py 6.99.14.3 and older.

Included the tracebacks for two of the games I've tried:- "Full traceback: File "F:\Renpy\Summertime Saga 0.16\renpy\bootstrap.py", line 306, in bootstrap renpy.main.main() File "F:\Renpy\Summertime Saga 0.16\renpy\main.py", line 375, in main renpy.game.script.load_script() # sets renpy.game.script. File "F:\Renpy\Summertime Saga 0.16\renpy\script.py", line 266, in load_script self.load_appropriate_file(".rpyc", ".rpy", dir, fn, initcode) File "F:\Renpy\Summertime Saga 0.16\renpy\script.py", line 749, in load_appropriate_file raise Exception("Could not load file %s." % lastfn) Exception: Could not load file F:\Renpy\Summertime Saga 0.16/game/un.rpyc.

Windows-7-6.1.7601-SP1 Ren'Py 7.0.0.196 SummertimeSaga 0.16.0 Fri Jul 27 01:16:02 2018"

"Full traceback: File "F:\Renpy\A Town Uncovered 0.19b\renpy\bootstrap.py", line 306, in bootstrap renpy.main.main() File "F:\Renpy\A Town Uncovered 0.19b\renpy\main.py", line 357, in main renpy.game.script.load_script() # sets renpy.game.script. File "F:\Renpy\A Town Uncovered 0.19b\renpy\script.py", line 266, in load_script self.load_appropriate_file(".rpyc", ".rpy", dir, fn, initcode) File "F:\Renpy\A Town Uncovered 0.19b\renpy\script.py", line 749, in load_appropriate_file raise Exception("Could not load file %s." % lastfn) Exception: Could not load file F:\Renpy\A Town Uncovered 0.19b/game/un.rpyc.

Windows-7-6.1.7601-SP1 Ren'Py 7.0.0.196

Fri Jul 27 01:17:59 2018"

CensoredUsername commented 6 years ago

That's odd. I can't find a recent change in ren'py that woud cause this to happen. I'll try to investigate.

PMiley commented 6 years ago

I had this issue with Summertime Saga 0.16.0 and 0.16.1 but not A Town Uncovered 0.19b. I did notice that Summertime Saga adds several additional Python libraries. summertime libraries

annhwi commented 6 years ago

pretty much the same story here w/ Summertime Saga 16.1. Unpacking the .rpa files w/ unren is no issue... but traceback is virtually identical for the un.rpyc.

traceback.txt

johngary1951 commented 5 years ago

Get the new version of UnRen.bat here https://f95zone.com/threads/unren-bat-v0-7-rpa-extractor-rpyc-decompiler-console-developer-menu-enabler.3083/

davidosky101 commented 5 years ago

this is a modification of un.rpyc (1.0.8) where they fixed the error you mention, unfortunately they couldn't fix it to work with renpy 7 and the new layered image system, hopefully the author can fix it. UnRen-v0.7.zip

CensoredUsername commented 5 years ago

First of all, UnRen does not use the un.rpyc file.

Second, it doesn't fix the mentioned error, it just uses a modification of normal unrpyc that purely removes multiprocessing support so it can be ran using ren'py's python executable instead of using python installed on the system.

Third, UnRen violates the license of this project (it does not include the license disclaimer anywhere as is required) so I'm not too keen on people mentioning it here. Especially since it is little more than a repackage of unrpyc and rpatool.

Since it doesn't fix the error I'll mark advertisements of it as spam until they fix the license issue.

CensoredUsername commented 5 years ago

@OrdosAlpha I've found one possible source of the bug and fixed it. Could you check if your problems are resolved?

srk68 commented 5 years ago

Hi,

first of all, thanks for this useful tool. However, since I also experience this problem, I would like to pick up here. I downloaded un.rpyc v1.0.9 and tried to decompile a file containing a "layered image" from game Summertime Saga v0.17.5. It failed as before, with just the line "layered image [name]:"

No errors were given in the log. Is there something I can do to help narrowing this?

CensoredUsername commented 5 years ago

@skr68 that's a different bug, that's just that layered images aren't supported yet in decompilation.

srk68 commented 5 years ago

"aren't supported yet"

That gives hope! Thanks for the feedback ;)

Edit: should have posted this here: https://github.com/CensoredUsername/unrpyc/issues/73

CensoredUsername commented 5 years ago

@srk68 Should be supported now.

And as I've gotten no further info I'm closing this issue as I cannot reproduce it myself.

srk68 commented 5 years ago

Hi,

I don't know if a closed issue can be re-opened. But I just tested Summertime Saga with the new 1.0.11 version of un.rpyc, and the error as mentioned in the initial post is still there.

I remember there was a workaround for such problems in the past: deleting the locations and minigames folder in the game\scripts folder before running un.rpyc. I did that and it worked, of course without the deleted folders. I then restored those folders, started the game (with un.rpyc) again, and finally it managed to decompile everything.

Maybe this information helps?

CensoredUsername commented 5 years ago

@srk68 I'll reopen it then, as I was unable to reproduce it myself but with extra info we should be able to fix that.

It working when some files are not present is definitely odd. If the traceback you got matched the one in the initial post, that's usually caused by an error in loading the decompiler before any decompilation even happens. Debugging this is quite messy unfortunately.

Could you confirm if it's a specific file in those folders that causes it? By e.g. removing half the files in those folders and seeing if it still works or not, then of that half that causes it to stop remove a quarter etc. ?

I'll meanwhile create a debug un.rpyc file that basically prints as much information to log.txt as possible so we can figure out where the loading process fails. If that doesn't work some tinkering in ren'py will be required to find out where it is failing unfortunately. Bootstrapping a decompiler from inside a script file is a bit of an interesting process.

srk68 commented 5 years ago

Hi!

I just checked and it is the same traceback as in the first post (apart from path names and dates).

I tried narrowing the problem down, but it appears that it is not a specific file or folder that needs to be removed:

I first deleted half the folders under game\scripts\locations, and it failed to decompile. I restored the folders and deleted the other half, again it failed.

Then I deleted one folder after another until it succeeded. But the last folder I deleted was not the problem because when I restored it and deleted all the other folders, everything went well (which was to be expected because everything goes well, too, when I restore all deleted folders after the first decompilation went through for the rest, as I described before).

So, basically, it can decompile everything, but not everything together in one pass.

Edit: Where can I find that debug un.rpyc?

CensoredUsername commented 5 years ago

@srk68 here you go. It does nothing special except for printing a bunch of stuff to the game's log.txt. If you could forward any output in log.txt, unrpyc.log.txt, or other log files with information on the crash to me I'd be very thankful.

srk68 commented 5 years ago

Hi,

I just tried with version 0.17.1 of the game and received the same error. Please find the log file attached.

log.zip

srk68 commented 5 years ago

Hi again,

I think I figured out what the problem was....

I first created decompiled the RPA files with rpatool to get all the RPYC and PNG files, then (to save space) I deleted the RPA files. Only after this I put un.rpyc into the game directory to decompile the RPYC files. This fails as described above.

I was not aware that it is not necessary to create the RPYC files before. If I just start the game with un.rpyc without prior rpatool, it manages to create the RPY files from the RPA files directly. But it will fail if all the RPYC files exist when running un.rpyc.

CensoredUsername commented 5 years ago

@srk68

Question: since you mention deleting the script folder before decompiling, did you run any tools before running un.rpyc to extract the script files from the archives?

edit: am able to reproduce it now by first extracting the rpyc files from the archive. Oddly enough this seems to error out while straight extracting from the .rpa files doesn't.

CensoredUsername commented 5 years ago

I've found the issue: apparently those games simply have more script files than file handles the OS support. I wasn't noticing it as this issue is only encountered if you use un.rpyc after extracting the script files from the archives manually. It should be fixed now.

srk68 commented 5 years ago

OK, tested with un.rpyc v1.0.12, works perfectly now!

Thanks!