[Sync] Project sync

This commit is contained in:
Antz 2014-10-11 08:28:58 +01:00 committed by Antz
parent f1c9e0f94b
commit 86690df496
22 changed files with 1731 additions and 385 deletions

View file

@ -122,7 +122,7 @@ Tokens StrSplit(const std::string& src, const std::string& sep)
{
if (sep.find(*i) != std::string::npos)
{
if (s.length()) r.push_back(s);
if (s.length()) { r.push_back(s); }
s = "";
}
else
@ -130,14 +130,14 @@ Tokens StrSplit(const std::string& src, const std::string& sep)
s += *i;
}
}
if (s.length()) r.push_back(s);
if (s.length()) { r.push_back(s); }
return r;
}
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index)
{
if (index >= data.size())
return 0;
{ return 0; }
return (uint32)atoi(data[index].c_str());
}
@ -186,15 +186,15 @@ void stripLineInvisibleChars(std::string& str)
else
{
if (wpos != pos)
str[wpos++] = str[pos];
{ str[wpos++] = str[pos]; }
else
++wpos;
{ ++wpos; }
space = false;
}
}
if (wpos < str.size())
str.erase(wpos, str.size());
{ str.erase(wpos, str.size()); }
}
std::string secsToTimeString(time_t timeInSecs, bool shortText, bool hoursOnly)
@ -206,15 +206,15 @@ std::string secsToTimeString(time_t timeInSecs, bool shortText, bool hoursOnly)
std::ostringstream ss;
if (days)
ss << days << (shortText ? "d" : " Day(s) ");
{ ss << days << (shortText ? "d" : " Day(s) "); }
if (hours || hoursOnly)
ss << hours << (shortText ? "h" : " Hour(s) ");
{ ss << hours << (shortText ? "h" : " Hour(s) "); }
if (!hoursOnly)
{
if (minutes)
ss << minutes << (shortText ? "m" : " Minute(s) ");
{ ss << minutes << (shortText ? "m" : " Minute(s) "); }
if (secs || (!days && !hours && !minutes))
ss << secs << (shortText ? "s" : " Second(s).");
{ ss << secs << (shortText ? "s" : " Second(s)."); }
}
return ss.str();
@ -300,7 +300,7 @@ std::string MoneyToString(uint64 money)
bool IsIPAddress(char const* ipaddress)
{
if (!ipaddress)
return false;
{ return false; }
// Let the big boys do it.
// Drawback: all valid ip address formats are recognized e.g.: 12.23,121234,0xABCD)
@ -312,7 +312,7 @@ uint32 CreatePIDFile(const std::string& filename)
{
FILE* pid_file = fopen(filename.c_str(), "w");
if (pid_file == NULL)
return 0;
{ return 0; }
#ifdef WIN32
DWORD pid = GetCurrentProcessId();
@ -345,7 +345,7 @@ void utf8truncate(std::string& utf8str, size_t len)
{
size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size());
if (wlen <= len)
return;
{ return; }
std::wstring wstr;
wstr.resize(wlen);
@ -368,7 +368,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
if (len > wsize)
{
if (wsize > 0)
wstr[0] = L'\0';
{ wstr[0] = L'\0'; }
wsize = 0;
return false;
}
@ -380,7 +380,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
catch (std::exception)
{
if (wsize > 0)
wstr[0] = L'\0';
{ wstr[0] = L'\0'; }
wsize = 0;
return false;
}
@ -396,7 +396,7 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
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)
{
@ -453,7 +453,7 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
{
// supported only Cyrillic cases
if (wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5)
return wname;
{ return wname; }
// Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently)
@ -489,7 +489,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)
return wname.substr(0, wname.size() - len);
{ return wname.substr(0, wname.size() - len); }
}
return wname;
@ -500,7 +500,7 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr)
#if PLATFORM == PLATFORM_WINDOWS
std::wstring wstr;
if (!Utf8toWStr(utf8str, wstr))
return false;
{ return false; }
conStr.resize(wstr.size());
CharToOemBuffW(&wstr[0], &conStr[0], wstr.size());
@ -532,13 +532,13 @@ bool Utf8FitTo(const std::string& str, std::wstring search)
std::wstring temp;
if (!Utf8toWStr(str, temp))
return false;
{ return false; }
// converting to lower case
wstrToLower(temp);
if (temp.find(search) == std::wstring::npos)
return false;
{ return false; }
return true;
}
@ -579,9 +579,9 @@ void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result)
unsigned char nibble = 0x0F & (bytes[i] >> ((1 - j) * 4));
char encodedNibble;
if (nibble < 0x0A)
encodedNibble = '0' + nibble;
{ encodedNibble = '0' + nibble; }
else
encodedNibble = 'A' + nibble - 0x0A;
{ encodedNibble = 'A' + nibble - 0x0A; }
ss << encodedNibble;
}
}