X-Hax / sa2-mod-loader

Sonic Adventure 2 PC Mod Loader
47 stars 16 forks source link

SA2 PC: ReplaceFile function doesn't work with .pak texture files #10

Closed End-User-Person closed 4 years ago

End-User-Person commented 4 years ago

Attempting to replace a .pak texture file using the ReplaceFile function via code results in one of two outcomes: Either the game crashes upon attempting to load the affected textures, or the .pak replacement is ignored entirely.

Whenever a .pak file already exists somewhere, either in the game itself or via enabled mods, setting a function to replace the file and its .prs equivalent is necessary for any changes to take effect, though the game will only recognize the .prs texture file. Having the replacement .pak texture file in its appropriate location will crash the game with this message:

Microsoft Visual C++ Runtime Library

Runtime Error!

Program: [path to sonic2app.exe]

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Replacing event cutscene textures produces the second outcome, though the process of setting the function to replace the .pak and .prs versions of the files is still required, even if there is no .pak file in the game's directory or other mods.

MainMemory commented 4 years ago

Wrong repo.

MainMemory commented 4 years ago

I did a simple test where I renamed sonictex.pak in a mod to sonictex2.pak and then used the ReplaceFiles section in mod.ini to redirect the file, and it worked fine, so I'm really not sure what's going wrong here.

MainMemory commented 4 years ago

As it turns out, there is no problem with the mod loader being able to replace .pak files. The problem, as it were, is that the mod loader only replaces the path used to load the file, not the filename string used to access the data inside said file, which expects the original file name instead of the replaced one. If you save the .pak with the file's original name and then rename it, it loads fine, at the cost of needing to rename it again before being able to edit it.