arcusmaximus / KirikiriTools

Tools for the Kirikiri visual novel engine
MIT License
291 stars 29 forks source link

Path collisions when extracting archives #20

Open yescallop opened 1 year ago

yescallop commented 1 year ago

I have noticed that in Atri -My Dear Moments- at least two pairs of storage media resources exist with the same paths:

psb://quickmenu.pimg/1711.tlg ~ psb://submenu.pimg/1711.tlg
psb://quickmenu.pimg/1717.tlg ~ psb://submenu.pimg/1717.tlg

This has caused a problem that only one resource will be used for the two resources in each pair. One menu button is thus seen to be improperly rendered:

image

On the other hand, the README of this project says that

Specifically, these features are available if DebugView shows a message such as "Hooking storage media 'arc'" when the game starts up (this doesn't apply to the media "psb").

These seem have brought up two questions:

  1. Are we to hook the storage media "psb" at all? Should there be a blacklist or a whitelist for the media names?
  2. Are path collisions also possible for .xp3 archives? Should we adjust the extraction procedure so that files from different archives are placed in separate directories?
arcusmaximus commented 1 year ago

The 1711.tlg and 1717.tlg are not present as loose files inside the .xp3s. Instead, they're entries inside the .pimg files, which can usually be found in the "uipsd" folder of data.xp3.

As you can guess, each .pimg file contains a set of related UI images. (The "psd" in "uipsd" is a reference to Photoshop: the graphics designer first creates a .psd file with the different UI elements and button states in different layers, then converts it to a .pimg file using a custom tool.)

The note in the README is meant to point out that, if all you see is a "psb" storage media, the game doesn't use custom storage media as a defense mechanism and the tool's extraction feature doesn't apply (because you can use GARbro or KrkrExtract instead).

To answer your questions:

  1. The "psb" storage media can be skipped during hooking because it's not related to encryption and exposes files that don't exist as such in the .xp3 archives. You would instead get the .pimg files from the "arc" storage media.
  2. Path collisions between different .xp3s are very much possible. Which .xp3 takes precedence depends on the order in which the game registers them. This mechanism allows developers to, say, release a small patch.xp3 containing updated scenario files that override the originals at runtime. For this particular case, though, no such conflict exists as explained above - and if a conflict did exist, we'd probably never find out (the game would only retrieve the latest version from the custom storage media).