diff --git a/src/client/game/game.cpp b/src/client/game/game.cpp index 18ca63bf..0fb8f24a 100644 --- a/src/client/game/game.cpp +++ b/src/client/game/game.cpp @@ -2,6 +2,8 @@ #include "game.hpp" +#include + namespace game { namespace @@ -34,4 +36,26 @@ namespace game static const auto server = get_host_library().get_optional_header()->CheckSum == 0x14C28B4; return server; } + + std::filesystem::path get_appdata_path() + { + static const auto appdata_path = [] + { + PWSTR path; + if (FAILED(SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &path))) + { + throw std::runtime_error("Failed to read APPDATA path!"); + } + + auto _ = utils::finally([&path] + { + CoTaskMemFree(path); + }); + + static auto appdata = std::filesystem::path(path) / "boiii"; + return appdata; + }(); + + return appdata_path; + } } diff --git a/src/client/game/game.hpp b/src/client/game/game.hpp index 02e6fa59..2a825538 100644 --- a/src/client/game/game.hpp +++ b/src/client/game/game.hpp @@ -73,6 +73,8 @@ namespace game size_t address_{}; size_t server_address_{}; }; + + std::filesystem::path get_appdata_path(); } inline size_t operator"" _g(const size_t val)