This commit is contained in:
恍兮惚兮 2024-11-17 13:03:03 +08:00
parent f64840f948
commit acddc3158f
11 changed files with 81 additions and 147 deletions

View File

@ -39,9 +39,8 @@ bool InsertAnim2Hook()
// そんな俺に声をかけてきたのは、近所のスーパーで働いている主婦の、@n『@[赤羽:あかばね]@[千晶:ちあき]』さんだ。
myhp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
static const std::regex rx("@\\[(.*?):(.*?)\\]", std::regex_constants::icase);
std::string result = buffer->strA();
result = std::regex_replace(result, rx, "$1");
result = std::regex_replace(result, std::regex("@\\[(.*?):(.*?)\\]", std::regex_constants::icase), "$1");
buffer->from(result);
};
myhp.newlineseperator = L"@n";

View File

@ -1258,9 +1258,8 @@ bool InsertBGIDynamicHook(LPVOID addr, DWORD frame, DWORD stack)
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
// It could be either <R..> or <r..>
static const std::regex rx("<r.+?>(.+?)</r>", std::regex_constants::icase);
std::string result = buffer->strA();
result = std::regex_replace(result, rx, "$1");
result = std::regex_replace(result, std::regex("<r.+?>(.+?)</r>", std::regex_constants::icase), "$1");
buffer->from(result);
};

View File

@ -1198,8 +1198,7 @@ namespace
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
std::string str = buffer->strA();
std::regex reg1("\\{(.*?)/(.*?)\\}");
std::string result1 = std::regex_replace(str, reg1, "$1");
std::string result1 = std::regex_replace(str, std::regex("\\{(.*?)/(.*?)\\}"), "$1");
buffer->from(result1);
};

View File

@ -238,8 +238,7 @@ bool InsertCatSystem2Hook()
hp.type = USING_STRING | CODEC_UTF8;
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
static std::regex rx(R"(\[(.+?)/.+\])");
auto _ = std::regex_replace(buffer->strA(), rx, "$1");
auto _ = std::regex_replace(buffer->strA(), std::regex(R"(\[(.+?)/.+\])"), "$1");
buffer->from(_);
};
hp.newlineseperator = L"\\n";
@ -836,8 +835,7 @@ namespace
hp.hook_font = F_GetGlyphOutlineA;
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
static std::regex rx(R"(\[(.+?)/.+\])");
buffer->from(std::regex_replace(buffer->strA(), rx, "$1"));
buffer->from(std::regex_replace(buffer->strA(), std::regex(R"(\[(.+?)/.+\])"), "$1"));
};
static ULONG p;

View File

@ -189,8 +189,7 @@ namespace
return buffer->clear();
std::string str = buffer->strA();
std::regex reg1("\\{(.*?)/(.*?)\\}");
std::string result1 = std::regex_replace(str, reg1, "$1");
std::string result1 = std::regex_replace(str, std::regex("\\{(.*?)/(.*?)\\}"), "$1");
buffer->from(result1);
};
succ |= NewHook(hp, "debonosu");

View File

@ -393,8 +393,7 @@ namespace
void hook2(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
{
strReplace(save, "\\k", "");
static std::regex rx("<R(.+?)\\|.+>");
save = std::regex_replace(save, rx, "$1");
save = std::regex_replace(save, std::regex("<R(.+?)\\|.+>"), "$1");
buffer->from(save);
}
void hook2a(hook_stack *s, TextBuffer buffer)

View File

@ -517,9 +517,8 @@ namespace
};
hp.filter_fun = [](TextBuffer *buffer, HookParam *hp)
{
static const std::regex rx("#\\{(.*?)\\}(.*?)#", std::regex_constants::icase);
std::string result = buffer->strA();
result = std::regex_replace(result, rx, "$2");
result = std::regex_replace(result, std::regex("#\\{(.*?)\\}(.*?)#", std::regex_constants::icase), "$2");
strReplace(result, u8" \n", "");
strReplace(result, u8"\n", "");
buffer->from(result);

View File

@ -147,12 +147,9 @@ namespace
std::string rubyRemove(std::string text)
{
std::regex rx("<r(.*?)>(.*?)</r>");
text = std::regex_replace(text, rx, "$2");
std::regex rx2("<c(.*?)>(.*?)</c>");
text = std::regex_replace(text, rx2, "$2");
std::regex rx3("<s(.*?)>(.*?)</s>");
text = std::regex_replace(text, rx3, "$2");
text = std::regex_replace(text, std::regex("<r(.*?)>(.*?)</r>"), "$2");
text = std::regex_replace(text, std::regex("<c(.*?)>(.*?)</c>"), "$2");
text = std::regex_replace(text, std::regex("<s(.*?)>(.*?)</s>"), "$2");
return text;
}
}

