Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MS Store recognition #137

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CommonLibSF/include/REL/ID.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ namespace REL
static IDDatabase _instance;
inline static std::atomic_bool _initialized{};
inline static std::mutex _initLock;
inline static bool _is_steam{};
database::memory_map _mmap;
std::span<database::mapping_t> _id2offset;
Platform _platform{ Platform::kUnknown };
Expand Down
19 changes: 8 additions & 11 deletions CommonLibSF/src/REL/ID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ namespace REL
namespace database
{
constexpr auto LookUpDir = "Data\\SFSE\\Plugins"sv;
constexpr std::array VendorModule{
std::make_pair("steam_api64"sv, IDDatabase::Platform::kSteam),
std::make_pair("Xcurl"sv, IDDatabase::Platform::kMsStore),
};

[[nodiscard]] std::uint64_t Offset2ID::operator()(std::size_t a_offset) const
{
Expand Down Expand Up @@ -173,11 +169,12 @@ namespace REL
file /= std::format("{}\\versionlib-{}", database::LookUpDir, version.string("-"));

_platform = Platform::kUnknown;
for (auto& [vendor, registered] : database::VendorModule) {
if (WinAPI::GetModuleHandle(vendor.data())) {
_platform = registered;
break;
}
if (WinAPI::GetModuleHandle(L"steam_api64")) {
_platform = Platform::kSteam;
_is_steam = true;
}
else {
_platform = Platform::kMsStore;
}

stl_assert(_platform != Platform::kUnknown,
Expand Down Expand Up @@ -254,10 +251,10 @@ namespace REL
"then it is likely that address library has not yet added support "
"for this version of the game or this platform.\n"
"Current version: {}\n"
"Current vendor module: {}"sv,
"Current platform: {}"sv,
stl::utf16_to_utf8(a_filename).value_or("<unknown filename>"s),
a_version.string(),
database::VendorModule[std::to_underlying(_platform)].first),
_is_steam ? "Steam" : "Microsoft Store"),
a_failOnError);
}
return true;
Expand Down