Closed vswarte closed 8 months ago
I managed to recover the link for the IAKFileLocationResolver::Open from browser history: https://www.audiokinetic.com/en/library/2021.1.14_8108/?source=SDK&id=class_a_k_1_1_stream_mgr_1_1_i_ak_file_location_resolver_abc328bc9dcf4120e8a0f427e287335e5.html#abc328bc9dcf4120e8a0f427e287335e5
We're hooking a FromSoft provided implementation of this interface if I'm not mistaking. Since the API is defined by Wwise itself I don't think this code is very likely to change in a significant manner for either of the two games. Although it seems this function has been scrapped in favor of something else in edge builds of AK/Wwise so upcoming games might need a different strategy.
This PR makes ME2 also facilitate wwise bnk replacements for Elden Ring (tested v1.10.0) and AC6 (tested 1.03.1 through 10.5.0).
It does so by pattern matching for a function in the games that seems responsible for providing either an EblFileOperator or a plain disk-backed FileOperator implementation. If a file operator implementation is requested for a bnk this hook asserts if there is a replacement file and will swap the EblFileOperator for the disk-backed one.
There is a lot to be said about the replacement detection. It's messy, it's bad and it's a lot of hand-wavy code that relies on the convention of FromSoftware developers. There is nothing I can think of to improve this and I'm open for suggestions.
I also feel like it's inefficient to always be doing a full set of filesystem lookups but it seems the hooked functions are called infrequently enough to not cause a significant performance hit.