This commit is contained in:
Gliniak 2022-04-30 11:45:22 +02:00
parent d78fd19ab4
commit ccbb5a2ebf
2 changed files with 8 additions and 7 deletions

View File

@ -36,8 +36,7 @@ void PatchDB::LoadPatches() {
const std::filesystem::path patches_directory = patches_root_ / "patches";
const std::vector<xe::filesystem::FileInfo>& patch_files =
filesystem::ListFiles(patches_directory);
const std::regex file_name_regex_match =
std::regex("^[A-Fa-f0-9]{8}.*\\.patch\\.toml$");
const std::regex file_name_regex_match = std::regex(patch_filename_regex);
for (const xe::filesystem::FileInfo& patch_file : patch_files) {
// Skip files that doesn't have only title_id as name and .patch as
@ -150,7 +149,6 @@ bool PatchDB::ReadPatchData(
bool success = string_util::hex_string_to_array(data, value);
if (!success) {
XELOGE("PatchDB: Cannot load patch due to invalid data!");
return false;
}

View File

@ -110,8 +110,11 @@ class PatchDB {
std::vector<PatchFileEntry>& GetAllPatches() { return loaded_patches; }
private:
std::vector<PatchFileEntry> loaded_patches;
std::filesystem::path patches_root_;
void ReadHash(PatchFileEntry& patchEntry,
std::shared_ptr<cpptoml::table> patch_toml_fields);
inline static const std::string patch_filename_regex =
"^[A-Fa-f0-9]{8}.*\\.patch\\.toml$";
const std::map<std::string, PatchData> patch_data_types_size = {
{"string", PatchData(0, PatchDataType::string)},
@ -124,8 +127,8 @@ class PatchDB {
{"be16", PatchData(sizeof(uint16_t), PatchDataType::be16)},
{"be8", PatchData(sizeof(uint8_t), PatchDataType::be8)}};
void ReadHash(PatchFileEntry& patchEntry,
std::shared_ptr<cpptoml::table> patch_toml_fields);
std::vector<PatchFileEntry> loaded_patches;
std::filesystem::path patches_root_;
};
} // namespace patcher
} // namespace xe