diff --git a/UnleashedRecomp/framework.h b/UnleashedRecomp/framework.h index fb8a53f..92818da 100644 --- a/UnleashedRecomp/framework.h +++ b/UnleashedRecomp/framework.h @@ -75,7 +75,7 @@ constexpr size_t FirstBitLow(TValue value) return 0; } -static std::unique_ptr ReadAllBytes(const char* filePath, size_t& fileSize) +inline static std::unique_ptr ReadAllBytes(const char* filePath, size_t& fileSize) { FILE* file = fopen(filePath, "rb"); diff --git a/UnleashedRecomp/kernel/xdbf.h b/UnleashedRecomp/kernel/xdbf.h index 7f23976..d1c2de3 100644 --- a/UnleashedRecomp/kernel/xdbf.h +++ b/UnleashedRecomp/kernel/xdbf.h @@ -5,3 +5,36 @@ extern XDBFWrapper g_xdbfWrapper; extern std::unordered_map g_xdbfTextureCache; + +namespace xdbf +{ + inline static std::string& FixInvalidSequences(std::string& str) + { + static std::vector invalidSequences = + { + "\xE2\x80\x99" + }; + + static std::vector replaceSequences = + { + "'" + }; + + for (int i = 0; i < invalidSequences.size(); i++) + { + size_t pos = 0; + + auto& invalidSeq = invalidSequences[i]; + auto& replaceSeq = replaceSequences[i]; + + while ((pos = str.find(invalidSequences[i], pos)) != std::string::npos) + { + str = str.replace(pos, invalidSeq.length(), replaceSeq); + + pos += replaceSeq.length(); + } + } + + return str; + } +} diff --git a/UnleashedRecomp/ui/achievement_menu.cpp b/UnleashedRecomp/ui/achievement_menu.cpp index f591ff9..bac06e6 100644 --- a/UnleashedRecomp/ui/achievement_menu.cpp +++ b/UnleashedRecomp/ui/achievement_menu.cpp @@ -794,7 +794,12 @@ void AchievementMenu::Open() g_achievements.clear(); for (auto& achievement : g_xdbfWrapper.GetAchievements((EXDBFLanguage)Config::Language.Value)) + { + if (Config::Language == ELanguage::English) + achievement.Name = xdbf::FixInvalidSequences(achievement.Name); + g_achievements.push_back(std::make_tuple(achievement, AchievementData::GetTimestamp(achievement.ID))); + } std::sort(g_achievements.begin(), g_achievements.end(), [](const auto& a, const auto& b) { diff --git a/UnleashedRecomp/ui/achievement_overlay.cpp b/UnleashedRecomp/ui/achievement_overlay.cpp index 4303e66..d841423 100644 --- a/UnleashedRecomp/ui/achievement_overlay.cpp +++ b/UnleashedRecomp/ui/achievement_overlay.cpp @@ -178,6 +178,9 @@ void AchievementOverlay::Open(int id) g_appearTime = ImGui::GetTime(); g_achievement = g_xdbfWrapper.GetAchievement((EXDBFLanguage)Config::Language.Value, id); + if (Config::Language == ELanguage::English) + g_achievement.Name = xdbf::FixInvalidSequences(g_achievement.Name); + Game_PlaySound("obj_navi_appear"); }