Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 27, 2024
2 parents 2e5c6b3 + 5479ab1 commit a8a7d08
Show file tree
Hide file tree
Showing 40 changed files with 160,406 additions and 99,339 deletions.
6,536 changes: 4,070 additions & 2,466 deletions pcsx2-qt/Translations/pcsx2-qt_af-ZA.ts

Large diffs are not rendered by default.

6,738 changes: 4,171 additions & 2,567 deletions pcsx2-qt/Translations/pcsx2-qt_ar-SA.ts

Large diffs are not rendered by default.

6,528 changes: 4,066 additions & 2,462 deletions pcsx2-qt/Translations/pcsx2-qt_bg-BG.ts

Large diffs are not rendered by default.

11,877 changes: 6,740 additions & 5,137 deletions pcsx2-qt/Translations/pcsx2-qt_ca-ES.ts

Large diffs are not rendered by default.

7,036 changes: 4,320 additions & 2,716 deletions pcsx2-qt/Translations/pcsx2-qt_cs-CZ.ts

Large diffs are not rendered by default.

6,528 changes: 4,066 additions & 2,462 deletions pcsx2-qt/Translations/pcsx2-qt_da-DK.ts

Large diffs are not rendered by default.

6,688 changes: 4,146 additions & 2,542 deletions pcsx2-qt/Translations/pcsx2-qt_de-DE.ts

Large diffs are not rendered by default.

6,574 changes: 4,089 additions & 2,485 deletions pcsx2-qt/Translations/pcsx2-qt_el-GR.ts

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pcsx2-qt/Translations/pcsx2-qt_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17158,12 +17158,12 @@ Ejecting {3} and replacing it with {2}.</source>
<context>
<name>Patch</name>
<message>
<location filename="../../pcsx2/Patch.cpp" line="342"/>
<location filename="../../pcsx2/Patch.cpp" line="348"/>
<source>Failed to open {}. Built-in game patches are not available.</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<location filename="../../pcsx2/Patch.cpp" line="698"/>
<location filename="../../pcsx2/Patch.cpp" line="710"/>
<source>%n GameDB patches are active.</source>
<comment>OSD Message</comment>
<translation type="unfinished">
Expand All @@ -17172,7 +17172,7 @@ Ejecting {3} and replacing it with {2}.</source>
</translation>
</message>
<message numerus="yes">
<location filename="../../pcsx2/Patch.cpp" line="705"/>
<location filename="../../pcsx2/Patch.cpp" line="717"/>
<source>%n game patches are active.</source>
<comment>OSD Message</comment>
<translation type="unfinished">
Expand All @@ -17181,7 +17181,7 @@ Ejecting {3} and replacing it with {2}.</source>
</translation>
</message>
<message numerus="yes">
<location filename="../../pcsx2/Patch.cpp" line="712"/>
<location filename="../../pcsx2/Patch.cpp" line="724"/>
<source>%n cheat patches are active.</source>
<comment>OSD Message</comment>
<translation type="unfinished">
Expand All @@ -17190,7 +17190,7 @@ Ejecting {3} and replacing it with {2}.</source>
</translation>
</message>
<message>
<location filename="../../pcsx2/Patch.cpp" line="727"/>
<location filename="../../pcsx2/Patch.cpp" line="739"/>
<source>No cheats or patches (widescreen, compatibility or others) are found / enabled.</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6,651 changes: 4,127 additions & 2,524 deletions pcsx2-qt/Translations/pcsx2-qt_es-419.ts

Large diffs are not rendered by default.

6,592 changes: 4,098 additions & 2,494 deletions pcsx2-qt/Translations/pcsx2-qt_es-ES.ts

Large diffs are not rendered by default.

6,690 changes: 4,147 additions & 2,543 deletions pcsx2-qt/Translations/pcsx2-qt_fa-IR.ts

Large diffs are not rendered by default.

8,374 changes: 4,989 additions & 3,385 deletions pcsx2-qt/Translations/pcsx2-qt_fi-FI.ts

Large diffs are not rendered by default.

6,654 changes: 4,129 additions & 2,525 deletions pcsx2-qt/Translations/pcsx2-qt_fr-FR.ts

Large diffs are not rendered by default.

6,558 changes: 4,081 additions & 2,477 deletions pcsx2-qt/Translations/pcsx2-qt_he-IL.ts

Large diffs are not rendered by default.

6,530 changes: 4,067 additions & 2,463 deletions pcsx2-qt/Translations/pcsx2-qt_hi-IN.ts

Large diffs are not rendered by default.

6,656 changes: 4,130 additions & 2,526 deletions pcsx2-qt/Translations/pcsx2-qt_hr-HR.ts

