mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-26 23:26:23 +00:00
refactor(Core/Misc): Rewrite name handling functions that use raw buffers (#2230)
This commit is contained in:
@@ -123,24 +123,15 @@ bool normalizePlayerName(std::string& name)
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
wchar_t wstr_buf[MAX_INTERNAL_PLAYER_NAME+1];
|
||||
size_t wstr_len = MAX_INTERNAL_PLAYER_NAME;
|
||||
|
||||
if (!Utf8toWStr(name, &wstr_buf[0], wstr_len))
|
||||
std::wstring tmp;
|
||||
if (!Utf8toWStr(name, tmp))
|
||||
return false;
|
||||
|
||||
wstr_buf[0] = wcharToUpper(wstr_buf[0]);
|
||||
for (size_t i = 1; i < wstr_len; ++i)
|
||||
wstr_buf[i] = wcharToLower(wstr_buf[i]);
|
||||
wstrToLower(tmp);
|
||||
if (!tmp.empty())
|
||||
tmp[0] = wcharToUpper(tmp[0]);
|
||||
|
||||
// if there's "gm" at the end, uppercase it!
|
||||
if (wstr_len>=2 && wstr_buf[wstr_len-2]==L'g' && wstr_buf[wstr_len-1]==L'm')
|
||||
{
|
||||
wstr_buf[wstr_len-2]=L'G';
|
||||
wstr_buf[wstr_len-1]=L'M';
|
||||
}
|
||||
|
||||
if (!WStrToUtf8(wstr_buf, wstr_len, name))
|
||||
if (!WStrToUtf8(tmp, name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user