View File

@ -265,8 +265,7 @@ namespace
void FBLJM61131(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex pattern("\\[[^\\]]+.");
s = std::regex_replace(s, pattern, "");
s = std::regex_replace(s, std::regex("\\[[^\\]]+."), "");
s = std::regex_replace(s, std::regex("\\\\k|\\\\x|%C|%B"), "");
s = std::regex_replace(s, std::regex("\\%\\d+\\#[0-9a-fA-F]*\\;"), "");
s = std::regex_replace(s, std::regex("\\n+"), " ");

View File

@ -363,8 +363,7 @@ namespace
void F0100F6A00A684000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex regex("(?=@.)");
std::sregex_token_iterator it(s.begin(), s.end(), regex, -1);
std::sregex_token_iterator it(s.begin(), s.end(), std::regex("(?=@.)"), -1);
std::sregex_token_iterator end;
std::vector<std::string> parts(it, end);
s = "";
@ -424,8 +423,7 @@ namespace
void F01006590155AC000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex regex("(?=@.)");
std::sregex_token_iterator it(s.begin(), s.end(), regex, -1);
std::sregex_token_iterator it(s.begin(), s.end(), std::regex("(?=@.)"), -1);
std::sregex_token_iterator end;
std::vector<std::string> parts(it, end);
@ -468,8 +466,7 @@ namespace
}
else if (tag == "@v" || tag == "@h")
{
std::regex regex("[\\w_-]+");
s += std::regex_replace(content, regex, "");
s += std::regex_replace(content, std::regex("[\\w_-]+"), "");
counter++;
continue;
}
@ -486,8 +483,7 @@ namespace
counter++;
continue;
}
std::regex regex(u8"[\\d+─]");
s += std::regex_replace(content, regex, "");
s += std::regex_replace(content, std::regex(u8"[\\d+─]"), "");
counter += 3;
continue;
}
@ -507,8 +503,7 @@ namespace
static bool readString_playerNameFlag = false;
static std::string readString_playerName = u8"ラピス";
std::regex regex("(?=@.)");
std::sregex_token_iterator it(s.begin(), s.end(), regex, -1);
std::sregex_token_iterator it(s.begin(), s.end(), std::regex("(?=@.)"), -1);
std::sregex_token_iterator end;
std::vector<std::string> parts(it, end);
@ -572,8 +567,7 @@ namespace
}
else if (tag == "@v" || tag == "@h")
{
std::regex regex("[\\w_-]+");
s += std::regex_replace(content, regex, "");
s += std::regex_replace(content, std::regex("[\\w_-]+"), "");
counter++;
continue;
}
@ -590,8 +584,7 @@ namespace
counter++;
continue;
}
std::regex regex(u8"[\\d+─]");
s += std::regex_replace(content, regex, "");
s += std::regex_replace(content, std::regex(u8"[\\d+─]"), "");
counter += 3;
continue;
}
@ -789,8 +782,7 @@ namespace
void F010045C014650000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex pattern("(@(\\/)?[a-zA-Z#](\\(\\d+\\))?|)[*<>]+");
s = std::regex_replace(s, pattern, "");
s = std::regex_replace(s, std::regex(R"((@(\/)?[a-zA-Z#](\(\d+\))?|)+|[\*<>]+)"), "");
buffer->from(s);
}
@ -846,18 +838,15 @@ namespace
void F0100AFA01750C000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex newlineRegex("(\\\\n)+");
std::regex specialCharsRegex("\\\\d$|^\\@[a-z]+|#.*?#|\\$");
s = std::regex_replace(s, newlineRegex, " ");
s = std::regex_replace(s, specialCharsRegex, "");
s = std::regex_replace(s, std::regex(R"((\\n)+)"), " ");
s = std::regex_replace(s, std::regex(R"(\\d$|^\@[a-z]+|#.*?#|\$)"), "");
buffer->from(s);
}
void F0100C1E0102B8000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
s = std::regex_replace(s, std::regex("#N"), "\n");
std::regex colorRegex("#Color\\[[\\d]+\\]");
s = std::regex_replace(s, colorRegex, "");
s = std::regex_replace(s, std::regex("#Color\\[[\\d]+\\]"), "");
buffer->from(s);
}
void F0100BD700E648000(TextBuffer *buffer, HookParam *hp)
@ -956,8 +945,7 @@ namespace
void F010055D009F78000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex pattern3("\\d+");
s = std::regex_replace(s, pattern3, "");
s = std::regex_replace(s, std::regex("\\d+"), "");
static std::string last;
if (last == s)
return buffer->clear();
@ -968,21 +956,16 @@ namespace
void F010080C01AA22000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex furiganaRegex("#\\d+R.*?#");
s = std::regex_replace(s, furiganaRegex, "");
std::regex lettersNumbersRegex("[A-Za-z0-9]");
s = std::regex_replace(s, lettersNumbersRegex, "");
std::regex symbolsRegex(u8"[().%,_!#©&:?/]");
s = std::regex_replace(s, symbolsRegex, "");
s = std::regex_replace(s, std::regex("#\\d+R.*?#"), "");
s = std::regex_replace(s, std::regex("[A-Za-z0-9]"), "");
s = std::regex_replace(s, std::regex(u8"[().%,_!#©&:?/]"), "");
buffer->from(s);
}
void F0100CB700D438000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex furiganaRegex("<RUBY><RB>(.*?)<\\/RB><RT>(.*?)<\\/RT><\\/RUBY>");
s = std::regex_replace(s, furiganaRegex, "$1");
std::regex htmlTagRegex("<[^>]*>");
s = std::regex_replace(s, htmlTagRegex, "");
s = std::regex_replace(s, std::regex(R"(<RUBY><RB>(.*?)<\/RB><RT>(.*?)<\/RT><\/RUBY>)"), "$1");
s = std::regex_replace(s, std::regex("<[^>]*>"), "");
static std::string last;
if (last == s)
return buffer->clear();
@ -1018,14 +1001,10 @@ namespace
void F010072000BD32000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex lineBreakRegex("\\[~\\]");
s = std::regex_replace(s, lineBreakRegex, "\n");
std::regex romRegex("rom:[\\s\\S]*$");
s = std::regex_replace(s, romRegex, "");
std::regex furiganaRegex("\\[[\\w\\d]*\\[[\\w\\d]*\\].*?\\[\\/\\[\\w\\d]*\\]\\]");
s = std::regex_replace(s, furiganaRegex, "");
std::regex bracketsRegex("\\[.*?\\]");
s = std::regex_replace(s, bracketsRegex, "");
s = std::regex_replace(s, std::regex(R"(\[~\])"), "\n");
s = std::regex_replace(s, std::regex(R"(\rom:[\s\S]*$)"), "");
s = std::regex_replace(s, std::regex(R"(\[[\w\d]*\[[\w\d]*\].*?\[\/[\w\d]*\]\])"), "");
s = std::regex_replace(s, std::regex(R"(\[.*?\])"), "");
static std::string last;
if (last == s)
return buffer->clear();
@ -1334,12 +1313,8 @@ namespace
void F0100B5500CA0C000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
// std::regex pattern1("\\\\u0000+$");
std::regex pattern2("\\\\");
std::regex pattern3("\\$");
// s = std::regex_replace(s, pattern1, "");
s = std::regex_replace(s, pattern2, "");
s = std::regex_replace(s, pattern3, "");
s = std::regex_replace(s, std::regex("\\\\"), "");
s = std::regex_replace(s, std::regex("\\$"), "");
buffer->from(s);
}
void T0100B5500CA0C000(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
@ -1585,11 +1560,9 @@ namespace
void F0100556015CCC000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex rubiRegex("\\[[^\\]]+.");
s = std::regex_replace(s, rubiRegex, "");
s = std::regex_replace(s, std::regex("\\[[^\\]]+."), "");
s = std::regex_replace(s, std::regex("\\\\k|\\\\x|%C|%B|%p-1;"), "");
std::regex colorRegex("#[0-9a-fA-F]+;([^%#]+)(%r)?");
s = std::regex_replace(s, colorRegex, "$1");
s = std::regex_replace(s, std::regex("#[0-9a-fA-F]+;([^%#]+)(%r)?"), "$1");
static std::set<std::string> dump;
if (dump.find(s) != dump.end())
return buffer->clear();
@ -1668,14 +1641,10 @@ namespace
void F01001B900C0E2000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex whitespaceRegex("\\s");
s = std::regex_replace(s, whitespaceRegex, "");
std::regex hashRegex("#[A-Za-z]+(\\[(\\d*\\.)?\\d+\\])+");
s = std::regex_replace(s, hashRegex, "");
std::regex hashLetterRegex("#[a-z]");
s = std::regex_replace(s, hashLetterRegex, "");
std::regex lowercaseRegex("[a-z]");
s = std::regex_replace(s, lowercaseRegex, "");
s = std::regex_replace(s, std::regex("\\s"), "");
s = std::regex_replace(s, std::regex("#[A-Za-z]+(\\[(\\d*\\.)?\\d+\\])+"), "");
s = std::regex_replace(s, std::regex("#[a-z]"), "");
s = std::regex_replace(s, std::regex("[a-z]"), "");
buffer->from(s);
}
@ -1950,8 +1919,7 @@ namespace
void F01005E9016BDE000(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex patt("/\\/\\/ remove rubi\\n\\ss = s.replace\\(patt, ''\\);/");
s = std::regex_replace(s, patt, "");
s = std::regex_replace(s, std::regex(R"(\[[^\]]+.)"), "");
s = std::regex_replace(s, std::regex("\\\\k|\\\\x|%C|%B|%p-1;"), "");
s = std::regex_replace(s, std::regex("#[0-9a-fA-F]+;([^%#]+)(%r)?"), "$1");
s = std::regex_replace(s, std::regex("\\\\n"), " ");
@ -1970,12 +1938,9 @@ namespace
{
auto s = buffer->strW();
std::wregex pattern1(L"\\[([^\\]\\/]+)\\/[^\\]]+\\]");
s = std::regex_replace(s, pattern1, L"$1");
std::wregex pattern2(L"(\\S*)@");
s = std::regex_replace(s, pattern2, L"$1");
std::wregex pattern3(L"\\$");
s = std::regex_replace(s, pattern3, L"");
s = std::regex_replace(s, std::wregex(LR"(\[([^\]\/]+)\/[^\]]+\])"), L"$1");
s = std::regex_replace(s, std::wregex(L"(\\S*)@"), L"$1");
s = std::regex_replace(s, std::wregex(L"\\$"), L"");
buffer->from(s);
}
void F01000A400AF2A000(TextBuffer *buffer, HookParam *hp)

View File

@ -6,10 +6,8 @@ namespace ppsspp
void ULJS00403_filter(TextBuffer *buffer, HookParam *hp)
{
std::string result = buffer->strA();
std::regex newlinePattern(R"((\\n)+)");
result = std::regex_replace(result, newlinePattern, " ");
std::regex pattern(R"((\\d$|^\@[a-z]+|#.*?#|\$))");
result = std::regex_replace(result, pattern, "");
result = std::regex_replace(result, std::regex(R"((\\n)+)"), " ");
result = std::regex_replace(result, std::regex(R"((\\d$|^\@[a-z]+|#.*?#|\$))"), "");
buffer->from(result);
}
@ -109,28 +107,18 @@ namespace ppsspp
void ULJM06119_filter(TextBuffer *buffer, HookParam *hp)
{
std::string s = buffer->strA();
std::regex pattern(R"(/\[[^\]]+./g)");
s = std::regex_replace(s, pattern, "");
std::regex tagPattern(R"(/\\k|\\x|%C|%B)");
s = std::regex_replace(s, tagPattern, "");
std::regex colorPattern(R"(/\%\d+\#[0-9a-fA-F]*\;)");
s = std::regex_replace(s, colorPattern, "");
std::regex newlinePattern(R"(/\n+)");
s = std::regex_replace(s, newlinePattern, " ");
s = std::regex_replace(s, std::regex(R"(/\[[^\]]+./g)"), "");
s = std::regex_replace(s, std::regex(R"(/\\k|\\x|%C|%B)"), "");
s = std::regex_replace(s, std::regex(R"(/\%\d+\#[0-9a-fA-F]*\;)"), "");
s = std::regex_replace(s, std::regex(R"(/\n+)"), " ");
buffer->from(s);
}
void ULJM06036_filter(TextBuffer *buffer, HookParam *hp)
{
std::wstring result = buffer->strW();
std::wregex pattern(LR"(<R([^\/]+).([^>]+).>)");
result = std::regex_replace(result, pattern, L"$2");
std::wregex tagPattern(LR"(<[A-Z]+>)");
result = std::regex_replace(result, tagPattern, L"");
result = std::regex_replace(result, std::wregex(LR"(<R([^\/]+).([^>]+).>)"), L"$2");
result = std::regex_replace(result, std::wregex(LR"(<[A-Z]+>)"), L"");
buffer->from(result);
}
@ -260,6 +248,20 @@ namespace ppsspp
{
StringCharReplacer(buffer, "\\n", 2, '\n');
}
void FNPJH50247(TextBuffer *buffer, HookParam *hp)
{
static lru_cache<std::string> cache(3);
auto s = buffer->strA();
if (cache.touch(s))
buffer->clear();
else
{
s = std::regex_replace(s, std::regex("#C[0-9]{9}"), "");
s = std::regex_replace(s, std::regex("#RUBS(.*?)#RUBE(.*?)#REND"), "$2");
s = std::regex_replace(s, std::regex("#CDEF"), "");
buffer->from(s);
}
}
void ULJM06145(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
@ -296,45 +298,22 @@ namespace ppsspp
void NPJH50619F(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex pattern1("[\\r\\n]+");
std::string replacement1 = "";
std::string result1 = std::regex_replace(s, pattern1, replacement1);
std::regex pattern2("^(.*?)\\)+");
std::string replacement2 = "";
std::string result2 = std::regex_replace(result1, pattern2, replacement2);
std::regex pattern3("#ECL+");
std::string replacement3 = "";
std::string result3 = std::regex_replace(result2, pattern3, replacement3);
std::regex pattern4("(#.+?\\))+");
std::string replacement4 = "";
std::string result4 = std::regex_replace(result3, pattern4, replacement4);
buffer->from(result4);
s = std::regex_replace(s, std::regex("[\\r\\n]+"), "");
s = std::regex_replace(s, std::regex("^(.*?)\\)+"), "");
s = std::regex_replace(s, std::regex("#ECL+"), "");
s = std::regex_replace(s, std::regex("(#.+?\\))+"), "");
buffer->from(s);
}
void NPJH50505F(TextBuffer *buffer, HookParam *hp)
{
auto s = buffer->strA();
std::regex pattern2("#RUBS(#[A-Z0-9]+)*[^#]+");
std::string replacement2 = "";
std::string result2 = std::regex_replace(s, pattern2, replacement2);
std::regex pattern3("#FAMILY");
std::string replacement3 = "$FAMILY";
std::string result3 = std::regex_replace(result2, pattern3, replacement3);
std::regex pattern4("#GIVE");
std::string replacement4 = "$GIVE";
std::string result4 = std::regex_replace(result3, pattern4, replacement4);
std::regex pattern5("(#[A-Z0-9\\-]+)+");
std::string replacement5 = "";
std::string result5 = std::regex_replace(result4, pattern5, replacement5);
std::regex pattern6("\\n+");
std::string replacement6 = " ";
std::string result6 = std::regex_replace(result5, pattern6, replacement6);
buffer->from(result6);
s = std::regex_replace(s, std::regex("#RUBS(#[A-Z0-9]+)*[^#]+"), "");
s = std::regex_replace(s, std::regex("#FAMILY"), "$FAMILY");
s = std::regex_replace(s, std::regex("#GIVE"), "$GIVE");
s = std::regex_replace(s, std::regex("(#[A-Z0-9\\-]+)+"), "");
s = std::regex_replace(s, std::regex("\\n+"), "");
buffer->from(s);
}
void QNPJH50909(hook_stack *stack, HookParam *hp, TextBuffer *buffer, uintptr_t *split)
@ -420,7 +399,9 @@ namespace ppsspp
// 源狼 GENROH
{0x8940DA8, {0, 1, 0, 0, ULJM06145, "ULJM06145"}}, // TEXT
// 遙かなる時空の中で4 愛蔵版
{0x8955CE0, {0, 0, 0, ULJM05810, 0, " ULJM05810"}},
{0x8955CE0, {0, 0, 0, ULJM05810, 0, "ULJM05810"}},
// Fate/EXTRA
{0x88B87F0, {0, 6, 0, 0, FNPJH50247, "NPJH50247"}},
};
}