Large diffs are not rendered by default.

7,113 changes: 4,360 additions & 2,753 deletions pcsx2-qt/Translations/pcsx2-qt_hu-HU.ts

Large diffs are not rendered by default.

6,815 changes: 4,210 additions & 2,605 deletions pcsx2-qt/Translations/pcsx2-qt_id-ID.ts

Large diffs are not rendered by default.

6,539 changes: 4,071 additions & 2,468 deletions pcsx2-qt/Translations/pcsx2-qt_it-IT.ts

Large diffs are not rendered by default.

6,616 changes: 4,110 additions & 2,506 deletions pcsx2-qt/Translations/pcsx2-qt_ja-JP.ts

Large diffs are not rendered by default.

6,530 changes: 4,067 additions & 2,463 deletions pcsx2-qt/Translations/pcsx2-qt_ka-GE.ts

Large diffs are not rendered by default.

6,602 changes: 4,103 additions & 2,499 deletions pcsx2-qt/Translations/pcsx2-qt_ko-KR.ts

Large diffs are not rendered by default.

6,726 changes: 4,165 additions & 2,561 deletions pcsx2-qt/Translations/pcsx2-qt_lt-LT.ts

Large diffs are not rendered by default.

6,528 changes: 4,066 additions & 2,462 deletions pcsx2-qt/Translations/pcsx2-qt_lv-LV.ts

Large diffs are not rendered by default.

6,536 changes: 4,070 additions & 2,466 deletions pcsx2-qt/Translations/pcsx2-qt_nl-NL.ts

Large diffs are not rendered by default.

6,562 changes: 4,083 additions & 2,479 deletions pcsx2-qt/Translations/pcsx2-qt_no-NO.ts

Large diffs are not rendered by default.

6,550 changes: 4,077 additions & 2,473 deletions pcsx2-qt/Translations/pcsx2-qt_pl-PL.ts

Large diffs are not rendered by default.

6,962 changes: 4,283 additions & 2,679 deletions pcsx2-qt/Translations/pcsx2-qt_pt-BR.ts

Large diffs are not rendered by default.

7,048 changes: 4,326 additions & 2,722 deletions pcsx2-qt/Translations/pcsx2-qt_pt-PT.ts

Large diffs are not rendered by default.

6,528 changes: 4,066 additions & 2,462 deletions pcsx2-qt/Translations/pcsx2-qt_ro-RO.ts

Large diffs are not rendered by default.

6,640 changes: 4,122 additions & 2,518 deletions pcsx2-qt/Translations/pcsx2-qt_ru-RU.ts

Large diffs are not rendered by default.

6,528 changes: 4,066 additions & 2,462 deletions pcsx2-qt/Translations/pcsx2-qt_sr-SP.ts

Large diffs are not rendered by default.

6,536 changes: 4,070 additions & 2,466 deletions pcsx2-qt/Translations/pcsx2-qt_sv-SE.ts

Large diffs are not rendered by default.

6,572 changes: 4,088 additions & 2,484 deletions pcsx2-qt/Translations/pcsx2-qt_tr-TR.ts

Large diffs are not rendered by default.

6,698 changes: 4,151 additions & 2,547 deletions pcsx2-qt/Translations/pcsx2-qt_uk-UA.ts

Large diffs are not rendered by default.

6,542 changes: 4,073 additions & 2,469 deletions pcsx2-qt/Translations/pcsx2-qt_vi-VN.ts

Large diffs are not rendered by default.

6,628 changes: 4,116 additions & 2,512 deletions pcsx2-qt/Translations/pcsx2-qt_zh-CN.ts

Large diffs are not rendered by default.

6,568 changes: 4,086 additions & 2,482 deletions pcsx2-qt/Translations/pcsx2-qt_zh-TW.ts

Large diffs are not rendered by default.

158 changes: 136 additions & 22 deletions pcsx2/Patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ namespace Patch
std::optional<AspectRatioType> override_aspect_ratio;
std::optional<GSInterlaceMode> override_interlace_mode;
std::vector<PatchCommand> patches;
std::vector<DynamicPatch> dpatches;
};

struct PatchTextTable
Expand All @@ -132,6 +133,7 @@ namespace Patch
static void patch(PatchGroup* group, const std::string_view cmd, const std::string_view param);
static void gsaspectratio(PatchGroup* group, const std::string_view cmd, const std::string_view param);
static void gsinterlacemode(PatchGroup* group, const std::string_view cmd, const std::string_view param);
static void dpatch(PatchGroup* group, const std::string_view cmd, const std::string_view param);
} // namespace PatchFunc

