Radfordhound / HedgeLib

A C++ library and collection of tools that aims to make modding games in the Sonic the Hedgehog franchise easier.
MIT License
88 stars 24 forks source link

Add PACx403 support. #72

Closed blueskythlikesclouds closed 3 years ago

blueskythlikesclouds commented 3 years ago

Turns out Puyo Puyo Tetris 2 runs on Hedgehog Engine 2 and introduces a new revision of the PAC format (PACx403). This adds support for it. It removes the chunks and compresses the entire data using zlib (without the header).

Not quite sure about the code quality & portability, so please review it.

(Note: It seems there's some extra data in the new version too, which seems to reference other PACs...? I notice file paths in them. It could be a dependency tree which makes other PACs load alongside the main one. That isn't handled in this PR.)

blueskythlikesclouds commented 3 years ago

I've done the changes requested. I have a question, though. The header is actually different in PACx403, it's simply missing the "chunk count" field. How should I go about implementing that?

(Also I realized I forgot to implement PACx403 in the Read method so I've done that as well.)

Radfordhound commented 3 years ago

Thank you! It all looks great

Tbh while it feels a little bad to copy-paste the whole struct just to remove one field, I honestly think that would be for the better to avoid confusion, especially for when we implement writing. The only problem then is: which struct do you use to check the version number?

Perhaps have three types: one for V402, one for V403, and one that acts as a "subset" that contains only fields present in all of the V4 revisions. In this case, it can just be a typedef for the V403 header struct like:

/* This type is a "subset" of all V4 revision headers. */
typedef HlPACxV403Header HlPACxV4Header;

We could replace this typedef with a full-on struct definition later on if a new revision comes out that makes it necessary.

This subset struct can be used to check the version number and to do things that aren't dependent on the revision.

ActualMandM commented 3 years ago

Seems like it does reference other pacs, as unpacking and repacking the same cutin pac ends up breaking how it looks.

2020-12-10_20-28-45_yuzu
Radfordhound commented 3 years ago

@ActualMandM Dang, that's interesting! Would you mind DMing me a few samples? I'd like to take a look at the pac referencing stuff skyth talked about.

ccateni commented 3 years ago

No matter what I do to repack the files, it keeps giving me an error with the reason being unknown.

blueskythlikesclouds commented 3 years ago

Sorry for the delay, I got sidetracked. It should be complete now (other than the dependency data).

@ccateni This version of HedgeLib++ does not support repacking yet.

Radfordhound commented 3 years ago

@ccateni My apologies. As Skyth said, this version doesn't support repacking just yet. I was going to fix that, but then my motherboard unexpectedly died and a lot of personal stuff happened so I haven't been able to. I'm getting a new one any day now, so I'll try to add that back in ASAP. It's a bit complicated though so might take a few weeks all-in-all. PPT2 will be a priority since that's new and to my knowledge has no tools yet.

@blueskythlikesclouds No worries man- sorry for the delay on my part as well.

Thanks for all of this; it looks great! I'll merge it.