patch_manager: Update cheat parsing for new VM
This commit is contained in:
parent
c6becfc9f5
commit
a0055192fe
2 changed files with 20 additions and 15 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
#include "core/loader/nso.h"
|
#include "core/loader/nso.h"
|
||||||
|
#include "core/memory/cheat_engine.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
@ -247,8 +248,9 @@ bool PatchManager::HasNSOPatch(const std::array<u8, 32>& build_id_) const {
|
||||||
return !CollectPatches(patch_dirs, build_id).empty();
|
return !CollectPatches(patch_dirs, build_id).empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<CheatList> ReadCheatFileFromFolder(const Core::System& system, u64 title_id,
|
namespace {
|
||||||
const std::array<u8, 0x20>& build_id_,
|
std::optional<std::vector<Memory::CheatEntry>> ReadCheatFileFromFolder(
|
||||||
|
const Core::System& system, u64 title_id, const std::array<u8, 0x20>& build_id_,
|
||||||
const VirtualDir& base_path, bool upper) {
|
const VirtualDir& base_path, bool upper) {
|
||||||
const auto build_id_raw = Common::HexToString(build_id_, upper);
|
const auto build_id_raw = Common::HexToString(build_id_, upper);
|
||||||
const auto build_id = build_id_raw.substr(0, sizeof(u64) * 2);
|
const auto build_id = build_id_raw.substr(0, sizeof(u64) * 2);
|
||||||
|
@ -267,12 +269,15 @@ static std::optional<CheatList> ReadCheatFileFromFolder(const Core::System& syst
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextCheatParser parser;
|
Memory::TextCheatParser parser;
|
||||||
return parser.Parse(system, data);
|
return parser.Parse(
|
||||||
|
system, std::string_view(reinterpret_cast<const char* const>(data.data()), data.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CheatList> PatchManager::CreateCheatList(const Core::System& system,
|
} // Anonymous namespace
|
||||||
const std::array<u8, 32>& build_id_) const {
|
|
||||||
|
std::vector<Memory::CheatEntry> PatchManager::CreateCheatList(
|
||||||
|
const Core::System& system, const std::array<u8, 32>& build_id_) const {
|
||||||
const auto load_dir =
|
const auto load_dir =
|
||||||
Core::System::GetInstance().GetFileSystemController().GetModificationLoadRoot(title_id);
|
Core::System::GetInstance().GetFileSystemController().GetModificationLoadRoot(title_id);
|
||||||
if (load_dir == nullptr) {
|
if (load_dir == nullptr) {
|
||||||
|
@ -284,20 +289,20 @@ std::vector<CheatList> PatchManager::CreateCheatList(const Core::System& system,
|
||||||
std::sort(patch_dirs.begin(), patch_dirs.end(),
|
std::sort(patch_dirs.begin(), patch_dirs.end(),
|
||||||
[](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); });
|
[](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); });
|
||||||
|
|
||||||
std::vector<CheatList> out;
|
std::vector<Memory::CheatEntry> out;
|
||||||
out.reserve(patch_dirs.size());
|
|
||||||
for (const auto& subdir : patch_dirs) {
|
for (const auto& subdir : patch_dirs) {
|
||||||
auto cheats_dir = subdir->GetSubdirectory("cheats");
|
auto cheats_dir = subdir->GetSubdirectory("cheats");
|
||||||
if (cheats_dir != nullptr) {
|
if (cheats_dir != nullptr) {
|
||||||
auto res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, true);
|
auto res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, true);
|
||||||
if (res.has_value()) {
|
if (res.has_value()) {
|
||||||
out.push_back(std::move(*res));
|
std::copy(res->begin(), res->end(), std::back_inserter(out));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, false);
|
res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, false);
|
||||||
if (res.has_value())
|
if (res.has_value()) {
|
||||||
out.push_back(std::move(*res));
|
std::copy(res->begin(), res->end(), std::back_inserter(out));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/file_sys/cheat_engine.h"
|
|
||||||
#include "core/file_sys/nca_metadata.h"
|
#include "core/file_sys/nca_metadata.h"
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
|
#include "core/memory/dmnt_cheat_types.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
|
@ -51,7 +51,7 @@ public:
|
||||||
bool HasNSOPatch(const std::array<u8, 0x20>& build_id) const;
|
bool HasNSOPatch(const std::array<u8, 0x20>& build_id) const;
|
||||||
|
|
||||||
// Creates a CheatList object with all
|
// Creates a CheatList object with all
|
||||||
std::vector<CheatList> CreateCheatList(const Core::System& system,
|
std::vector<Memory::CheatEntry> CreateCheatList(const Core::System& system,
|
||||||
const std::array<u8, 0x20>& build_id) const;
|
const std::array<u8, 0x20>& build_id) const;
|
||||||
|
|
||||||
// Currently tracked RomFS patches:
|
// Currently tracked RomFS patches:
|
||||||
|
|
Loading…
Reference in a new issue