static void TrimPatchLine(std::string& buffer);
Expand Down Expand Up @@ -187,6 +189,7 @@ namespace Patch
{0, "patch", &Patch::PatchFunc::patch},
{0, "gsaspectratio", &Patch::PatchFunc::gsaspectratio},
{0, "gsinterlacemode", &Patch::PatchFunc::gsinterlacemode},
{0, "dpatch", &Patch::PatchFunc::dpatch},
{0, nullptr, nullptr},
};
} // namespace Patch
Expand Down Expand Up @@ -247,31 +250,34 @@ u32 Patch::LoadPatchesFromString(PatchList* patch_list, const std::string& patch

PatchGroup current_patch_group;
const auto add_current_patch = [patch_list, &current_patch_group]() {
if (current_patch_group.patches.empty())
return;

// Ungrouped/legacy patches should merge with other ungrouped patches.
if (current_patch_group.name.empty())
if (!current_patch_group.patches.empty())
{
const PatchList::iterator ungrouped_patch = std::find_if(patch_list->begin(), patch_list->end(),
[](const PatchGroup& pg) { return pg.name.empty(); });
if (ungrouped_patch != patch_list->end())
// Ungrouped/legacy patches should merge with other ungrouped patches.
if (current_patch_group.name.empty())
{
Console.WriteLn(Color_Gray, fmt::format(
"Patch: Merging {} new patch commands into ungrouped list.", current_patch_group.patches.size()));
const PatchList::iterator ungrouped_patch = std::find_if(patch_list->begin(), patch_list->end(),
[](const PatchGroup& pg) { return pg.name.empty(); });
if (ungrouped_patch != patch_list->end())
{
Console.WriteLn(Color_Gray, fmt::format(
"Patch: Merging {} new patch commands into ungrouped list.", current_patch_group.patches.size()));

ungrouped_patch->patches.reserve(ungrouped_patch->patches.size() + current_patch_group.patches.size());
for (PatchCommand& cmd : current_patch_group.patches)
ungrouped_patch->patches.push_back(std::move(cmd));
}
else
{
// Always add ungrouped patches, no sense to compare empty names.
patch_list->push_back(std::move(current_patch_group));
ungrouped_patch->patches.reserve(ungrouped_patch->patches.size() + current_patch_group.patches.size());
for (PatchCommand& cmd : current_patch_group.patches)
ungrouped_patch->patches.push_back(std::move(cmd));
}
else
{
// Always add ungrouped patches, no sense to compare empty names.
patch_list->push_back(std::move(current_patch_group));
}

return;
}
}

if (current_patch_group.patches.empty() && current_patch_group.dpatches.empty())
return;
}

// Don't show patches with duplicate names, prefer the first loaded.
if (!ContainsPatchName(*patch_list, current_patch_group.name))
Expand Down Expand Up @@ -302,7 +308,7 @@ u32 Patch::LoadPatchesFromString(PatchList* patch_list, const std::string& patch
continue;
}

if (!current_patch_group.name.empty() || !current_patch_group.patches.empty())
if (!current_patch_group.name.empty() || !current_patch_group.patches.empty() || !current_patch_group.dpatches.empty())
{
add_current_patch();
current_patch_group = {};
Expand All @@ -318,7 +324,7 @@ u32 Patch::LoadPatchesFromString(PatchList* patch_list, const std::string& patch
LoadPatchLine(&current_patch_group, line);
}

if (!current_patch_group.name.empty() || !current_patch_group.patches.empty())
if (!current_patch_group.name.empty() || !current_patch_group.patches.empty() || !current_patch_group.dpatches.empty())
add_current_patch();

return static_cast<u32>(patch_list->size() - before);
Expand Down Expand Up @@ -623,13 +629,18 @@ u32 Patch::EnablePatches(const PatchList& patches, const EnablePatchList& enable
s_active_patches.push_back(&ip);
}

for (const DynamicPatch& dp : p.dpatches)
{
s_active_dynamic_patches.push_back(dp);
}

if (p.override_aspect_ratio.has_value())
s_override_aspect_ratio = p.override_aspect_ratio;
if (p.override_interlace_mode.has_value())
s_override_interlace_mode = p.override_interlace_mode;

// Count unlabelled patches once per command, or one patch per group.
count += p.name.empty() ? static_cast<u32>(p.patches.size()) : 1;
count += p.name.empty() ? (static_cast<u32>(p.patches.size()) + static_cast<u32>(p.dpatches.size())) : 1;
}

return count;
Expand Down Expand Up @@ -688,6 +699,7 @@ void Patch::UpdateActivePatches(bool reload_enabled_list, bool verbose, bool ver
s_active_patches.clear();
s_override_aspect_ratio.reset();
s_override_interlace_mode.reset();
s_active_dynamic_patches.clear();

SmallString message;
u32 gp_count = 0;
Expand Down Expand Up @@ -901,6 +913,108 @@ void Patch::PatchFunc::gsinterlacemode(PatchGroup* group, const std::string_view
group->override_interlace_mode = static_cast<GSInterlaceMode>(interlace_mode.value());
}

void Patch::PatchFunc::dpatch(PatchGroup* group, const std::string_view cmd, const std::string_view param)
{
#define PATCH_ERROR(fstring, ...) \
Console.Error(fmt::format("(dPatch) Error Parsing: {}={}: " fstring, cmd, param, __VA_ARGS__))

// [0]=version/type,[1]=number of patterns,[2]=number of replacements
// Each pattern or replacement is [3]=offset,[4]=hex

const std::vector<std::string_view> pieces(StringUtil::SplitString(param, ',', false));
if (pieces.size() < 3)
{
PATCH_ERROR("Expected at least 3 data parameters; only found {}", pieces.size());
return;
}


std::string_view patterns_end, replacements_end;

// Implemented for possible future use so we don't have to break backcompat
std::optional<u32> dpatch_type = StringUtil::FromChars<u32>(pieces[0]);

std::optional<u32> num_patterns = StringUtil::FromChars<u32>(pieces[1], 16, &patterns_end);
std::optional<u32> num_replacements = StringUtil::FromChars<u32>(pieces[2], 16, &replacements_end);

if (!dpatch_type.has_value())
{
PATCH_ERROR("Malformed version/type '{}', a decimal number(e.g. 0,1,2) is expected", pieces[0]);
return;
}

if (dpatch_type.value() != 0)
{
PATCH_ERROR("Unsupported version/type '{}', only 0 is currently supported", pieces[0]);
return;
}

if (!num_patterns.has_value())
{
PATCH_ERROR("Malformed number of patterns '{}', a decimal number is expected", pieces[1]);
return;
}

if (!num_replacements.has_value())
{
PATCH_ERROR("Malformed number of replacements '{}', a decimal number is expected", pieces[2]);
return;
}

if (pieces.size() != ((num_patterns.value() * 2) + (num_replacements.value() * 2) + 3))
{
PATCH_ERROR("Expected 2 fields for each {} patterns and {} replacements; found {}", num_patterns.value(), num_replacements.value(), pieces.size() - 2);
return;
}

DynamicPatch dpatch;
for (u32 i = 0; i < num_patterns.value(); i++)
{
std::optional<u32> offset = StringUtil::FromChars<u32>(pieces[3 + (i * 2)], 16);
std::optional<u32> value = StringUtil::FromChars<u32>(pieces[4 + (i * 2)], 16);
if (!offset.has_value())
{
PATCH_ERROR("Malformed offset '{}', a hex number without prefix (e.g. 0123ABCD) is expected", pieces[3 + (i * 2)]);
return;
}
if (!value.has_value())
{
PATCH_ERROR("Malformed value '{}', a hex number without prefix (e.g. 0123ABCD) is expected", pieces[4 + (i * 2)]);
return;
}

DynamicPatchEntry pattern;
pattern.offset = offset.value();
pattern.value = value.value();

dpatch.pattern.push_back(pattern);
}

for (u32 i = 0; i < num_replacements.value(); i++)
{
std::optional<u32> offset = StringUtil::FromChars<u32>(pieces[3 + (num_patterns.value() * 2) + (i * 2)], 16);
std::optional<u32> value = StringUtil::FromChars<u32>(pieces[4 + (num_patterns.value() * 2) + (i * 2)], 16);
if (!offset.has_value())
{
PATCH_ERROR("Malformed offset '{}', a hex number without prefix (e.g. 0123ABCD) is expected", pieces[3 + (num_patterns.value() * 2) + (i * 2)]);
return;
}
if (!value.has_value())
{
PATCH_ERROR("Malformed value '{}', a hex number without prefix (e.g. 0123ABCD) is expected", pieces[4 + (num_patterns.value() * 2) + (i * 2)]);
return;
}

DynamicPatchEntry replacement;
replacement.offset = offset.value();
replacement.value = value.value();

dpatch.replacement.push_back(replacement);
}

group->dpatches.push_back(dpatch);
}

// This is for applying patches directly to memory
void Patch::ApplyLoadedPatches(patch_place_type place)
{
Expand Down

0 comments on commit a8a7d08

Please sign in to comment.