diff options
Diffstat (limited to 'src/server/shared/Utilities/Util.cpp')
-rwxr-xr-x | src/server/shared/Utilities/Util.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 7d3a6f7ed58..187258e41b3 100755 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -128,9 +128,9 @@ void stripLineInvisibleChars(std::string &str) bool space = false; for (size_t pos = 0; pos < str.size(); ++pos) { - if(invChars.find(str[pos])!=std::string::npos) + if (invChars.find(str[pos])!=std::string::npos) { - if(!space) + if (!space) { str[wpos++] = ' '; space = true; @@ -138,7 +138,7 @@ void stripLineInvisibleChars(std::string &str) } else { - if(wpos!=pos) + if (wpos!=pos) str[wpos++] = str[pos]; else ++wpos; @@ -146,9 +146,9 @@ void stripLineInvisibleChars(std::string &str) } } - if(wpos < str.size()) + if (wpos < str.size()) str.erase(wpos, str.size()); - if(str.find("|TInterface")!=std::string::npos) + if (str.find("|TInterface")!=std::string::npos) str.clear(); } @@ -161,15 +161,15 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly) uint64 days = timeInSecs / DAY; std::ostringstream ss; - if(days) + if (days) ss << days << (shortText ? "d " : " Day(s) "); - if(hours || hoursOnly) + if (hours || hoursOnly) ss << hours << (shortText ? "h " : " Hour(s) "); - if(!hoursOnly) + if (!hoursOnly) { - if(minutes) + if (minutes) ss << minutes << (shortText ? "m " : " Minute(s) "); - if(secs || (!days && !hours && !minutes) ) + if (secs || (!days && !hours && !minutes) ) ss << secs << (shortText ? "s" : " Second(s)."); } @@ -184,14 +184,14 @@ uint32 TimeStringToSecs(const std::string& timestring) for (std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); ++itr) { - if(isdigit(*itr)) + if (isdigit(*itr)) { buffer*=10; buffer+= (*itr)-'0'; } else { - switch(*itr) + switch (*itr) { case 'd': multiplier = DAY; break; case 'h': multiplier = HOUR; break; @@ -225,7 +225,7 @@ std::string TimeToTimestampStr(time_t t) /// Check if the string is a valid ip address representation bool IsIPAddress(char const* ipaddress) { - if(!ipaddress) + if (!ipaddress) return false; // Let the big boys do it. @@ -270,7 +270,7 @@ void utf8truncate(std::string& utf8str, size_t len) try { size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size()); - if(wlen <= len) + if (wlen <= len) return; std::wstring wstr; @@ -291,9 +291,9 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) try { size_t len = utf8::distance(utf8str, utf8str+csize); - if(len > wsize) + if (len > wsize) { - if(wsize > 0) + if (wsize > 0) wstr[0] = L'\0'; wsize = 0; return false; @@ -305,7 +305,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) } catch(std::exception) { - if(wsize > 0) + if (wsize > 0) wstr[0] = L'\0'; wsize = 0; return false; @@ -384,7 +384,7 @@ typedef wchar_t const* const* wstrlist; std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) { // supported only Cyrillic cases - if(wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5) + if (wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5) return wname; // Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently) @@ -419,7 +419,7 @@ 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) + if (wname.substr(wname.size()-len, len)==*itr) return wname.substr(0, wname.size()-len); } @@ -430,7 +430,7 @@ 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()); @@ -462,13 +462,13 @@ 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 wstrToLower( temp ); - if(temp.find(search) == std::wstring::npos) + if (temp.find(search) == std::wstring::npos) return false; return true; @@ -509,7 +509,7 @@ void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result) { unsigned char nibble = 0x0F & (bytes[i]>>((1-j)*4)); char encodedNibble; - if(nibble < 0x0A) + if (nibble < 0x0A) encodedNibble = '0'+nibble; else encodedNibble = 'A'+nibble-0x0A; |