diff options
Diffstat (limited to 'src/server/shared/Utilities/Util.cpp')
-rwxr-xr-x | src/server/shared/Utilities/Util.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 2c72a1be8a1..47e91fbfa7d 100755 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -147,7 +147,7 @@ void stripLineInvisibleChars(std::string &str) } if(wpos < str.size()) - str.erase(wpos,str.size()); + str.erase(wpos, str.size()); if(str.find("|TInterface")!=std::string::npos) str.clear(); @@ -218,7 +218,7 @@ std::string TimeToTimestampStr(time_t t) // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) char buf[20]; - snprintf(buf,20,"%04d-%02d-%02d_%02d-%02d-%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + snprintf(buf, 20, "%04d-%02d-%02d_%02d-%02d-%02d", aTm->tm_year+1900, aTm->tm_mon+1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec); return std::string(buf); } @@ -229,7 +229,7 @@ bool IsIPAddress(char const* ipaddress) return false; // Let the big boys do it. - // Drawback: all valid ip address formats are recognized e.g.: 12.23,121234,0xABCD) + // Drawback: all valid ip address formats are recognized e.g.: 12.23, 121234, 0xABCD) return inet_addr(ipaddress) != INADDR_NONE; } @@ -256,7 +256,7 @@ size_t utf8length(std::string& utf8str) { try { - return utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + return utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size()); } catch(std::exception) { @@ -265,19 +265,19 @@ size_t utf8length(std::string& utf8str) } } -void utf8truncate(std::string& utf8str,size_t len) +void utf8truncate(std::string& utf8str, size_t len) { try { - size_t wlen = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size()); if(wlen <= len) return; std::wstring wstr; wstr.resize(wlen); - utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]); + utf8::utf8to16(utf8str.c_str(), utf8str.c_str()+utf8str.size(), &wstr[0]); wstr.resize(len); - char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str[0]); + char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str()+wstr.size(), &utf8str[0]); utf8str.resize(oend-(&utf8str[0])); // remove unused tail } catch(std::exception) @@ -290,7 +290,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) { try { - size_t len = utf8::distance(utf8str,utf8str+csize); + size_t len = utf8::distance(utf8str, utf8str+csize); if(len > wsize) { if(wsize > 0) @@ -300,7 +300,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) } wsize = len; - utf8::utf8to16(utf8str,utf8str+csize,wstr); + utf8::utf8to16(utf8str, utf8str+csize, wstr); wstr[len] = L'\0'; } catch(std::exception) @@ -318,11 +318,11 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr) { try { - size_t len = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + size_t len = utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size()); wstr.resize(len); if (len) - utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]); + utf8::utf8to16(utf8str.c_str(), utf8str.c_str()+utf8str.size(), &wstr[0]); } catch(std::exception) { @@ -342,7 +342,7 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str) if (size) { - char* oend = utf8::utf16to8(wstr,wstr+size,&utf8str2[0]); + char* oend = utf8::utf16to8(wstr, wstr+size, &utf8str2[0]); utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail } utf8str = utf8str2; @@ -365,7 +365,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str) if (wstr.size()) { - char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str2[0]); + char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str()+wstr.size(), &utf8str2[0]); utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail } utf8str = utf8str2; @@ -389,22 +389,22 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) // Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently) - static wchar_t const a_End[] = { wchar_t(1), wchar_t(0x0430),wchar_t(0x0000)}; - static wchar_t const o_End[] = { wchar_t(1), wchar_t(0x043E),wchar_t(0x0000)}; - static wchar_t const ya_End[] = { wchar_t(1), wchar_t(0x044F),wchar_t(0x0000)}; - static wchar_t const ie_End[] = { wchar_t(1), wchar_t(0x0435),wchar_t(0x0000)}; - static wchar_t const i_End[] = { wchar_t(1), wchar_t(0x0438),wchar_t(0x0000)}; - static wchar_t const yeru_End[] = { wchar_t(1), wchar_t(0x044B),wchar_t(0x0000)}; - static wchar_t const u_End[] = { wchar_t(1), wchar_t(0x0443),wchar_t(0x0000)}; - static wchar_t const yu_End[] = { wchar_t(1), wchar_t(0x044E),wchar_t(0x0000)}; - static wchar_t const oj_End[] = { wchar_t(2), wchar_t(0x043E),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const ie_j_End[] = { wchar_t(2), wchar_t(0x0435),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const io_j_End[] = { wchar_t(2), wchar_t(0x0451),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const o_m_End[] = { wchar_t(2), wchar_t(0x043E),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const io_m_End[] = { wchar_t(2), wchar_t(0x0451),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const ie_m_End[] = { wchar_t(2), wchar_t(0x0435),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C),wchar_t(0x0000)}; - static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439),wchar_t(0x0000)}; + static wchar_t const a_End[] = { wchar_t(1), wchar_t(0x0430), wchar_t(0x0000)}; + static wchar_t const o_End[] = { wchar_t(1), wchar_t(0x043E), wchar_t(0x0000)}; + static wchar_t const ya_End[] = { wchar_t(1), wchar_t(0x044F), wchar_t(0x0000)}; + static wchar_t const ie_End[] = { wchar_t(1), wchar_t(0x0435), wchar_t(0x0000)}; + static wchar_t const i_End[] = { wchar_t(1), wchar_t(0x0438), wchar_t(0x0000)}; + static wchar_t const yeru_End[] = { wchar_t(1), wchar_t(0x044B), wchar_t(0x0000)}; + static wchar_t const u_End[] = { wchar_t(1), wchar_t(0x0443), wchar_t(0x0000)}; + static wchar_t const yu_End[] = { wchar_t(1), wchar_t(0x044E), wchar_t(0x0000)}; + static wchar_t const oj_End[] = { wchar_t(2), wchar_t(0x043E), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const ie_j_End[] = { wchar_t(2), wchar_t(0x0435), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const io_j_End[] = { wchar_t(2), wchar_t(0x0451), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const o_m_End[] = { wchar_t(2), wchar_t(0x043E), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const io_m_End[] = { wchar_t(2), wchar_t(0x0451), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const ie_m_End[] = { wchar_t(2), wchar_t(0x0435), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C), wchar_t(0x0000)}; + static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439), wchar_t(0x0000)}; static wchar_t const* const dropEnds[6][8] = { { &a_End[1], &o_End[1], &ya_End[1], &ie_End[1], &soft_End[1], &j_End[1], NULL, NULL }, @@ -419,8 +419,8 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) { size_t len = size_t((*itr)[-1]); // get length from string size field - if(wname.substr(wname.size()-len,len)==*itr) - return wname.substr(0,wname.size()-len); + if(wname.substr(wname.size()-len, len)==*itr) + return wname.substr(0, wname.size()-len); } return wname; @@ -430,11 +430,11 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr) { #if PLATFORM == PLATFORM_WINDOWS std::wstring wstr; - if(!Utf8toWStr(utf8str,wstr)) + if(!Utf8toWStr(utf8str, wstr)) return false; conStr.resize(wstr.size()); - CharToOemBuffW(&wstr[0],&conStr[0],wstr.size()); + CharToOemBuffW(&wstr[0], &conStr[0], wstr.size()); #else // not implemented yet conStr = utf8str; @@ -443,14 +443,14 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr) return true; } -bool consoleToUtf8(const std::string& conStr,std::string& utf8str) +bool consoleToUtf8(const std::string& conStr, std::string& utf8str) { #if PLATFORM == PLATFORM_WINDOWS std::wstring wstr; wstr.resize(conStr.size()); - OemToCharBuffW(&conStr[0],&wstr[0],conStr.size()); + OemToCharBuffW(&conStr[0], &wstr[0], conStr.size()); - return WStrToUtf8(wstr,utf8str); + return WStrToUtf8(wstr, utf8str); #else // not implemented yet utf8str = conStr; @@ -462,7 +462,7 @@ bool Utf8FitTo(const std::string& str, std::wstring search) { std::wstring temp; - if(!Utf8toWStr(str,temp)) + if(!Utf8toWStr(str, temp)) return false; // converting to lower case |