diff --git a/src/common/ryujinx_compat.cpp b/src/common/ryujinx_compat.cpp index fe45644477..f0b935e74d 100644 --- a/src/common/ryujinx_compat.cpp +++ b/src/common/ryujinx_compat.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include namespace Common::FS { @@ -31,7 +31,6 @@ IMENReadResult ReadKvdb(const fs::path &path, std::vector &imens) { std::ifstream kvdb{path, std::ios::binary | std::ios::ate}; - // TODO: error codes if (!kvdb) { return IMENReadResult::Nonexistent; } @@ -66,21 +65,15 @@ IMENReadResult ReadKvdb(const fs::path &path, std::vector &imens) return IMENReadResult::NoImens; } - imens.resize(num_imens / 2); + imens.reserve(num_imens); // initially I wanted to do a struct, but imkvdb is 140 bytes // while the compiler will murder you if you try to align u64 to 4 bytes for (std::size_t i = 0; i < num_imens; ++i) { - char magic [4]; + char magic[4]; u64 title_id = 0; u64 save_id = 0; - // I have no idea why this is but we can basically just... ignore every other IMEN - if (i % 2 == 0) { - kvdb.ignore(IMEN_SIZE); - continue; - } - kvdb.read(magic, 4); if (std::memcmp(magic, IMEN_MAGIC, 4) != 0) { return IMENReadResult::InvalidMagic; @@ -92,9 +85,11 @@ IMENReadResult ReadKvdb(const fs::path &path, std::vector &imens) kvdb.read(reinterpret_cast(&save_id), 8); kvdb.ignore(0x38); - imens[i / 2] = IMEN{ title_id, save_id}; + imens.emplace_back(IMEN{title_id, save_id}); + fmt::println("TitleID: {:16X} SaveID: {:016X} length: {}", title_id, save_id, imens.size()); } return IMENReadResult::Success; } -} + +} // namespace Common::FS diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index fb4b4e109a..08c18d5295 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2919,9 +2919,13 @@ void GMainWindow::OnLinkToRyujinx(const u64& program_id) namespace fs = std::filesystem; u64 save_id = QtCommon::GetRyujinxSaveID(program_id); + if (save_id == (u64) -1) + return; fs::path ryu_dir = Common::FS::GetRyuSavePath(save_id); std::string user_id = GetProfileID(); + if (user_id.empty()) + return; std::string hex_program = fmt::format("{:016X}", program_id); fs::path eden_dir = FrontendCommon::DataManager::GetDataDir(FrontendCommon::DataManager::DataDir::Saves) / user_id / hex_program;