mirror of
https://github.com/mangosfour/server.git
synced 2025-12-25 22:37:04 +00:00
Cleanup Operator padding
This commit is contained in:
parent
9141299127
commit
e32b9953a1
264 changed files with 6715 additions and 6715 deletions
|
|
@ -162,7 +162,7 @@ uint32 BigNumber::AsDword()
|
|||
|
||||
bool BigNumber::isZero() const
|
||||
{
|
||||
return BN_is_zero(_bn)!=0;
|
||||
return BN_is_zero(_bn) != 0;
|
||||
}
|
||||
|
||||
uint8* BigNumber::AsByteArray(int minSize, bool reverse)
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ class ByteBuffer
|
|||
_rpos = _wpos = 0;
|
||||
}
|
||||
|
||||
template <typename T> void put(size_t pos,T value)
|
||||
template <typename T> void put(size_t pos, T value)
|
||||
{
|
||||
EndianConvert(value);
|
||||
put(pos,(uint8*)&value,sizeof(value));
|
||||
put(pos, (uint8*)&value, sizeof(value));
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(uint8 value)
|
||||
|
|
@ -384,7 +384,7 @@ class ByteBuffer
|
|||
|
||||
void appendPackGUID(uint64 guid)
|
||||
{
|
||||
uint8 packGUID[8+1];
|
||||
uint8 packGUID[8 + 1];
|
||||
packGUID[0] = 0;
|
||||
size_t size = 1;
|
||||
for (uint8 i = 0; guid != 0; ++i)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ LocaleNameStr const fullLocaleNameList[] =
|
|||
LocaleConstant GetLocaleByName(const std::string& name)
|
||||
{
|
||||
for (LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr)
|
||||
if (name==itr->name)
|
||||
if (name == itr->name)
|
||||
return itr->locale;
|
||||
|
||||
return LOCALE_enUS; // including enGB case
|
||||
|
|
|
|||
|
|
@ -166,11 +166,11 @@ inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; }
|
|||
enum TimeConstants
|
||||
{
|
||||
MINUTE = 60,
|
||||
HOUR = MINUTE*60,
|
||||
DAY = HOUR*24,
|
||||
WEEK = DAY*7,
|
||||
MONTH = DAY*30,
|
||||
YEAR = MONTH*12,
|
||||
HOUR = MINUTE * 60,
|
||||
DAY = HOUR * 24,
|
||||
WEEK = DAY * 7,
|
||||
MONTH = DAY * 30,
|
||||
YEAR = MONTH * 12,
|
||||
IN_MILLISECONDS = 1000
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -35,35 +35,35 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt)
|
|||
if (data)
|
||||
{
|
||||
delete [] data;
|
||||
data=NULL;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
FILE* f=fopen(filename,"rb");
|
||||
FILE* f = fopen(filename, "rb");
|
||||
if (!f)return false;
|
||||
|
||||
if (fread(&header,4,1,f)!=1) // Number of records
|
||||
if (fread(&header, 4, 1, f) != 1) // Number of records
|
||||
return false;
|
||||
|
||||
EndianConvert(header);
|
||||
if (header!=0x43424457)
|
||||
if (header != 0x43424457)
|
||||
return false; //'WDBC'
|
||||
|
||||
if (fread(&recordCount,4,1,f)!=1) // Number of records
|
||||
if (fread(&recordCount, 4, 1, f) != 1) // Number of records
|
||||
return false;
|
||||
|
||||
EndianConvert(recordCount);
|
||||
|
||||
if (fread(&fieldCount,4,1,f)!=1) // Number of fields
|
||||
if (fread(&fieldCount, 4, 1, f) != 1) // Number of fields
|
||||
return false;
|
||||
|
||||
EndianConvert(fieldCount);
|
||||
|
||||
if (fread(&recordSize,4,1,f)!=1) // Size of a record
|
||||
if (fread(&recordSize, 4, 1, f) != 1) // Size of a record
|
||||
return false;
|
||||
|
||||
EndianConvert(recordSize);
|
||||
|
||||
if (fread(&stringSize,4,1,f)!=1) // String size
|
||||
if (fread(&stringSize, 4, 1, f) != 1) // String size
|
||||
return false;
|
||||
|
||||
EndianConvert(stringSize);
|
||||
|
|
@ -79,10 +79,10 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt)
|
|||
fieldsOffset[i] += 4;
|
||||
}
|
||||
|
||||
data = new unsigned char[recordSize*recordCount+stringSize];
|
||||
stringTable = data + recordSize*recordCount;
|
||||
data = new unsigned char[recordSize * recordCount + stringSize];
|
||||
stringTable = data + recordSize * recordCount;
|
||||
|
||||
if (fread(data,recordSize*recordCount+stringSize,1,f)!=1)
|
||||
if (fread(data, recordSize * recordCount + stringSize, 1, f) != 1)
|
||||
return false;
|
||||
|
||||
fclose(f);
|
||||
|
|
@ -100,10 +100,10 @@ DBCFileLoader::~DBCFileLoader()
|
|||
DBCFileLoader::Record DBCFileLoader::getRecord(size_t id)
|
||||
{
|
||||
assert(data);
|
||||
return Record(*this, data + id*recordSize);
|
||||
return Record(*this, data + id * recordSize);
|
||||
}
|
||||
|
||||
uint32 DBCFileLoader::GetFormatRecordSize(const char* format,int32* index_pos)
|
||||
uint32 DBCFileLoader::GetFormatRecordSize(const char* format, int32* index_pos)
|
||||
{
|
||||
uint32 recordsize = 0;
|
||||
int32 i = -1;
|
||||
|
|
@ -121,10 +121,10 @@ uint32 DBCFileLoader::GetFormatRecordSize(const char* format,int32* index_pos)
|
|||
recordsize += sizeof(char*);
|
||||
break;
|
||||
case FT_SORT:
|
||||
i=x;
|
||||
i = x;
|
||||
break;
|
||||
case FT_IND:
|
||||
i=x;
|
||||
i = x;
|
||||
recordsize += sizeof(uint32);
|
||||
break;
|
||||
case FT_BYTE:
|
||||
|
|
@ -162,27 +162,27 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**
|
|||
*/
|
||||
|
||||
typedef char* ptr;
|
||||
if (strlen(format)!=fieldCount)
|
||||
if (strlen(format) != fieldCount)
|
||||
return NULL;
|
||||
|
||||
//get struct size and index pos
|
||||
int32 i;
|
||||
uint32 recordsize=GetFormatRecordSize(format,&i);
|
||||
uint32 recordsize = GetFormatRecordSize(format, &i);
|
||||
|
||||
if (i>=0)
|
||||
if (i >= 0)
|
||||
{
|
||||
uint32 maxi=0;
|
||||
uint32 maxi = 0;
|
||||
//find max index
|
||||
for (uint32 y=0; y<recordCount; y++)
|
||||
for (uint32 y = 0; y < recordCount; y++)
|
||||
{
|
||||
uint32 ind=getRecord(y).getUInt(i);
|
||||
if (ind>maxi)maxi=ind;
|
||||
uint32 ind = getRecord(y).getUInt(i);
|
||||
if (ind > maxi)maxi = ind;
|
||||
}
|
||||
|
||||
++maxi;
|
||||
records=maxi;
|
||||
indexTable=new ptr[maxi];
|
||||
memset(indexTable,0,maxi*sizeof(ptr));
|
||||
records = maxi;
|
||||
indexTable = new ptr[maxi];
|
||||
memset(indexTable, 0, maxi * sizeof(ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -190,38 +190,38 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**
|
|||
indexTable = new ptr[recordCount];
|
||||
}
|
||||
|
||||
char* dataTable= new char[recordCount*recordsize];
|
||||
char* dataTable = new char[recordCount * recordsize];
|
||||
|
||||
uint32 offset=0;
|
||||
uint32 offset = 0;
|
||||
|
||||
for (uint32 y =0; y < recordCount; ++y)
|
||||
for (uint32 y = 0; y < recordCount; ++y)
|
||||
{
|
||||
if (i >= 0)
|
||||
{
|
||||
indexTable[getRecord(y).getUInt(i)]=&dataTable[offset];
|
||||
indexTable[getRecord(y).getUInt(i)] = &dataTable[offset];
|
||||
}
|
||||
else
|
||||
indexTable[y]=&dataTable[offset];
|
||||
indexTable[y] = &dataTable[offset];
|
||||
|
||||
for (uint32 x = 0; x < fieldCount; ++x)
|
||||
{
|
||||
switch (format[x])
|
||||
{
|
||||
case FT_FLOAT:
|
||||
*((float*)(&dataTable[offset]))=getRecord(y).getFloat(x);
|
||||
*((float*)(&dataTable[offset])) = getRecord(y).getFloat(x);
|
||||
offset += sizeof(float);
|
||||
break;
|
||||
case FT_IND:
|
||||
case FT_INT:
|
||||
*((uint32*)(&dataTable[offset]))=getRecord(y).getUInt(x);
|
||||
*((uint32*)(&dataTable[offset])) = getRecord(y).getUInt(x);
|
||||
offset += sizeof(uint32);
|
||||
break;
|
||||
case FT_BYTE:
|
||||
*((uint8*)(&dataTable[offset]))=getRecord(y).getUInt8(x);
|
||||
*((uint8*)(&dataTable[offset])) = getRecord(y).getUInt8(x);
|
||||
offset += sizeof(uint8);
|
||||
break;
|
||||
case FT_STRING:
|
||||
*((char**)(&dataTable[offset]))=NULL; // will be replaces non-empty or "" strings in AutoProduceStrings
|
||||
*((char**)(&dataTable[offset])) = NULL; // will be replaces non-empty or "" strings in AutoProduceStrings
|
||||
offset += sizeof(char*);
|
||||
break;
|
||||
case FT_LOGIC:
|
||||
|
|
@ -243,15 +243,15 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**
|
|||
|
||||
char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable)
|
||||
{
|
||||
if (strlen(format)!=fieldCount)
|
||||
if (strlen(format) != fieldCount)
|
||||
return NULL;
|
||||
|
||||
char* stringPool= new char[stringSize];
|
||||
memcpy(stringPool,stringTable,stringSize);
|
||||
char* stringPool = new char[stringSize];
|
||||
memcpy(stringPool, stringTable, stringSize);
|
||||
|
||||
uint32 offset=0;
|
||||
uint32 offset = 0;
|
||||
|
||||
for (uint32 y =0; y < recordCount; ++y)
|
||||
for (uint32 y = 0; y < recordCount; ++y)
|
||||
{
|
||||
for (uint32 x = 0; x < fieldCount; ++x)
|
||||
{
|
||||
|
|
@ -274,7 +274,7 @@ char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable)
|
|||
if (!*slot || !** slot)
|
||||
{
|
||||
const char* st = getRecord(y).getString(x);
|
||||
*slot=stringPool+(st-(const char*)stringTable);
|
||||
*slot = stringPool + (st - (const char*)stringTable);
|
||||
}
|
||||
offset += sizeof(char*);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -24,17 +24,17 @@
|
|||
|
||||
enum
|
||||
{
|
||||
FT_NA='x', // ignore/ default, 4 byte size, in Source String means field is ignored, in Dest String means field is filled with default value
|
||||
FT_NA_BYTE='X', // ignore/ default, 1 byte size, see above
|
||||
FT_NA_FLOAT='F', // ignore/ default, float size, see above
|
||||
FT_NA_POINTER='p', // fill default value into dest, pointer size, Use this only with static data (otherwise mem-leak)
|
||||
FT_STRING='s', //char*
|
||||
FT_FLOAT='f', //float
|
||||
FT_INT='i', //uint32
|
||||
FT_BYTE='b', //uint8
|
||||
FT_SORT='d', //sorted by this field, field is not included
|
||||
FT_IND='n', //the same,but parsed to data
|
||||
FT_LOGIC='l' //Logical (boolean)
|
||||
FT_NA = 'x', // ignore/ default, 4 byte size, in Source String means field is ignored, in Dest String means field is filled with default value
|
||||
FT_NA_BYTE = 'X', // ignore/ default, 1 byte size, see above
|
||||
FT_NA_FLOAT = 'F', // ignore/ default, float size, see above
|
||||
FT_NA_POINTER = 'p', // fill default value into dest, pointer size, Use this only with static data (otherwise mem-leak)
|
||||
FT_STRING = 's', //char*
|
||||
FT_FLOAT = 'f', //float
|
||||
FT_INT = 'i', //uint32
|
||||
FT_BYTE = 'b', //uint8
|
||||
FT_SORT = 'd', //sorted by this field, field is not included
|
||||
FT_IND = 'n', //the same,but parsed to data
|
||||
FT_LOGIC = 'l' //Logical (boolean)
|
||||
};
|
||||
|
||||
class DBCFileLoader
|
||||
|
|
@ -51,21 +51,21 @@ class DBCFileLoader
|
|||
float getFloat(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
float val = *reinterpret_cast<float*>(offset+file.GetOffset(field));
|
||||
float val = *reinterpret_cast<float*>(offset + file.GetOffset(field));
|
||||
EndianConvert(val);
|
||||
return val;
|
||||
}
|
||||
uint32 getUInt(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
uint32 val = *reinterpret_cast<uint32*>(offset+file.GetOffset(field));
|
||||
uint32 val = *reinterpret_cast<uint32*>(offset + file.GetOffset(field));
|
||||
EndianConvert(val);
|
||||
return val;
|
||||
}
|
||||
uint8 getUInt8(size_t field) const
|
||||
{
|
||||
assert(field < file.fieldCount);
|
||||
return *reinterpret_cast<uint8*>(offset+file.GetOffset(field));
|
||||
return *reinterpret_cast<uint8*>(offset + file.GetOffset(field));
|
||||
}
|
||||
|
||||
const char* getString(size_t field) const
|
||||
|
|
@ -92,7 +92,7 @@ class DBCFileLoader
|
|||
uint32 GetNumRows() const { return recordCount;}
|
||||
uint32 GetCols() const { return fieldCount; }
|
||||
uint32 GetOffset(size_t id) const { return (fieldsOffset != NULL && id < fieldCount) ? fieldsOffset[id] : 0; }
|
||||
bool IsLoaded() {return (data!=NULL);}
|
||||
bool IsLoaded() {return (data != NULL);}
|
||||
char* AutoProduceData(const char* fmt, uint32& count, char**& indexTable);
|
||||
char* AutoProduceStrings(const char* fmt, char* dataTable);
|
||||
static uint32 GetFormatRecordSize(const char* format, int32* index_pos = NULL);
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@ class DBCStorage
|
|||
fieldCount = dbc.GetCols();
|
||||
|
||||
// load raw non-string data
|
||||
m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable);
|
||||
m_dataTable = (T*)dbc.AutoProduceData(fmt, nCount, (char**&)indexTable);
|
||||
|
||||
// load strings from dbc data
|
||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable));
|
||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable));
|
||||
|
||||
// error in dbc file at loading if NULL
|
||||
return indexTable!=NULL;
|
||||
return indexTable != NULL;
|
||||
}
|
||||
|
||||
bool LoadStringsFrom(char const* fn)
|
||||
|
|
@ -65,7 +65,7 @@ class DBCStorage
|
|||
return false;
|
||||
|
||||
// load strings from another locale dbc data
|
||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable));
|
||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/)
|
|||
// Enable logging of SQL commands (usually only GM commands)
|
||||
// (See method: PExecuteLog)
|
||||
m_logSQL = sConfig.GetBoolDefault("LogSQL", false);
|
||||
m_logsDir = sConfig.GetStringDefault("LogsDir","");
|
||||
m_logsDir = sConfig.GetStringDefault("LogsDir", "");
|
||||
if (!m_logsDir.empty())
|
||||
{
|
||||
if ((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
||||
if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
|
||||
m_logsDir.append("/");
|
||||
}
|
||||
|
||||
|
|
@ -215,9 +215,9 @@ void Database::escape_string(std::string& str)
|
|||
if (str.empty())
|
||||
return;
|
||||
|
||||
char* buf = new char[str.size()*2+1];
|
||||
char* buf = new char[str.size() * 2 + 1];
|
||||
//we don't care what connection to use - escape string will be the same
|
||||
m_pQueryConnections[0]->escape_string(buf,str.c_str(),str.size());
|
||||
m_pQueryConnections[0]->escape_string(buf, str.c_str(), str.size());
|
||||
str = buf;
|
||||
delete[] buf;
|
||||
}
|
||||
|
|
@ -250,7 +250,7 @@ void Database::Ping()
|
|||
}
|
||||
}
|
||||
|
||||
bool Database::PExecuteLog(const char* format,...)
|
||||
bool Database::PExecuteLog(const char* format, ...)
|
||||
{
|
||||
if (!format)
|
||||
return false;
|
||||
|
|
@ -261,9 +261,9 @@ bool Database::PExecuteLog(const char* format,...)
|
|||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (res==-1)
|
||||
if (res == -1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s", format);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -272,12 +272,12 @@ bool Database::PExecuteLog(const char* format,...)
|
|||
time_t curr;
|
||||
tm local;
|
||||
time(&curr); // get current time_t value
|
||||
local=*(localtime(&curr)); // dereference and assign
|
||||
local = *(localtime(&curr)); // dereference and assign
|
||||
char fName[128];
|
||||
sprintf(fName, "%04d-%02d-%02d_logSQL.sql", local.tm_year+1900, local.tm_mon+1, local.tm_mday);
|
||||
sprintf(fName, "%04d-%02d-%02d_logSQL.sql", local.tm_year + 1900, local.tm_mon + 1, local.tm_mday);
|
||||
|
||||
FILE* log_file;
|
||||
std::string logsDir_fname = m_logsDir+fName;
|
||||
std::string logsDir_fname = m_logsDir + fName;
|
||||
log_file = fopen(logsDir_fname.c_str(), "a");
|
||||
if (log_file)
|
||||
{
|
||||
|
|
@ -287,14 +287,14 @@ bool Database::PExecuteLog(const char* format,...)
|
|||
else
|
||||
{
|
||||
// The file could not be opened
|
||||
sLog.outError("SQL-Logging is disabled - Log file for the SQL commands could not be openend: %s",fName);
|
||||
sLog.outError("SQL-Logging is disabled - Log file for the SQL commands could not be openend: %s", fName);
|
||||
}
|
||||
}
|
||||
|
||||
return Execute(szQuery);
|
||||
}
|
||||
|
||||
QueryResult* Database::PQuery(const char* format,...)
|
||||
QueryResult* Database::PQuery(const char* format, ...)
|
||||
{
|
||||
if (!format) return NULL;
|
||||
|
||||
|
|
@ -304,16 +304,16 @@ QueryResult* Database::PQuery(const char* format,...)
|
|||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (res==-1)
|
||||
if (res == -1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s", format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Query(szQuery);
|
||||
}
|
||||
|
||||
QueryNamedResult* Database::PQueryNamed(const char* format,...)
|
||||
QueryNamedResult* Database::PQueryNamed(const char* format, ...)
|
||||
{
|
||||
if (!format) return NULL;
|
||||
|
||||
|
|
@ -323,9 +323,9 @@ QueryNamedResult* Database::PQueryNamed(const char* format,...)
|
|||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (res==-1)
|
||||
if (res == -1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s", format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ bool Database::Execute(const char* sql)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Database::PExecute(const char* format,...)
|
||||
bool Database::PExecute(const char* format, ...)
|
||||
{
|
||||
if (!format)
|
||||
return false;
|
||||
|
|
@ -367,16 +367,16 @@ bool Database::PExecute(const char* format,...)
|
|||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (res==-1)
|
||||
if (res == -1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s", format);
|
||||
return false;
|
||||
}
|
||||
|
||||
return Execute(szQuery);
|
||||
}
|
||||
|
||||
bool Database::DirectPExecute(const char* format,...)
|
||||
bool Database::DirectPExecute(const char* format, ...)
|
||||
{
|
||||
if (!format)
|
||||
return false;
|
||||
|
|
@ -387,9 +387,9 @@ bool Database::DirectPExecute(const char* format,...)
|
|||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (res==-1)
|
||||
if (res == -1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s", format);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -459,7 +459,7 @@ bool Database::RollbackTransaction()
|
|||
bool Database::CheckRequiredField(char const* table_name, char const* required_name)
|
||||
{
|
||||
// check required field
|
||||
QueryResult* result = PQuery("SELECT %s FROM %s LIMIT 1",required_name,table_name);
|
||||
QueryResult* result = PQuery("SELECT %s FROM %s LIMIT 1", required_name, table_name);
|
||||
if (result)
|
||||
{
|
||||
delete result;
|
||||
|
|
@ -479,16 +479,16 @@ bool Database::CheckRequiredField(char const* table_name, char const* required_n
|
|||
else
|
||||
db_name = "UNKNOWN";
|
||||
|
||||
char const* req_sql_update_name = required_name+strlen("required_");
|
||||
char const* req_sql_update_name = required_name + strlen("required_");
|
||||
|
||||
QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1",table_name);
|
||||
QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1", table_name);
|
||||
if (result2)
|
||||
{
|
||||
QueryFieldNames const& namesMap = result2->GetFieldNames();
|
||||
std::string reqName;
|
||||
for (QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr)
|
||||
{
|
||||
if (itr->substr(0,9)=="required_")
|
||||
if (itr->substr(0, 9) == "required_")
|
||||
{
|
||||
reqName = *itr;
|
||||
break;
|
||||
|
|
@ -497,15 +497,15 @@ bool Database::CheckRequiredField(char const* table_name, char const* required_n
|
|||
|
||||
delete result2;
|
||||
|
||||
std::string cur_sql_update_name = reqName.substr(strlen("required_"),reqName.npos);
|
||||
std::string cur_sql_update_name = reqName.substr(strlen("required_"), reqName.npos);
|
||||
|
||||
if (!reqName.empty())
|
||||
{
|
||||
sLog.outErrorDb("The table `%s` in your [%s] database indicates that this database is out of date!",table_name,db_name);
|
||||
sLog.outErrorDb("The table `%s` in your [%s] database indicates that this database is out of date!", table_name, db_name);
|
||||
sLog.outErrorDb();
|
||||
sLog.outErrorDb(" [A] You have: --> `%s.sql`",cur_sql_update_name.c_str());
|
||||
sLog.outErrorDb(" [A] You have: --> `%s.sql`", cur_sql_update_name.c_str());
|
||||
sLog.outErrorDb();
|
||||
sLog.outErrorDb(" [B] You need: --> `%s.sql`",req_sql_update_name);
|
||||
sLog.outErrorDb(" [B] You need: --> `%s.sql`", req_sql_update_name);
|
||||
sLog.outErrorDb();
|
||||
sLog.outErrorDb("You must apply all updates after [A] to [B] to use mangos with this database.");
|
||||
sLog.outErrorDb("These updates are included in the sql/updates folder.");
|
||||
|
|
@ -513,32 +513,32 @@ bool Database::CheckRequiredField(char const* table_name, char const* required_n
|
|||
}
|
||||
else
|
||||
{
|
||||
sLog.outErrorDb("The table `%s` in your [%s] database is missing its version info.",table_name,db_name);
|
||||
sLog.outErrorDb("The table `%s` in your [%s] database is missing its version info.", table_name, db_name);
|
||||
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.");
|
||||
sLog.outErrorDb();
|
||||
sLog.outErrorDb("This revision of MaNGOS requires a database updated to:");
|
||||
sLog.outErrorDb("`%s.sql`",req_sql_update_name);
|
||||
sLog.outErrorDb("`%s.sql`", req_sql_update_name);
|
||||
sLog.outErrorDb();
|
||||
|
||||
if (!strcmp(db_name, "WORLD"))
|
||||
sLog.outErrorDb("Post this error to your database provider forum or find a solution there.");
|
||||
else
|
||||
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name);
|
||||
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.", db_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outErrorDb("The table `%s` in your [%s] database is missing or corrupt.",table_name,db_name);
|
||||
sLog.outErrorDb("The table `%s` in your [%s] database is missing or corrupt.", table_name, db_name);
|
||||
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.");
|
||||
sLog.outErrorDb();
|
||||
sLog.outErrorDb("This revision of mangos requires a database updated to:");
|
||||
sLog.outErrorDb("`%s.sql`",req_sql_update_name);
|
||||
sLog.outErrorDb("`%s.sql`", req_sql_update_name);
|
||||
sLog.outErrorDb();
|
||||
|
||||
if (!strcmp(db_name, "WORLD"))
|
||||
sLog.outErrorDb("Post this error to your database provider forum or find a solution there.");
|
||||
else
|
||||
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name);
|
||||
sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.", db_name);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class MANGOS_DLL_SPEC SqlConnection
|
|||
virtual bool Execute(const char* sql) = 0;
|
||||
|
||||
//escape string generation
|
||||
virtual unsigned long escape_string(char* to, const char* from, unsigned long length) { strncpy(to,from,length); return length; }
|
||||
virtual unsigned long escape_string(char* to, const char* from, unsigned long length) { strncpy(to, from, length); return length; }
|
||||
|
||||
// nothing do if DB not support transactions
|
||||
virtual bool BeginTransaction() { return true; }
|
||||
|
|
@ -124,8 +124,8 @@ class MANGOS_DLL_SPEC Database
|
|||
return guard->QueryNamed(sql);
|
||||
}
|
||||
|
||||
QueryResult* PQuery(const char* format,...) ATTR_PRINTF(2,3);
|
||||
QueryNamedResult* PQueryNamed(const char* format,...) ATTR_PRINTF(2,3);
|
||||
QueryResult* PQuery(const char* format, ...) ATTR_PRINTF(2, 3);
|
||||
QueryNamedResult* PQueryNamed(const char* format, ...) ATTR_PRINTF(2, 3);
|
||||
|
||||
inline bool DirectExecute(const char* sql)
|
||||
{
|
||||
|
|
@ -136,7 +136,7 @@ class MANGOS_DLL_SPEC Database
|
|||
return guard->Execute(sql);
|
||||
}
|
||||
|
||||
bool DirectPExecute(const char* format,...) ATTR_PRINTF(2,3);
|
||||
bool DirectPExecute(const char* format, ...) ATTR_PRINTF(2, 3);
|
||||
|
||||
/// Async queries and query holders, implemented in DatabaseImpl.h
|
||||
|
||||
|
|
@ -158,20 +158,20 @@ class MANGOS_DLL_SPEC Database
|
|||
bool AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* sql);
|
||||
// PQuery / member
|
||||
template<class Class>
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format,...) ATTR_PRINTF(4,5);
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format, ...) ATTR_PRINTF(4, 5);
|
||||
template<class Class, typename ParamType1>
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...) ATTR_PRINTF(5,6);
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...) ATTR_PRINTF(5, 6);
|
||||
template<class Class, typename ParamType1, typename ParamType2>
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...) ATTR_PRINTF(6,7);
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...) ATTR_PRINTF(6, 7);
|
||||
template<class Class, typename ParamType1, typename ParamType2, typename ParamType3>
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...) ATTR_PRINTF(7,8);
|
||||
bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...) ATTR_PRINTF(7, 8);
|
||||
// PQuery / static
|
||||
template<typename ParamType1>
|
||||
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...) ATTR_PRINTF(4,5);
|
||||
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...) ATTR_PRINTF(4, 5);
|
||||
template<typename ParamType1, typename ParamType2>
|
||||
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...) ATTR_PRINTF(5,6);
|
||||
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...) ATTR_PRINTF(5, 6);
|
||||
template<typename ParamType1, typename ParamType2, typename ParamType3>
|
||||
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...) ATTR_PRINTF(6,7);
|
||||
bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...) ATTR_PRINTF(6, 7);
|
||||
template<class Class>
|
||||
// QueryHolder
|
||||
bool DelayQueryHolder(Class* object, void (Class::*method)(QueryResult*, SqlQueryHolder*), SqlQueryHolder* holder);
|
||||
|
|
@ -179,10 +179,10 @@ class MANGOS_DLL_SPEC Database
|
|||
bool DelayQueryHolder(Class* object, void (Class::*method)(QueryResult*, SqlQueryHolder*, ParamType1), SqlQueryHolder* holder, ParamType1 param1);
|
||||
|
||||
bool Execute(const char* sql);
|
||||
bool PExecute(const char* format,...) ATTR_PRINTF(2,3);
|
||||
bool PExecute(const char* format, ...) ATTR_PRINTF(2, 3);
|
||||
|
||||
// Writes SQL commands to a LOG file (see mangosd.conf "LogSQL")
|
||||
bool PExecuteLog(const char* format,...) ATTR_PRINTF(2,3);
|
||||
bool PExecuteLog(const char* format, ...) ATTR_PRINTF(2, 3);
|
||||
|
||||
bool BeginTransaction();
|
||||
bool CommitTransaction();
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ Database::AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamT
|
|||
|
||||
template<class Class>
|
||||
bool
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format,...)
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format, ...)
|
||||
{
|
||||
ASYNC_PQUERY_BODY(format, szQuery)
|
||||
return AsyncQuery(object, method, szQuery);
|
||||
|
|
@ -115,7 +115,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const
|
|||
|
||||
template<class Class, typename ParamType1>
|
||||
bool
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...)
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...)
|
||||
{
|
||||
ASYNC_PQUERY_BODY(format, szQuery)
|
||||
return AsyncQuery(object, method, param1, szQuery);
|
||||
|
|
@ -123,7 +123,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamTy
|
|||
|
||||
template<class Class, typename ParamType1, typename ParamType2>
|
||||
bool
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...)
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...)
|
||||
{
|
||||
ASYNC_PQUERY_BODY(format, szQuery)
|
||||
return AsyncQuery(object, method, param1, param2, szQuery);
|
||||
|
|
@ -131,7 +131,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamTy
|
|||
|
||||
template<class Class, typename ParamType1, typename ParamType2, typename ParamType3>
|
||||
bool
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...)
|
||||
Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...)
|
||||
{
|
||||
ASYNC_PQUERY_BODY(format, szQuery)
|
||||
return AsyncQuery(object, method, param1, param2, param3, szQuery);
|
||||
|
|
@ -141,7 +141,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamTy
|
|||
|
||||
template<typename ParamType1>
|
||||
bool
|
||||
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...)
|
||||
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...)
|
||||
{
|
||||
ASYNC_PQUERY_BODY(format, szQuery)
|
||||
return AsyncQuery(method, param1, szQuery);
|
||||
|
|
@ -149,7 +149,7 @@ Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param
|
|||
|
||||
template<typename ParamType1, typename ParamType2>
|
||||
bool
|
||||
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...)
|
||||
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...)
|
||||
{
|
||||
ASYNC_PQUERY_BODY(format, szQuery)
|
||||
return AsyncQuery(method, param1, param2, szQuery);
|
||||
|
|
@ -157,7 +157,7 @@ Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), Para
|
|||
|
||||
template<typename ParamType1, typename ParamType2, typename ParamType3>
|
||||
bool
|
||||
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...)
|
||||
Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...)
|
||||
{
|
||||
ASYNC_PQUERY_BODY(format, szQuery)
|
||||
return AsyncQuery(method, param1, param2, param3, szQuery);
|
||||
|
|
|
|||
|
|
@ -104,12 +104,12 @@ bool MySQLConnection::Initialize(const char* infoString)
|
|||
if (iter != tokens.end())
|
||||
database = *iter++;
|
||||
|
||||
mysql_options(mysqlInit,MYSQL_SET_CHARSET_NAME,"utf8");
|
||||
mysql_options(mysqlInit, MYSQL_SET_CHARSET_NAME, "utf8");
|
||||
#ifdef WIN32
|
||||
if (host==".") // named pipe use option (Windows)
|
||||
if (host == ".") // named pipe use option (Windows)
|
||||
{
|
||||
unsigned int opt = MYSQL_PROTOCOL_PIPE;
|
||||
mysql_options(mysqlInit,MYSQL_OPT_PROTOCOL,(char const*)&opt);
|
||||
mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt);
|
||||
port = 0;
|
||||
unix_socket = 0;
|
||||
}
|
||||
|
|
@ -119,10 +119,10 @@ bool MySQLConnection::Initialize(const char* infoString)
|
|||
unix_socket = 0;
|
||||
}
|
||||
#else
|
||||
if (host==".") // socket use option (Unix/Linux)
|
||||
if (host == ".") // socket use option (Unix/Linux)
|
||||
{
|
||||
unsigned int opt = MYSQL_PROTOCOL_SOCKET;
|
||||
mysql_options(mysqlInit,MYSQL_OPT_PROTOCOL,(char const*)&opt);
|
||||
mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt);
|
||||
host = "localhost";
|
||||
port = 0;
|
||||
unix_socket = port_or_socket.c_str();
|
||||
|
|
@ -140,7 +140,7 @@ bool MySQLConnection::Initialize(const char* infoString)
|
|||
if (!mMysql)
|
||||
{
|
||||
sLog.outError("Could not connect to MySQL database at %s: %s\n",
|
||||
host.c_str(),mysql_error(mysqlInit));
|
||||
host.c_str(), mysql_error(mysqlInit));
|
||||
mysql_close(mysqlInit);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ bool MySQLConnection::_Query(const char* sql, MYSQL_RES** pResult, MYSQL_FIELD**
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql);
|
||||
}
|
||||
|
||||
*pResult = mysql_store_result(mMysql);
|
||||
|
|
@ -216,7 +216,7 @@ QueryResult* MySQLConnection::Query(const char* sql)
|
|||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(sql,&result,&fields,&rowCount,&fieldCount))
|
||||
if (!_Query(sql, &result, &fields, &rowCount, &fieldCount))
|
||||
return NULL;
|
||||
|
||||
QueryResultMysql* queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount);
|
||||
|
|
@ -232,7 +232,7 @@ QueryNamedResult* MySQLConnection::QueryNamed(const char* sql)
|
|||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(sql,&result,&fields,&rowCount,&fieldCount))
|
||||
if (!_Query(sql, &result, &fields, &rowCount, &fieldCount))
|
||||
return NULL;
|
||||
|
||||
QueryFieldNames names(fieldCount);
|
||||
|
|
@ -242,7 +242,7 @@ QueryNamedResult* MySQLConnection::QueryNamed(const char* sql)
|
|||
QueryResultMysql* queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount);
|
||||
|
||||
queryResult->NextRow();
|
||||
return new QueryNamedResult(queryResult,names);
|
||||
return new QueryNamedResult(queryResult, names);
|
||||
}
|
||||
|
||||
bool MySQLConnection::Execute(const char* sql)
|
||||
|
|
@ -261,7 +261,7 @@ bool MySQLConnection::Execute(const char* sql)
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql);
|
||||
}
|
||||
// end guarded block
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ bool PostgreSQLConnection::_Query(const char* sql, PGresult** pResult, uint64* p
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql);
|
||||
}
|
||||
|
||||
*pRowCount = PQntuples(*pResult);
|
||||
|
|
@ -142,7 +142,7 @@ QueryResult* PostgreSQLConnection::Query(const char* sql)
|
|||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(sql,&result,&rowCount,&fieldCount))
|
||||
if (!_Query(sql, &result, &rowCount, &fieldCount))
|
||||
return NULL;
|
||||
|
||||
QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
|
||||
|
|
@ -160,7 +160,7 @@ QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql)
|
|||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(sql,&result,&rowCount,&fieldCount))
|
||||
if (!_Query(sql, &result, &rowCount, &fieldCount))
|
||||
return NULL;
|
||||
|
||||
QueryFieldNames names(fieldCount);
|
||||
|
|
@ -170,7 +170,7 @@ QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql)
|
|||
QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
|
||||
|
||||
queryResult->NextRow();
|
||||
return new QueryNamedResult(queryResult,names);
|
||||
return new QueryNamedResult(queryResult, names);
|
||||
}
|
||||
|
||||
bool PostgreSQLConnection::Execute(const char* sql)
|
||||
|
|
@ -189,7 +189,7 @@ bool PostgreSQLConnection::Execute(const char* sql)
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Field
|
|||
uint64 GetUInt64() const
|
||||
{
|
||||
uint64 value = 0;
|
||||
if (!mValue || sscanf(mValue,UI64FMTD,&value) == -1)
|
||||
if (!mValue || sscanf(mValue, UI64FMTD, &value) == -1)
|
||||
return 0;
|
||||
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void SQLStorage::EraseEntry(uint32 id)
|
|||
case FT_STRING:
|
||||
{
|
||||
if (pIndex[id])
|
||||
delete [] *(char**)((char*)(pIndex[id])+offset);
|
||||
delete [] *(char**)((char*)(pIndex[id]) + offset);
|
||||
|
||||
offset += sizeof(char*);
|
||||
break;
|
||||
|
|
@ -81,7 +81,7 @@ void SQLStorage::Free()
|
|||
{
|
||||
for (uint32 y = 0; y < MaxEntry; ++y)
|
||||
if (pIndex[y])
|
||||
delete [] *(char**)((char*)(pIndex[y])+offset);
|
||||
delete [] *(char**)((char*)(pIndex[y]) + offset);
|
||||
|
||||
offset += sizeof(char*);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class SQLStorage
|
|||
void init(const char* _entry_field, const char* sqlname)
|
||||
{
|
||||
entry_field = _entry_field;
|
||||
table=sqlname;
|
||||
table = sqlname;
|
||||
data = NULL;
|
||||
pIndex = NULL;
|
||||
iNumFields = strlen(src_format);
|
||||
|
|
|
|||
|
|
@ -84,35 +84,35 @@ void SQLStorageLoaderBase<T>::storeValue(V value, SQLStorage& store, char* p, ui
|
|||
{
|
||||
case FT_LOGIC:
|
||||
subclass->convert(x, value, *((bool*)(&p[offset])));
|
||||
offset+=sizeof(bool);
|
||||
offset += sizeof(bool);
|
||||
break;
|
||||
case FT_BYTE:
|
||||
subclass->convert(x, value, *((char*)(&p[offset])));
|
||||
offset+=sizeof(char);
|
||||
offset += sizeof(char);
|
||||
break;
|
||||
case FT_INT:
|
||||
subclass->convert(x, value, *((uint32*)(&p[offset])));
|
||||
offset+=sizeof(uint32);
|
||||
offset += sizeof(uint32);
|
||||
break;
|
||||
case FT_FLOAT:
|
||||
subclass->convert(x, value, *((float*)(&p[offset])));
|
||||
offset+=sizeof(float);
|
||||
offset += sizeof(float);
|
||||
break;
|
||||
case FT_STRING:
|
||||
subclass->convert_to_str(x, value, *((char**)(&p[offset])));
|
||||
offset+=sizeof(char*);
|
||||
offset += sizeof(char*);
|
||||
break;
|
||||
case FT_NA:
|
||||
subclass->default_fill(x, value, *((int32*)(&p[offset])));
|
||||
offset+=sizeof(uint32);
|
||||
offset += sizeof(uint32);
|
||||
break;
|
||||
case FT_NA_BYTE:
|
||||
subclass->default_fill(x, value, *((char*)(&p[offset])));
|
||||
offset+=sizeof(char);
|
||||
offset += sizeof(char);
|
||||
break;
|
||||
case FT_NA_FLOAT:
|
||||
subclass->default_fill(x, value, *((float*)(&p[offset])));
|
||||
offset+=sizeof(float);
|
||||
offset += sizeof(float);
|
||||
break;
|
||||
case FT_IND:
|
||||
case FT_SORT:
|
||||
|
|
@ -132,7 +132,7 @@ void SQLStorageLoaderBase<T>::storeValue(char const* value, SQLStorage& store, c
|
|||
{
|
||||
case FT_LOGIC:
|
||||
subclass->convert_from_str(x, value, *((bool*)(&p[offset])));
|
||||
offset+=sizeof(bool);
|
||||
offset += sizeof(bool);
|
||||
break;
|
||||
case FT_BYTE:
|
||||
subclass->convert_from_str(x, value, *((char*)(&p[offset])));
|
||||
|
|
@ -177,7 +177,7 @@ void SQLStorageLoaderBase<T>::Load(SQLStorage& store, bool error_at_empty /*= tr
|
|||
exit(1); // Stop server at loading non exited table or not accessable table
|
||||
}
|
||||
|
||||
maxi = (*result)[0].GetUInt32()+1;
|
||||
maxi = (*result)[0].GetUInt32() + 1;
|
||||
delete result;
|
||||
|
||||
result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s", store.table);
|
||||
|
|
@ -249,9 +249,9 @@ void SQLStorageLoaderBase<T>::Load(SQLStorage& store, bool error_at_empty /*= tr
|
|||
}
|
||||
|
||||
char** newIndex = new char*[maxi];
|
||||
memset(newIndex, 0, maxi*sizeof(char*));
|
||||
memset(newIndex, 0, maxi * sizeof(char*));
|
||||
|
||||
char* _data= new char[store.RecordCount * recordsize];
|
||||
char* _data = new char[store.RecordCount * recordsize];
|
||||
uint32 count = 0;
|
||||
BarGoLink bar(store.RecordCount);
|
||||
do
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ bool SqlQueryHolder::SetQuery(size_t index, const char* sql)
|
|||
if (m_queries[index].first != NULL)
|
||||
{
|
||||
sLog.outError("Attempt assign query to holder index (" SIZEFMTD ") where other query stored (Old: [%s] New: [%s])",
|
||||
index,m_queries[index].first,sql);
|
||||
index, m_queries[index].first, sql);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ bool SqlQueryHolder::SetPQuery(size_t index, const char* format, ...)
|
|||
{
|
||||
if (!format)
|
||||
{
|
||||
sLog.outError("Query (index: " SIZEFMTD ") is empty.",index);
|
||||
sLog.outError("Query (index: " SIZEFMTD ") is empty.", index);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -153,13 +153,13 @@ bool SqlQueryHolder::SetPQuery(size_t index, const char* format, ...)
|
|||
int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (res==-1)
|
||||
if (res == -1)
|
||||
{
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s",format);
|
||||
sLog.outError("SQL Query truncated (and not execute) for format: %s", format);
|
||||
return false;
|
||||
}
|
||||
|
||||
return SetQuery(index,szQuery);
|
||||
return SetQuery(index, szQuery);
|
||||
}
|
||||
|
||||
QueryResult* SqlQueryHolder::GetResult(size_t index)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class SqlQueryHolder
|
|||
SqlQueryHolder() {}
|
||||
~SqlQueryHolder();
|
||||
bool SetQuery(size_t index, const char* sql);
|
||||
bool SetPQuery(size_t index, const char* format, ...) ATTR_PRINTF(3,4);
|
||||
bool SetPQuery(size_t index, const char* format, ...) ATTR_PRINTF(3, 4);
|
||||
void SetSize(size_t size);
|
||||
QueryResult* GetResult(size_t index);
|
||||
void SetResult(size_t index, QueryResult* result);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace ACE_Based
|
||||
{
|
||||
template <class T, class LockType, typename StorageType=std::deque<T> >
|
||||
template <class T, class LockType, typename StorageType = std::deque<T> >
|
||||
class LockedQueue
|
||||
{
|
||||
//! Lock access to the queue.
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ enum LogType
|
|||
LogError
|
||||
};
|
||||
|
||||
const int LogType_count = int(LogError) +1;
|
||||
const int LogType_count = int(LogError) + 1;
|
||||
|
||||
Log::Log() :
|
||||
raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
|
||||
|
|
@ -134,21 +134,21 @@ void Log::SetColor(bool stdout_stream, Color color)
|
|||
|
||||
enum ANSITextAttr
|
||||
{
|
||||
TA_NORMAL=0,
|
||||
TA_BOLD=1,
|
||||
TA_BLINK=5,
|
||||
TA_REVERSE=7
|
||||
TA_NORMAL = 0,
|
||||
TA_BOLD = 1,
|
||||
TA_BLINK = 5,
|
||||
TA_REVERSE = 7
|
||||
};
|
||||
|
||||
enum ANSIFgTextAttr
|
||||
{
|
||||
FG_BLACK=30, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
|
||||
FG_BLACK = 30, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
|
||||
FG_MAGENTA, FG_CYAN, FG_WHITE, FG_YELLOW
|
||||
};
|
||||
|
||||
enum ANSIBgTextAttr
|
||||
{
|
||||
BG_BLACK=40, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
|
||||
BG_BLACK = 40, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
|
||||
BG_MAGENTA, BG_CYAN, BG_WHITE
|
||||
};
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ void Log::SetColor(bool stdout_stream, Color color)
|
|||
FG_WHITE // LWHITE
|
||||
};
|
||||
|
||||
fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color<Color_count ?";1":""));
|
||||
fprintf((stdout_stream ? stdout : stderr), "\x1b[%d%sm", UnixColorFG[color], (color >= YELLOW && color < Color_count ? ";1" : ""));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ void Log::ResetColor(bool stdout_stream)
|
|||
|
||||
void Log::SetLogLevel(char* level)
|
||||
{
|
||||
int32 newLevel =atoi((char*)level);
|
||||
int32 newLevel = atoi((char*)level);
|
||||
|
||||
if (newLevel < LOG_LVL_MINIMAL)
|
||||
newLevel = LOG_LVL_MINIMAL;
|
||||
|
|
@ -201,7 +201,7 @@ void Log::SetLogLevel(char* level)
|
|||
|
||||
void Log::SetLogFileLevel(char* level)
|
||||
{
|
||||
int32 newLevel =atoi((char*)level);
|
||||
int32 newLevel = atoi((char*)level);
|
||||
|
||||
if (newLevel < LOG_LVL_MINIMAL)
|
||||
newLevel = LOG_LVL_MINIMAL;
|
||||
|
|
@ -216,36 +216,36 @@ void Log::SetLogFileLevel(char* level)
|
|||
void Log::Initialize()
|
||||
{
|
||||
/// Common log files data
|
||||
m_logsDir = sConfig.GetStringDefault("LogsDir","");
|
||||
m_logsDir = sConfig.GetStringDefault("LogsDir", "");
|
||||
if (!m_logsDir.empty())
|
||||
{
|
||||
if ((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
||||
if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
|
||||
m_logsDir.append("/");
|
||||
}
|
||||
|
||||
m_logsTimestamp = "_" + GetTimestampStr();
|
||||
|
||||
/// Open specific log files
|
||||
logfile = openLogFile("LogFile","LogTimestamp","w");
|
||||
logfile = openLogFile("LogFile", "LogTimestamp", "w");
|
||||
|
||||
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
|
||||
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount", false);
|
||||
if (!m_gmlog_per_account)
|
||||
gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
|
||||
gmLogfile = openLogFile("GMLogFile", "GmLogTimestamp", "a");
|
||||
else
|
||||
{
|
||||
// GM log settings for per account case
|
||||
m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
|
||||
if (!m_gmlog_filename_format.empty())
|
||||
{
|
||||
bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp",false);
|
||||
bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp", false);
|
||||
|
||||
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
|
||||
if (dot_pos!=m_gmlog_filename_format.npos)
|
||||
if (dot_pos != m_gmlog_filename_format.npos)
|
||||
{
|
||||
if (m_gmlog_timestamp)
|
||||
m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);
|
||||
m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp);
|
||||
|
||||
m_gmlog_filename_format.insert(dot_pos,"_#%u");
|
||||
m_gmlog_filename_format.insert(dot_pos, "_#%u");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -259,10 +259,10 @@ void Log::Initialize()
|
|||
}
|
||||
}
|
||||
|
||||
charLogfile = openLogFile("CharLogFile","CharLogTimestamp","a");
|
||||
dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
|
||||
raLogfile = openLogFile("RaLogFile",NULL,"a");
|
||||
worldLogfile = openLogFile("WorldLogFile","WorldLogTimestamp","a");
|
||||
charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
|
||||
dberLogfile = openLogFile("DBErrorLogFile", NULL, "a");
|
||||
raLogfile = openLogFile("RaLogFile", NULL, "a");
|
||||
worldLogfile = openLogFile("WorldLogFile", "WorldLogTimestamp", "a");
|
||||
|
||||
// Main log file settings
|
||||
m_includeTime = sConfig.GetBoolDefault("LogTime", false);
|
||||
|
|
@ -280,22 +280,22 @@ void Log::Initialize()
|
|||
m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false);
|
||||
}
|
||||
|
||||
FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode)
|
||||
FILE* Log::openLogFile(char const* configFileName, char const* configTimeStampFlag, char const* mode)
|
||||
{
|
||||
std::string logfn=sConfig.GetStringDefault(configFileName, "");
|
||||
std::string logfn = sConfig.GetStringDefault(configFileName, "");
|
||||
if (logfn.empty())
|
||||
return NULL;
|
||||
|
||||
if (configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag,false))
|
||||
if (configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag, false))
|
||||
{
|
||||
size_t dot_pos = logfn.find_last_of(".");
|
||||
if (dot_pos!=logfn.npos)
|
||||
logfn.insert(dot_pos,m_logsTimestamp);
|
||||
if (dot_pos != logfn.npos)
|
||||
logfn.insert(dot_pos, m_logsTimestamp);
|
||||
else
|
||||
logfn += m_logsTimestamp;
|
||||
}
|
||||
|
||||
return fopen((m_logsDir+logfn).c_str(), mode);
|
||||
return fopen((m_logsDir + logfn).c_str(), mode);
|
||||
}
|
||||
|
||||
FILE* Log::openGmlogPerAccount(uint32 account)
|
||||
|
|
@ -304,7 +304,7 @@ FILE* Log::openGmlogPerAccount(uint32 account)
|
|||
return NULL;
|
||||
|
||||
char namebuf[MANGOS_PATH_MAX];
|
||||
snprintf(namebuf,MANGOS_PATH_MAX,m_gmlog_filename_format.c_str(),account);
|
||||
snprintf(namebuf, MANGOS_PATH_MAX, m_gmlog_filename_format.c_str(), account);
|
||||
return fopen(namebuf, "a");
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ void Log::outTimestamp(FILE* file)
|
|||
// HH hour (2 digits 00-23)
|
||||
// MM minutes (2 digits 00-59)
|
||||
// SS seconds (2 digits 00-59)
|
||||
fprintf(file,"%-4d-%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);
|
||||
fprintf(file, "%-4d-%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);
|
||||
}
|
||||
|
||||
void Log::outTime()
|
||||
|
|
@ -331,7 +331,7 @@ void Log::outTime()
|
|||
// HH hour (2 digits 00-23)
|
||||
// MM minutes (2 digits 00-59)
|
||||
// SS seconds (2 digits 00-59)
|
||||
printf("%02d:%02d:%02d ",aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
|
||||
printf("%02d:%02d:%02d ", aTm->tm_hour, aTm->tm_min, aTm->tm_sec);
|
||||
}
|
||||
|
||||
std::string Log::GetTimestampStr()
|
||||
|
|
@ -345,7 +345,7 @@ std::string Log::GetTimestampStr()
|
|||
// 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);
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ void Log::outString(const char* str, ...)
|
|||
return;
|
||||
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogNormal]);
|
||||
SetColor(true, m_colors[LogNormal]);
|
||||
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
|
@ -407,7 +407,7 @@ void Log::outError(const char* err, ...)
|
|||
return;
|
||||
|
||||
if (m_colored)
|
||||
SetColor(false,m_colors[LogError]);
|
||||
SetColor(false, m_colors[LogError]);
|
||||
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
|
@ -468,7 +468,7 @@ void Log::outErrorDb(const char* err, ...)
|
|||
return;
|
||||
|
||||
if (m_colored)
|
||||
SetColor(false,m_colors[LogError]);
|
||||
SetColor(false, m_colors[LogError]);
|
||||
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
|
@ -521,7 +521,7 @@ void Log::outBasic(const char* str, ...)
|
|||
if (m_logLevel >= LOG_LVL_BASIC)
|
||||
{
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDetails]);
|
||||
SetColor(true, m_colors[LogDetails]);
|
||||
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
|
@ -560,7 +560,7 @@ void Log::outDetail(const char* str, ...)
|
|||
{
|
||||
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDetails]);
|
||||
SetColor(true, m_colors[LogDetails]);
|
||||
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
|
@ -600,7 +600,7 @@ void Log::outDebug(const char* str, ...)
|
|||
if (m_logLevel >= LOG_LVL_DEBUG)
|
||||
{
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDebug]);
|
||||
SetColor(true, m_colors[LogDebug]);
|
||||
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
|
@ -640,7 +640,7 @@ void Log::outCommand(uint32 account, const char* str, ...)
|
|||
if (m_logLevel >= LOG_LVL_DETAIL)
|
||||
{
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDetails]);
|
||||
SetColor(true, m_colors[LogDetails]);
|
||||
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
|
@ -719,7 +719,7 @@ void Log::outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeNam
|
|||
|
||||
outTimestamp(worldLogfile);
|
||||
|
||||
fprintf(worldLogfile,"\n%s:\nSOCKET: %u\nLENGTH: " SIZEFMTD "\nOPCODE: %s (0x%.4X)\nDATA:\n",
|
||||
fprintf(worldLogfile, "\n%s:\nSOCKET: %u\nLENGTH: " SIZEFMTD "\nOPCODE: %s (0x%.4X)\nDATA:\n",
|
||||
incoming ? "CLIENT" : "SERVER",
|
||||
socket, packet->size(), opcodeName, opcode);
|
||||
|
||||
|
|
@ -740,7 +740,7 @@ void Log::outCharDump(const char* str, uint32 account_id, uint32 guid, const cha
|
|||
{
|
||||
if (charLogfile)
|
||||
{
|
||||
fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",account_id,guid,name,str);
|
||||
fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n", account_id, guid, name, str);
|
||||
fflush(charLogfile);
|
||||
}
|
||||
}
|
||||
|
|
@ -766,7 +766,7 @@ void Log::outRALog(const char* str, ...)
|
|||
|
||||
void Log::WaitBeforeContinueIfNeed()
|
||||
{
|
||||
int mode = sConfig.GetIntDefault("WaitAtStartupError",0);
|
||||
int mode = sConfig.GetIntDefault("WaitAtStartupError", 0);
|
||||
|
||||
if (mode < 0)
|
||||
{
|
||||
|
|
@ -777,7 +777,7 @@ void Log::WaitBeforeContinueIfNeed()
|
|||
}
|
||||
else if (mode > 0)
|
||||
{
|
||||
printf("\nWait %u secs for continue.\n",mode);
|
||||
printf("\nWait %u secs for continue.\n", mode);
|
||||
BarGoLink bar(mode);
|
||||
for (int i = 0; i < mode; ++i)
|
||||
{
|
||||
|
|
@ -809,7 +809,7 @@ void detail_log(const char* str, ...)
|
|||
char buf[256];
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
vsnprintf(buf,256, str, ap);
|
||||
vsnprintf(buf, 256, str, ap);
|
||||
va_end(ap);
|
||||
|
||||
sLog.outDetail("%s", buf);
|
||||
|
|
@ -823,7 +823,7 @@ void debug_log(const char* str, ...)
|
|||
char buf[256];
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
vsnprintf(buf,256, str, ap);
|
||||
vsnprintf(buf, 256, str, ap);
|
||||
va_end(ap);
|
||||
|
||||
DEBUG_LOG("%s", buf);
|
||||
|
|
@ -837,7 +837,7 @@ void error_log(const char* str, ...)
|
|||
char buf[256];
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
vsnprintf(buf,256, str, ap);
|
||||
vsnprintf(buf, 256, str, ap);
|
||||
va_end(ap);
|
||||
|
||||
sLog.outError("%s", buf);
|
||||
|
|
@ -851,7 +851,7 @@ void error_db_log(const char* str, ...)
|
|||
char buf[256];
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
vsnprintf(buf,256, str, ap);
|
||||
vsnprintf(buf, 256, str, ap);
|
||||
va_end(ap);
|
||||
|
||||
sLog.outErrorDb("%s", buf);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ enum LogFilters
|
|||
LOG_FILTER_TRANSPORT_MOVES = 0x000001, // 0 any related to transport moves
|
||||
LOG_FILTER_CREATURE_MOVES = 0x000002, // 1 creature move by cells
|
||||
LOG_FILTER_VISIBILITY_CHANGES = 0x000004, // 2 update visibility for diff objects and players
|
||||
LOG_FILTER_ACHIEVEMENT_UPDATES= 0x000008, // 3 achievement update broadcasts
|
||||
LOG_FILTER_ACHIEVEMENT_UPDATES = 0x000008, // 3 achievement update broadcasts
|
||||
LOG_FILTER_WEATHER = 0x000010, // 4 weather changes
|
||||
LOG_FILTER_PLAYER_STATS = 0x000020, // 5 player save data
|
||||
LOG_FILTER_SQL_TEXT = 0x000040, // 6 raw SQL text send to DB engine
|
||||
|
|
@ -85,7 +85,7 @@ enum Color
|
|||
WHITE
|
||||
};
|
||||
|
||||
const int Color_count = int(WHITE)+1;
|
||||
const int Color_count = int(WHITE) + 1;
|
||||
|
||||
class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Thread_Mutex> >
|
||||
{
|
||||
|
|
@ -122,29 +122,29 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
|
|||
void Initialize();
|
||||
void InitColors(const std::string& init_str);
|
||||
|
||||
void outCommand(uint32 account, const char* str, ...) ATTR_PRINTF(3,4);
|
||||
void outCommand(uint32 account, const char* str, ...) ATTR_PRINTF(3, 4);
|
||||
void outString(); // any log level
|
||||
// any log level
|
||||
void outString(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
void outString(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
// any log level
|
||||
void outError(const char* err, ...) ATTR_PRINTF(2,3);
|
||||
void outError(const char* err, ...) ATTR_PRINTF(2, 3);
|
||||
// log level >= 1
|
||||
void outBasic(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
void outBasic(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
// log level >= 2
|
||||
void outDetail(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
void outDetail(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
// log level >= 3
|
||||
void outDebug(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
void outDebug(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
|
||||
void outErrorDb(); // any log level
|
||||
// any log level
|
||||
void outErrorDb(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
void outErrorDb(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
// any log level
|
||||
void outChar(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
void outChar(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
// any log level
|
||||
void outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming);
|
||||
// any log level
|
||||
void outCharDump(const char* str, uint32 account_id, uint32 guid, const char* name);
|
||||
void outRALog(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
void outRALog(const char* str, ...) ATTR_PRINTF(2, 3);
|
||||
uint32 GetLogLevel() const { return m_logLevel; }
|
||||
void SetLogLevel(char* Level);
|
||||
void SetLogFileLevel(char* Level);
|
||||
|
|
@ -161,7 +161,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
|
|||
|
||||
static void WaitBeforeContinueIfNeed();
|
||||
private:
|
||||
FILE* openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode);
|
||||
FILE* openLogFile(char const* configFileName, char const* configTimeStampFlag, char const* mode);
|
||||
FILE* openGmlogPerAccount(uint32 account);
|
||||
|
||||
FILE* raLogfile;
|
||||
|
|
@ -239,9 +239,9 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
|
|||
ERROR_DB_FILTER_LOG(LOG_FILTER_DB_STRICTED_CHECK, __VA_ARGS__)
|
||||
|
||||
// primary for script library
|
||||
void MANGOS_DLL_SPEC outstring_log(const char* str, ...) ATTR_PRINTF(1,2);
|
||||
void MANGOS_DLL_SPEC detail_log(const char* str, ...) ATTR_PRINTF(1,2);
|
||||
void MANGOS_DLL_SPEC debug_log(const char* str, ...) ATTR_PRINTF(1,2);
|
||||
void MANGOS_DLL_SPEC error_log(const char* str, ...) ATTR_PRINTF(1,2);
|
||||
void MANGOS_DLL_SPEC error_db_log(const char* str, ...) ATTR_PRINTF(1,2);
|
||||
void MANGOS_DLL_SPEC outstring_log(const char* str, ...) ATTR_PRINTF(1, 2);
|
||||
void MANGOS_DLL_SPEC detail_log(const char* str, ...) ATTR_PRINTF(1, 2);
|
||||
void MANGOS_DLL_SPEC debug_log(const char* str, ...) ATTR_PRINTF(1, 2);
|
||||
void MANGOS_DLL_SPEC error_log(const char* str, ...) ATTR_PRINTF(1, 2);
|
||||
void MANGOS_DLL_SPEC error_db_log(const char* str, ...) ATTR_PRINTF(1, 2);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ void BarGoLink::step()
|
|||
#endif
|
||||
for (i = 0; i < n; i++) printf(full);
|
||||
for (; i < indic_len; i++) printf(empty);
|
||||
float percent = (((float)n/(float)indic_len)*100);
|
||||
float percent = (((float)n / (float)indic_len) * 100);
|
||||
#ifdef _WIN32
|
||||
printf("\x3D %i%% \r\x3D", (int)percent);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ bool WinServiceInstall()
|
|||
}
|
||||
|
||||
char path[_MAX_PATH + 10];
|
||||
if (!GetModuleFileName(0, path, sizeof(path)/sizeof(path[0])))
|
||||
if (!GetModuleFileName(0, path, sizeof(path) / sizeof(path[0])))
|
||||
{
|
||||
CloseServiceHandle(serviceControlManager);
|
||||
sLog.outError("SERVICE: Can't get service binary filename.");
|
||||
|
|
@ -121,7 +121,7 @@ bool WinServiceInstall()
|
|||
ZeroMemory(&sfa, sizeof(SERVICE_FAILURE_ACTIONS));
|
||||
sfa.lpsaActions = _action;
|
||||
sfa.cActions = 1;
|
||||
sfa.dwResetPeriod =INFINITE;
|
||||
sfa.dwResetPeriod = INFINITE;
|
||||
ChangeService_Config2(
|
||||
service, // handle to service
|
||||
SERVICE_CONFIG_FAILURE_ACTIONS, // information level
|
||||
|
|
@ -221,7 +221,7 @@ void WINAPI ServiceMain(DWORD argc, char* argv[])
|
|||
char path[_MAX_PATH + 1];
|
||||
unsigned int i, last_slash = 0;
|
||||
|
||||
GetModuleFileName(0, path, sizeof(path)/sizeof(path[0]));
|
||||
GetModuleFileName(0, path, sizeof(path) / sizeof(path[0]));
|
||||
|
||||
for (i = 0; i < std::strlen(path); i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ inline void ApplyPercentModFloatVar(float& var, float val, bool apply)
|
|||
{
|
||||
if (val == -100.0f) // prevent set var to zero
|
||||
val = -99.99f;
|
||||
var *= (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val));
|
||||
var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
|
||||
}
|
||||
|
||||
bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr);
|
||||
|
|
@ -117,7 +117,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str);
|
|||
bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str);
|
||||
|
||||
size_t utf8length(std::string& utf8str); // set string to "" if invalid utf8 sequence
|
||||
void utf8truncate(std::string& utf8str,size_t len);
|
||||
void utf8truncate(std::string& utf8str, size_t len);
|
||||
|
||||
inline bool isBasicLatinCharacter(wchar_t wchar)
|
||||
{
|
||||
|
|
@ -186,12 +186,12 @@ inline bool isWhiteSpace(char c)
|
|||
|
||||
inline bool isNumeric(wchar_t wchar)
|
||||
{
|
||||
return (wchar >= L'0' && wchar <=L'9');
|
||||
return (wchar >= L'0' && wchar <= L'9');
|
||||
}
|
||||
|
||||
inline bool isNumeric(char c)
|
||||
{
|
||||
return (c >= '0' && c <='9');
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
inline bool isNumericOrSpace(wchar_t wchar)
|
||||
|
|
@ -271,20 +271,20 @@ inline void strToLower(std::string& str)
|
|||
inline wchar_t wcharToUpper(wchar_t wchar)
|
||||
{
|
||||
if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
|
||||
return wchar_t(uint16(wchar)-0x0020);
|
||||
return wchar_t(uint16(wchar) - 0x0020);
|
||||
if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
|
||||
return wchar_t(0x1E9E);
|
||||
if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
|
||||
return wchar_t(uint16(wchar)-0x0020);
|
||||
return wchar_t(uint16(wchar) - 0x0020);
|
||||
if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
|
||||
return wchar_t(uint16(wchar)-0x0020);
|
||||
return wchar_t(uint16(wchar) - 0x0020);
|
||||
if (wchar >= 0x0101 && wchar <= 0x012F) // LATIN SMALL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK (only %2=1)
|
||||
{
|
||||
if (wchar % 2 == 1)
|
||||
return wchar_t(uint16(wchar)-0x0001);
|
||||
return wchar_t(uint16(wchar) - 0x0001);
|
||||
}
|
||||
if (wchar >= 0x0430 && wchar <= 0x044F) // CYRILLIC SMALL LETTER A - CYRILLIC SMALL LETTER YA
|
||||
return wchar_t(uint16(wchar)-0x0020);
|
||||
return wchar_t(uint16(wchar) - 0x0020);
|
||||
if (wchar == 0x0451) // CYRILLIC SMALL LETTER IO
|
||||
return wchar_t(0x0401);
|
||||
|
||||
|
|
@ -299,22 +299,22 @@ inline wchar_t wcharToUpperOnlyLatin(wchar_t wchar)
|
|||
inline wchar_t wcharToLower(wchar_t wchar)
|
||||
{
|
||||
if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
|
||||
return wchar_t(uint16(wchar)+0x0020);
|
||||
return wchar_t(uint16(wchar) + 0x0020);
|
||||
if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
return wchar_t(uint16(wchar)+0x0020);
|
||||
return wchar_t(uint16(wchar) + 0x0020);
|
||||
if (wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
|
||||
return wchar_t(uint16(wchar)+0x0020);
|
||||
return wchar_t(uint16(wchar) + 0x0020);
|
||||
if (wchar >= 0x0100 && wchar <= 0x012E) // LATIN CAPITAL LETTER A WITH MACRON - LATIN CAPITAL LETTER I WITH OGONEK (only %2=0)
|
||||
{
|
||||
if (wchar % 2 == 0)
|
||||
return wchar_t(uint16(wchar)+0x0001);
|
||||
return wchar_t(uint16(wchar) + 0x0001);
|
||||
}
|
||||
if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
|
||||
return wchar_t(0x00DF);
|
||||
if (wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO
|
||||
return wchar_t(0x0451);
|
||||
if (wchar >= 0x0410 && wchar <= 0x042F) // CYRILLIC CAPITAL LETTER A - CYRILLIC CAPITAL LETTER YA
|
||||
return wchar_t(uint16(wchar)+0x0020);
|
||||
return wchar_t(uint16(wchar) + 0x0020);
|
||||
|
||||
return wchar;
|
||||
}
|
||||
|
|
@ -332,7 +332,7 @@ inline void wstrToLower(std::wstring& str)
|
|||
std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
|
||||
|
||||
bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
|
||||
bool consoleToUtf8(const std::string& conStr,std::string& utf8str);
|
||||
bool consoleToUtf8(const std::string& conStr, std::string& utf8str);
|
||||
bool Utf8FitTo(const std::string& str, std::wstring search);
|
||||
void utf8printf(FILE* out, const char* str, ...);
|
||||
void vutf8printf(FILE* out, const char* str, va_list* ap);
|
||||
|
|
|
|||
|
|
@ -317,10 +317,10 @@ void WheatyExceptionReport::PrintSystemInfo()
|
|||
_tprintf(_T("//=====================================================\r\n"));
|
||||
if (_GetProcessorName(sString, countof(sString)))
|
||||
_tprintf(_T("*** Hardware ***\r\nProcessor: %s\r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"),
|
||||
sString, SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400);
|
||||
sString, SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys / 0x400, MemoryStatus.dwAvailPhys / 0x400, MemoryStatus.dwTotalPageFile / 0x400);
|
||||
else
|
||||
_tprintf(_T("*** Hardware ***\r\nProcessor: <unknown>\r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"),
|
||||
SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400);
|
||||
SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys / 0x400, MemoryStatus.dwAvailPhys / 0x400, MemoryStatus.dwTotalPageFile / 0x400);
|
||||
|
||||
if (_GetWindowsVersion(sString, countof(sString)))
|
||||
_tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString);
|
||||
|
|
@ -362,7 +362,7 @@ void WheatyExceptionReport::printTracesForAllThreads()
|
|||
{
|
||||
CONTEXT context;
|
||||
context.ContextFlags = 0xffffffff;
|
||||
HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,false, te32.th32ThreadID);
|
||||
HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, false, te32.th32ThreadID);
|
||||
if (threadHandle && GetThreadContext(threadHandle, &context))
|
||||
{
|
||||
WriteStackDetails(&context, false, threadHandle);
|
||||
|
|
@ -425,7 +425,7 @@ void WheatyExceptionReport::GenerateExceptionReport(
|
|||
_tprintf(_T("\r\nRegisters:\r\n"));
|
||||
|
||||
_tprintf(_T("EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n")
|
||||
,pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx,
|
||||
, pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx,
|
||||
pCtx->Esi, pCtx->Edi);
|
||||
|
||||
_tprintf(_T("CS:EIP:%04X:%08X\r\n"), pCtx->SegCs, pCtx->Eip);
|
||||
|
|
@ -440,8 +440,8 @@ void WheatyExceptionReport::GenerateExceptionReport(
|
|||
_tprintf(_T("\r\nRegisters:\r\n"));
|
||||
_tprintf(_T("RAX:%016I64X\r\nRBX:%016I64X\r\nRCX:%016I64X\r\nRDX:%016I64X\r\nRSI:%016I64X\r\nRDI:%016I64X\r\n")
|
||||
_T("R8: %016I64X\r\nR9: %016I64X\r\nR10:%016I64X\r\nR11:%016I64X\r\nR12:%016I64X\r\nR13:%016I64X\r\nR14:%016I64X\r\nR15:%016I64X\r\n")
|
||||
,pCtx->Rax, pCtx->Rbx, pCtx->Rcx, pCtx->Rdx,
|
||||
pCtx->Rsi, pCtx->Rdi ,pCtx->R9,pCtx->R10,pCtx->R11,pCtx->R12,pCtx->R13,pCtx->R14,pCtx->R15);
|
||||
, pCtx->Rax, pCtx->Rbx, pCtx->Rcx, pCtx->Rdx,
|
||||
pCtx->Rsi, pCtx->Rdi , pCtx->R9, pCtx->R10, pCtx->R11, pCtx->R12, pCtx->R13, pCtx->R14, pCtx->R15);
|
||||
_tprintf(_T("CS:RIP:%04X:%016I64X\r\n"), pCtx->SegCs, pCtx->Rip);
|
||||
_tprintf(_T("SS:RSP:%04X:%016X RBP:%08X\r\n"),
|
||||
pCtx->SegSs, pCtx->Rsp, pCtx->Rbp);
|
||||
|
|
@ -577,7 +577,7 @@ BOOL WheatyExceptionReport::GetLogicalAddress(
|
|||
// Yes, address is in the section. Calculate section and offset,
|
||||
// and store in the "section" & "offset" params, which were
|
||||
// passed by reference.
|
||||
section = i+1;
|
||||
section = i + 1;
|
||||
offset = rva - sectionStart;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -696,7 +696,7 @@ void WheatyExceptionReport::WriteStackDetails(
|
|||
if (SymGetLineFromAddr64(m_hProcess, sf.AddrPC.Offset,
|
||||
&dwLineDisplacement, &lineInfo))
|
||||
{
|
||||
_tprintf(_T(" %s line %u"),lineInfo.FileName,lineInfo.LineNumber);
|
||||
_tprintf(_T(" %s line %u"), lineInfo.FileName, lineInfo.LineNumber);
|
||||
}
|
||||
|
||||
_tprintf(_T("\r\n"));
|
||||
|
|
@ -793,7 +793,7 @@ bool WheatyExceptionReport::FormatSymbolValue(
|
|||
// Determine if the variable is a user defined type (UDT). IF so, bHandled
|
||||
// will return true.
|
||||
bool bHandled;
|
||||
pszCurrBuffer = DumpTypeIndex(pszCurrBuffer,pSym->ModBase, pSym->TypeIndex,
|
||||
pszCurrBuffer = DumpTypeIndex(pszCurrBuffer, pSym->ModBase, pSym->TypeIndex,
|
||||
0, pVariable, bHandled, pSym->Name);
|
||||
|
||||
if (!bHandled)
|
||||
|
|
@ -858,7 +858,7 @@ char* WheatyExceptionReport::DumpTypeIndex(
|
|||
} children;
|
||||
|
||||
children.Count = dwChildrenCount;
|
||||
children.Start= 0;
|
||||
children.Start = 0;
|
||||
|
||||
// Get the array of TypeIds, one for each child type
|
||||
if (!SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_FINDCHILDREN,
|
||||
|
|
@ -874,7 +874,7 @@ char* WheatyExceptionReport::DumpTypeIndex(
|
|||
for (unsigned i = 0; i < dwChildrenCount; i++)
|
||||
{
|
||||
// Add appropriate indentation level (since this routine is recursive)
|
||||
for (unsigned j = 0; j <= nestingLevel+1; j++)
|
||||
for (unsigned j = 0; j <= nestingLevel + 1; j++)
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, "\t");
|
||||
|
||||
// Recurse for each of the child types
|
||||
|
|
@ -883,7 +883,7 @@ char* WheatyExceptionReport::DumpTypeIndex(
|
|||
pszCurrBuffer += sprintf(pszCurrBuffer, rgBaseType[basicType]);
|
||||
|
||||
pszCurrBuffer = DumpTypeIndex(pszCurrBuffer, modBase,
|
||||
children.ChildId[i], nestingLevel+1,
|
||||
children.ChildId[i], nestingLevel + 1,
|
||||
offset, bHandled2, ""/*Name */);
|
||||
|
||||
// If the child wasn't a UDT, format it appropriately
|
||||
|
|
@ -902,7 +902,7 @@ char* WheatyExceptionReport::DumpTypeIndex(
|
|||
|
||||
// Get the size of the child member
|
||||
ULONG64 length;
|
||||
SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH,&length);
|
||||
SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH, &length);
|
||||
|
||||
// Calculate the address of the member
|
||||
DWORD_PTR dwFinalOffset = offset + dwMemberOffset;
|
||||
|
|
@ -939,7 +939,7 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer,
|
|||
{
|
||||
if (basicType == btFloat)
|
||||
{
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer," = %f", *(PFLOAT)pAddress);
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, " = %f", *(PFLOAT)pAddress);
|
||||
}
|
||||
else if (basicType == btChar)
|
||||
{
|
||||
|
|
@ -953,7 +953,7 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer,
|
|||
*(PDWORD)pAddress);
|
||||
}
|
||||
else
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer," = %X", *(PDWORD)pAddress);
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress);
|
||||
}
|
||||
else if (length == 8)
|
||||
{
|
||||
|
|
@ -983,7 +983,7 @@ WheatyExceptionReport::GetBasicType(DWORD typeIndex, DWORD64 modBase)
|
|||
// Get the real "TypeId" of the child. We need this for the
|
||||
// SymGetTypeInfo( TI_GET_TYPEID ) call below.
|
||||
DWORD typeId;
|
||||
if (SymGetTypeInfo(m_hProcess,modBase, typeIndex, TI_GET_TYPEID, &typeId))
|
||||
if (SymGetTypeInfo(m_hProcess, modBase, typeIndex, TI_GET_TYPEID, &typeId))
|
||||
{
|
||||
if (SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_BASETYPE,
|
||||
&basicType))
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class WheatyExceptionReport
|
|||
|
||||
static void WriteStackDetails(PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
|
||||
|
||||
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID);
|
||||
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO, ULONG, PVOID);
|
||||
|
||||
static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME*, char* pszBuffer, unsigned cbBuffer);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ class WorldPacket : public ByteBuffer
|
|||
WorldPacket() : ByteBuffer(0), m_opcode(0)
|
||||
{
|
||||
}
|
||||
explicit WorldPacket(uint16 opcode, size_t res=200) : ByteBuffer(res), m_opcode(opcode) { }
|
||||
explicit WorldPacket(uint16 opcode, size_t res = 200) : ByteBuffer(res), m_opcode(opcode) { }
|
||||
// copy constructor
|
||||
WorldPacket(const WorldPacket& packet) : ByteBuffer(packet), m_opcode(packet.m_opcode)
|
||||
{
|
||||
}
|
||||
|
||||
void Initialize(uint16 opcode, size_t newres=200)
|
||||
void Initialize(uint16 opcode, size_t newres = 200)
|
||||
{
|
||||
clear();
|
||||
_storage.reserve(newres);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12063"
|
||||
#define REVISION_NR "12063"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_11785_02_characters_instance"
|
||||
#define REVISION_DB_MANGOS "required_12012_01_mangos_spell_template"
|
||||
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
|
||||
#define REVISION_DB_CHARACTERS "required_11785_02_characters_instance"
|
||||
#define REVISION_DB_MANGOS "required_12012_01_mangos_spell_template"
|
||||
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue