-
Notifications
You must be signed in to change notification settings - Fork 165
Feat/wwise file location resolver hook #166
Feat/wwise file location resolver hook #166
Conversation
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. |
} | ||
|
||
std::optional<std::wstring> normalize_filename(const std::wstring path) { | ||
if (path.length() > 3 && path.substr(0, 4) == L"sd:/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be path.starts_with(...)
from C++20? I think ME2 is targeting C++20 nowadays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved per 8a857f8
|
||
using namespace spdlog; | ||
|
||
std::optional<fs::path> find_override_file(const fs::path game_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is identical to the code in archive_file_overrides.cpp
, right? If so I'd just move it to mod_loader_extension.cpp
and share the code between them to prevent losing some debugging time to slight drift in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per discussed in DMs I've removed the one in the wwise specific part and put a forward decl in the archive_file_overrides since the wwise_file_overrides.cpp
-> archive_file_overrides.h
dependency was already there
Should be resolved per b34fa30
} | ||
|
||
auto override_path_string = override.value().wstring(); | ||
return hooked_ak_file_location_resolver_open.original(p1, override_path_string.data(), 0, p4, p5, p6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make an AkOpenMode
enum reflecting the documentation up top just so it's obvious this 0
is Read
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved per fb2044a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of small comments, otherwise LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.