Skip to content

Commit

Permalink
fix: MS Store recognition (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee authored Oct 3, 2023
1 parent d6339fb commit 6130cb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
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

0 comments on commit 6130cb4

Please sign in to comment.