diff options
Diffstat (limited to 'src/server/game/Chat/LanguageMgr.cpp')
-rw-r--r-- | src/server/game/Chat/LanguageMgr.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/server/game/Chat/LanguageMgr.cpp b/src/server/game/Chat/LanguageMgr.cpp index 9fc877944bc..07181d986a5 100644 --- a/src/server/game/Chat/LanguageMgr.cpp +++ b/src/server/game/Chat/LanguageMgr.cpp @@ -170,7 +170,7 @@ namespace return; for (wchar_t& w : wstrText) - if (!isExtendedLatinCharacter(w) && !isNumeric(w) && w <= 0xFF && w != L'\\') + if (!isLatin1Character(w) && !isNumeric(w) && w <= 0xFF && w != L'\'') w = L' '; WStrToUtf8(wstrText, text); @@ -189,15 +189,11 @@ namespace 0xE3061AE7, 0xA39B0FA1, 0x9797F25F, 0xE4444563, }; - uint32 SStrHash(char const* string, bool caseInsensitive, uint32 seed = 0x7FED7FED) + uint32 SStrHash(std::string_view string, bool caseInsensitive, uint32 seed = 0x7FED7FED) { - ASSERT(string); - uint32 shift = 0xEEEEEEEE; - while (*string) + for (char c : string) { - char c = *string++; - if (caseInsensitive) c = upper_backslash(c); @@ -222,8 +218,8 @@ std::string LanguageMgr::Translate(std::string const& msg, uint32 language, Loca uint32 wordLen = std::min(18u, uint32(str.length())); if (LanguageMgr::WordList const* wordGroup = FindWordGroup(language, wordLen)) { - uint32 wordHash = SStrHash(str.data(), true); - uint8 idxInsideGroup = wordHash % wordGroup->size(); + uint32 wordHash = SStrHash(str, true); + uint8 idxInsideGroup = language * wordHash % wordGroup->size(); char const* replacementWord = (*wordGroup)[idxInsideGroup]; @@ -251,7 +247,7 @@ std::string LanguageMgr::Translate(std::string const& msg, uint32 language, Loca size_t length = std::min(wstrSourceWord.length(), strlen(replacementWord)); for (size_t i = 0; i < length; ++i) { - if (isUpper(wstrSourceWord[i])) + if (wstrSourceWord[i] != L'\'' && isUpper(wstrSourceWord[i])) result += charToUpper(replacementWord[i]); else result += charToLower(replacementWord[i]); |