From e00891fb5a5e83e1a5593c5dfeedd47e0368cd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Fri, 26 Apr 2024 06:31:54 +0800 Subject: [PATCH] fix --- LunaHook/engine64/yuzusuyu.cpp | 14 +++++++------- LunaHook/engines/ppsspp/specialgames.hpp | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/LunaHook/engine64/yuzusuyu.cpp b/LunaHook/engine64/yuzusuyu.cpp index 73df004..6a055fc 100644 --- a/LunaHook/engine64/yuzusuyu.cpp +++ b/LunaHook/engine64/yuzusuyu.cpp @@ -280,7 +280,7 @@ bool F010045C0109F2000(void* data, size_t* len, HookParam* hp){ s = std::regex_replace(s, std::regex("#[^\\]]*\\]"), ""); s = std::regex_replace(s, std::regex("#[^\\n]*\\n"), ""); s = std::regex_replace(s, std::regex("\\u3000"), ""); - s = std::regex_replace(s, std::regex("Save[\\s\\S]*データ"), ""); + s = std::regex_replace(s, std::regex(u8"Save[\\s\\S]*データ"), ""); return write_string_overwrite(data,len,s); } @@ -416,7 +416,7 @@ bool F01006590155AC000(void* data, size_t* len, HookParam* hp){ counter++; continue; } - std::regex regex("[\\d+─]"); + std::regex regex(u8"[\\d+─]"); s += std::regex_replace(content, regex, ""); counter += 3; continue; @@ -433,7 +433,7 @@ bool F01000200194AE000(void* data, size_t* len, HookParam* hp){ static std::string readString_savedSentence=""; static bool readString_playerNameFlag=false; - static std::string readString_playerName="ラピス"; + static std::string readString_playerName=u8"ラピス"; std::regex regex("(?=@.)"); std::sregex_token_iterator it(s.begin(), s.end(), regex, -1); @@ -457,7 +457,7 @@ bool F01000200194AE000(void* data, size_t* len, HookParam* hp){ if (tag == "@*") { if (content.find("name") == 0) { - if (readString_playerName == "ラピス") { + if (readString_playerName == u8"ラピス") { s += content.substr(4) + readString_playerName + parts[counter + 4].substr(1); } else { s += content.substr(4) + parts[counter + 3].substr(1) + parts[counter + 4].substr(1); @@ -496,7 +496,7 @@ bool F01000200194AE000(void* data, size_t* len, HookParam* hp){ counter++; continue; } - std::regex regex("[\\d+─]"); + std::regex regex(u8"[\\d+─]"); s += std::regex_replace(content, regex, ""); counter += 3; continue; @@ -999,7 +999,7 @@ void T0100DB300B996000(hook_stack* stack, HookParam* hp, uintptr_t* data, uintpt } bool F0100CBA014014000(void* data, size_t* len, HookParam* hp){ auto s = std::string((char*)data,*len); - s = std::regex_replace(s, std::regex("《.*?》"), ""); + s = std::regex_replace(s, std::regex(u8"《.*?》"), ""); s = std::regex_replace(s, std::regex("<[^>]*>"), ""); return write_string_overwrite(data,len,s); } @@ -1025,7 +1025,7 @@ bool F0100C310110B4000(void* data, size_t* len, HookParam* hp){ auto s = std::string((char*)data,*len); s = std::regex_replace(s, std::regex("(#Ruby\\[)([^,]+).([^\\]]+)."), "$2"); s = std::regex_replace(s, std::regex("#Color\\[[\\d]+\\]"), ""); - s = std::regex_replace(s, std::regex("( #n)+"), "#n"); + s = std::regex_replace(s, std::regex(u8"( #n)+"), "#n"); s = std::regex_replace(s, std::regex("#n+"), " "); return write_string_overwrite(data,len,s); } diff --git a/LunaHook/engines/ppsspp/specialgames.hpp b/LunaHook/engines/ppsspp/specialgames.hpp index 009e56e..290821a 100644 --- a/LunaHook/engines/ppsspp/specialgames.hpp +++ b/LunaHook/engines/ppsspp/specialgames.hpp @@ -75,21 +75,21 @@ void ULJS00339(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* spl bool NPJH50909_filter(void* data, size_t* len, HookParam* hp){ std::string result = std::string((char*)data,*len); - + auto ws=StringToWideString(result,932).value(); // Remove single line markers - result = std::regex_replace(result, std::regex("(\\%N)+"), " "); + ws = std::regex_replace(ws, std::wregex(L"(\\%N)+"), L" "); // Remove scale marker - result = std::regex_replace(result, std::regex("\\%\\@\\%\\d+"), ""); + ws = std::regex_replace(ws, std::wregex(L"\\%\\@\\%\\d+"), L""); // Reformat name - std::smatch match; - if (std::regex_search(result, match, std::regex("(^[^「]+)「"))) { - std::string name = match[1].str(); - result = std::regex_replace(result, std::regex("^[^「]+"), ""); - result = name + "\n" + result; + std::wsmatch match; + if (std::regex_search(ws, match, std::wregex(L"(^[^「]+)「"))) { + std::wstring name = match[1].str(); + ws = std::regex_replace(ws, std::wregex(L"^[^「]+"), L""); + ws = name + L"\n" + ws; } - return write_string_overwrite(data,len,result); + return write_string_overwrite(data,len,WideStringToString(ws,932)); } bool ULJM06119_filter(void* data, size_t* len, HookParam* hp){