Browse Source

proper error handling, do not ignore every other

Signed-off-by: crueter <crueter@eden-emu.dev>
pull/2815/head
crueter 4 months ago
parent
commit
f3eecfd796
  1. 19
      src/common/ryujinx_compat.cpp
  2. 4
      src/yuzu/main.cpp

19
src/common/ryujinx_compat.cpp

@ -7,7 +7,7 @@
#include <cstring>
#include <fmt/ranges.h>
#include <fstream>
#include <iostream>
#include <algorithm>
namespace Common::FS {
@ -31,7 +31,6 @@ IMENReadResult ReadKvdb(const fs::path &path, std::vector<IMEN> &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<IMEN> &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<IMEN> &imens)
kvdb.read(reinterpret_cast<char *>(&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

4
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;

Loading…
Cancel
Save