-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix resources extracted from pak_wii being unusable #139
Fix resources extracted from pak_wii being unusable #139
Conversation
tests to use pathlib
Here are several error logs that were found trying to run the following command : From @henriquegemignani :
From me :
Strange thing is, we are not getting the same errors despite running the same command. I made sure to pull from upstream before running it. As for my case, I've looked into why I'm getting such an error, so I've written |
By the looks of it, it seems like LZO is handled differently between Echoes and Corruption ; Corruption has some extra metadata ;
So far we've been using LZO blocks that were catered towards Echoes' compression, and not Corruption's, which would explain why the |
Created a specific LZO Segment class for Corruption's formats Still not decompressing though ;-;
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #139 +/- ##
==========================================
+ Coverage 68.57% 69.68% +1.10%
==========================================
Files 82 88 +6
Lines 5194 5564 +370
==========================================
+ Hits 3562 3877 +315
- Misses 1632 1687 +55 ☔ View full report in Codecov by Sentry. |
So I belive I've fixed parsing the compressed resources from paks, by creating a new LZOSegment class specifically for corruption ; Now, this wouldn't be as bad if it always was the same error, but no, that would be too easy :) So I've run some statistics and tried decompressing every single compressed resource in the game to see what error would present itself most often. The results are compiled within this csv : Reading the LZO documentation itself wasn't of much help for me, seeing as most of these exceptions just mean "data corrupted", it doesn't tell me what's wrong with it from an outsider perspective. Besides, if my data was truly corrupted, I don't think my game would even run with only 1% file integrity. Maybe we're not using the right compression level ? The retro modding wiki page for Prime 3 Paks specifies Corruption's files "are compressed with segmented LZO1X, just like Prime 2". While it is specified Echoes uses LZO1X-999, Corruption's compression level isn't explicitly stated, but not only does the phrasing imply it's also 999, I see no reason why Retro woul go for a lower compression level ? It's very unlikely that's actually the problem, but I don't really see any other way to explain the errors I've been getting. TLDR : I've hit a roadblock with decompressing some segments and cannot continue working on this PR if I can't find a way to explain the decompression errors. |
Where exactly are you getting errors? When parsing a pak? |
Parsing and Building as I've done them on the previous PR should still work as I've not modified them (the tests still pass) This would initially happen on |
Thanks to @henriquegemignani, we were able to fix all the errors that would occur during decompression. Turns out each block had to be treated as a whole Echoes resource
Now passes test_corruption_resource_encode_decode However, properly decompressing a resource with more than 1 compressed block still raises issues, only yielding the 1st block
Analyzed what exactly is wrong when decoding a compressed pak resource, more on that in the PR comments
So the adapter class that I was recommended to implement does seem to function as expected, as Initially looking at the stack trace, we can see that The real problem arises when parsing gets to the 2nd segment of the compressed resource ; parsing it yields empty bytes, which explains why only the 1st segment is returned, but also made me wonder why on earth was nothing returned ? Besides that, debugging revealed that So I feel it has become quite clear that this is an indexation issue, but now I wonder how I should fix it ? First thing that comes to mind is manually putting a different index for the segment index directly into the context, but this feels a bit hacky, and I'm not 100% certain this wouldn't break Echoes decompression as well. TL;DR : There is a problem with |
So after digging a little deeper into construct's code I've finally figured out why the context's index gets set back to 0 when parsing the second segment from the compressed resource put in for testing. That happens because of What I would do to solve this is implement another class inheriting from On another note, is this an issue worth bringing up on the Construct library's github ? I feel like |
does |
I had already tried Thanks a bunch, I'll push the fix once I make sure all the tests pass, though the code might be a little messy... but that's what reviews are for :) |
Oh I completely forgot to mention that I was wrapping the |
Removed many of the file/debug tests and implemented a child class for LZOCompressedBlock instead of using `if` statements in the existing class
So thanks to Dunc's advice, I believe I've managed to fix the decompression issue I've been having : the resources now seem to properly decompress regardless of whether they have 1 or 2 segments. However, trying to run the command that started this PR (
I'm fairly certain this is caused by the fact I had to wrap the |
try wrapping it in a |
And addressed most of the requested changes
Just gonna bump this real quick. I've moved |
We ran into problems trying to use resources that were extracted by pak_wii, causing RDS to raise exceptions