mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 13:37:00 +00:00
Cleanup Operator padding
This commit is contained in:
parent
9141299127
commit
e32b9953a1
264 changed files with 6715 additions and 6715 deletions
|
|
@ -139,7 +139,7 @@ uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index)
|
|||
float GetFloatValueFromArray(Tokens const& data, uint16 index)
|
||||
{
|
||||
float result;
|
||||
uint32 temp = GetUInt32ValueFromArray(data,index);
|
||||
uint32 temp = GetUInt32ValueFromArray(data, index);
|
||||
memcpy(&result, &temp, sizeof(result));
|
||||
|
||||
return result;
|
||||
|
|
@ -154,7 +154,7 @@ 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)
|
||||
{
|
||||
|
|
@ -164,7 +164,7 @@ void stripLineInvisibleChars(std::string& str)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (wpos!=pos)
|
||||
if (wpos != pos)
|
||||
str[wpos++] = str[pos];
|
||||
else
|
||||
++wpos;
|
||||
|
|
@ -173,7 +173,7 @@ void stripLineInvisibleChars(std::string& str)
|
|||
}
|
||||
|
||||
if (wpos < str.size())
|
||||
str.erase(wpos,str.size());
|
||||
str.erase(wpos, str.size());
|
||||
}
|
||||
|
||||
std::string secsToTimeString(time_t timeInSecs, bool shortText, bool hoursOnly)
|
||||
|
|
@ -209,8 +209,8 @@ uint32 TimeStringToSecs(const std::string& timestring)
|
|||
{
|
||||
if (isdigit(*itr))
|
||||
{
|
||||
buffer*=10;
|
||||
buffer+= (*itr)-'0';
|
||||
buffer *= 10;
|
||||
buffer += (*itr) - '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -222,9 +222,9 @@ uint32 TimeStringToSecs(const std::string& timestring)
|
|||
case 's': multiplier = 1; break;
|
||||
default : return 0; //bad format
|
||||
}
|
||||
buffer*=multiplier;
|
||||
secs+=buffer;
|
||||
buffer=0;
|
||||
buffer *= multiplier;
|
||||
secs += buffer;
|
||||
buffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +241,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);
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +279,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)
|
||||
{
|
||||
|
|
@ -288,20 +288,20 @@ 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]);
|
||||
utf8str.resize(oend-(&utf8str[0])); // remove unused tail
|
||||
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)
|
||||
{
|
||||
|
|
@ -313,7 +313,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)
|
||||
|
|
@ -323,7 +323,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)
|
||||
|
|
@ -341,11 +341,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)
|
||||
{
|
||||
|
|
@ -361,10 +361,10 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str)
|
|||
try
|
||||
{
|
||||
std::string utf8str2;
|
||||
utf8str2.resize(size*4); // allocate for most long case
|
||||
utf8str2.resize(size * 4); // allocate for most long case
|
||||
|
||||
char* oend = utf8::utf16to8(wstr,wstr+size,&utf8str2[0]);
|
||||
utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail
|
||||
char* oend = utf8::utf16to8(wstr, wstr + size, &utf8str2[0]);
|
||||
utf8str2.resize(oend - (&utf8str2[0])); // remove unused tail
|
||||
utf8str = utf8str2;
|
||||
}
|
||||
catch (std::exception)
|
||||
|
|
@ -381,10 +381,10 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str)
|
|||
try
|
||||
{
|
||||
std::string utf8str2;
|
||||
utf8str2.resize(wstr.size()*4); // allocate for most long case
|
||||
utf8str2.resize(wstr.size() * 4); // allocate for most long case
|
||||
|
||||
char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str2[0]);
|
||||
utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail
|
||||
char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str() + wstr.size(), &utf8str2[0]);
|
||||
utf8str2.resize(oend - (&utf8str2[0])); // remove unused tail
|
||||
utf8str = utf8str2;
|
||||
}
|
||||
catch (std::exception)
|
||||
|
|
@ -406,22 +406,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] =
|
||||
{
|
||||
|
|
@ -437,8 +437,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;
|
||||
|
|
@ -448,11 +448,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;
|
||||
|
|
@ -461,14 +461,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;
|
||||
|
|
@ -480,7 +480,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
|
||||
|
|
@ -503,15 +503,15 @@ void utf8printf(FILE* out, const char* str, ...)
|
|||
void vutf8printf(FILE* out, const char* str, va_list* ap)
|
||||
{
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
char temp_buf[32*1024];
|
||||
wchar_t wtemp_buf[32*1024];
|
||||
char temp_buf[32 * 1024];
|
||||
wchar_t wtemp_buf[32 * 1024];
|
||||
|
||||
size_t temp_len = vsnprintf(temp_buf, 32*1024, str, *ap);
|
||||
size_t temp_len = vsnprintf(temp_buf, 32 * 1024, str, *ap);
|
||||
|
||||
size_t wtemp_len = 32*1024-1;
|
||||
size_t wtemp_len = 32 * 1024 - 1;
|
||||
Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len);
|
||||
|
||||
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len+1);
|
||||
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len + 1);
|
||||
fprintf(out, "%s", temp_buf);
|
||||
#else
|
||||
vfprintf(out, str, *ap);
|
||||
|
|
@ -521,16 +521,16 @@ void vutf8printf(FILE* out, const char* str, va_list* ap)
|
|||
void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
for (uint32 i=0; i<arrayLen; ++i)
|
||||
for (uint32 i = 0; i < arrayLen; ++i)
|
||||
{
|
||||
for (uint8 j=0; j<2; ++j)
|
||||
for (uint8 j = 0; j < 2; ++j)
|
||||
{
|
||||
unsigned char nibble = 0x0F & (bytes[i]>>((1-j)*4));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue