MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ExtractPatchInfo

Method ExtractPatchInfo

pcsx2/Patch.cpp:441–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439}
440
441void Patch::ExtractPatchInfo(std::vector<PatchInfo>* dst, const std::string& pnach_data, u32* num_unlabelled_patches)
442{
443 std::istringstream ss(pnach_data);
444 std::string line;
445 PatchInfo current_patch;
446
447 std::optional<patch_place_type> last_place;
448 bool unknown_place = false;
449
450 while (std::getline(ss, line))
451 {
452 TrimPatchLine(line);
453 if (line.empty())
454 continue;
455
456 const bool has_patch = !current_patch.name.empty();
457
458 if (line.length() > 2 && line.front() == '[' && line.back() == ']')
459 {
460 if (has_patch)
461 {
462 if (std::none_of(dst->begin(), dst->end(),
463 [&current_patch](const PatchInfo& pi) { return (pi.name == current_patch.name); }))
464 {
465 // Don't show patches with duplicate names, prefer the first loaded.
466 if (!ContainsPatchName(*dst, current_patch.name))
467 {
468 dst->push_back(std::move(current_patch));
469 }
470 else
471 {
472 Console.WriteLn(Color_Gray, fmt::format("Patch: Skipped reading patch '{}' since a patch with a duplicate name was already loaded.", current_patch.name));
473 }
474 }
475 current_patch = {};
476 }
477
478 current_patch.name = line.substr(1, line.length() - 2);
479 last_place = std::nullopt;
480 unknown_place = false;
481 continue;
482 }
483
484 std::string_view key, value;
485 StringUtil::ParseAssignmentString(line, &key, &value);
486
487 // Just ignore other directives, who knows what rubbish people have in here.
488 // Use comment for description if it hasn't been otherwise specified.
489 if (key == "author")
490 {
491 current_patch.author = value;
492 }
493 else if (key == "description")
494 {
495 current_patch.description = value;
496 }
497 else if (key == "comment" && current_patch.description.empty())
498 {

Callers

nothing calls this directly

Calls 13

ParseAssignmentStringFunction · 0.85
StripWhitespaceFunction · 0.85
substrMethod · 0.80
formatFunction · 0.50
emptyMethod · 0.45
lengthMethod · 0.45
frontMethod · 0.45
backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
WriteLnMethod · 0.45

Tested by

no test coverage detected