mirror of
https://github.com/mangosfour/server.git
synced 2025-12-25 22:37:04 +00:00
[12062] Cleanup MaNGOS sources
This commit is contained in:
parent
a4cbed3199
commit
aeff8f9d1a
46 changed files with 1982 additions and 1864 deletions
|
|
@ -31,17 +31,17 @@ AuthCrypt::~AuthCrypt()
|
|||
|
||||
}
|
||||
|
||||
void AuthCrypt::Init(BigNumber *K)
|
||||
void AuthCrypt::Init(BigNumber* K)
|
||||
{
|
||||
uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 };
|
||||
|
||||
HMACSHA1 serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
|
||||
uint8 *encryptHash = serverEncryptHmac.ComputeHash(K);
|
||||
uint8* encryptHash = serverEncryptHmac.ComputeHash(K);
|
||||
|
||||
uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE };
|
||||
|
||||
HMACSHA1 clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
|
||||
uint8 *decryptHash = clientDecryptHmac.ComputeHash(K);
|
||||
uint8* decryptHash = clientDecryptHmac.ComputeHash(K);
|
||||
|
||||
//SARC4 _serverDecrypt(encryptHash);
|
||||
_clientDecrypt.Init(decryptHash);
|
||||
|
|
@ -63,7 +63,7 @@ void AuthCrypt::Init(BigNumber *K)
|
|||
_initialized = true;
|
||||
}
|
||||
|
||||
void AuthCrypt::DecryptRecv(uint8 *data, size_t len)
|
||||
void AuthCrypt::DecryptRecv(uint8* data, size_t len)
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
|
@ -71,7 +71,7 @@ void AuthCrypt::DecryptRecv(uint8 *data, size_t len)
|
|||
_clientDecrypt.UpdateData(len, data);
|
||||
}
|
||||
|
||||
void AuthCrypt::EncryptSend(uint8 *data, size_t len)
|
||||
void AuthCrypt::EncryptSend(uint8* data, size_t len)
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ class AuthCrypt
|
|||
AuthCrypt();
|
||||
~AuthCrypt();
|
||||
|
||||
void Init(BigNumber *K);
|
||||
void DecryptRecv(uint8 *, size_t);
|
||||
void EncryptSend(uint8 *, size_t);
|
||||
void Init(BigNumber* K);
|
||||
void DecryptRecv(uint8*, size_t);
|
||||
void EncryptSend(uint8*, size_t);
|
||||
|
||||
bool IsInitialized() { return _initialized; }
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ BigNumber::BigNumber()
|
|||
_array = NULL;
|
||||
}
|
||||
|
||||
BigNumber::BigNumber(const BigNumber &bn)
|
||||
BigNumber::BigNumber(const BigNumber& bn)
|
||||
{
|
||||
_bn = BN_dup(bn._bn);
|
||||
_array = NULL;
|
||||
|
|
@ -42,7 +42,7 @@ BigNumber::BigNumber(uint32 val)
|
|||
BigNumber::~BigNumber()
|
||||
{
|
||||
BN_free(_bn);
|
||||
if(_array) delete[] _array;
|
||||
if (_array) delete[] _array;
|
||||
}
|
||||
|
||||
void BigNumber::SetDword(uint32 val)
|
||||
|
|
@ -57,7 +57,7 @@ void BigNumber::SetQword(uint64 val)
|
|||
BN_add_word(_bn, (uint32)(val & 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
void BigNumber::SetBinary(const uint8 *bytes, int len)
|
||||
void BigNumber::SetBinary(const uint8* bytes, int len)
|
||||
{
|
||||
uint8 t[1000];
|
||||
for (int i = 0; i < len; i++)
|
||||
|
|
@ -65,7 +65,7 @@ void BigNumber::SetBinary(const uint8 *bytes, int len)
|
|||
BN_bin2bn(t, len, _bn);
|
||||
}
|
||||
|
||||
void BigNumber::SetHexStr(const char *str)
|
||||
void BigNumber::SetHexStr(const char* str)
|
||||
{
|
||||
BN_hex2bn(&_bn, str);
|
||||
}
|
||||
|
|
@ -75,27 +75,27 @@ void BigNumber::SetRand(int numbits)
|
|||
BN_rand(_bn, numbits, 0, 1);
|
||||
}
|
||||
|
||||
BigNumber BigNumber::operator=(const BigNumber &bn)
|
||||
BigNumber BigNumber::operator=(const BigNumber& bn)
|
||||
{
|
||||
BN_copy(_bn, bn._bn);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BigNumber BigNumber::operator+=(const BigNumber &bn)
|
||||
BigNumber BigNumber::operator+=(const BigNumber& bn)
|
||||
{
|
||||
BN_add(_bn, _bn, bn._bn);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BigNumber BigNumber::operator-=(const BigNumber &bn)
|
||||
BigNumber BigNumber::operator-=(const BigNumber& bn)
|
||||
{
|
||||
BN_sub(_bn, _bn, bn._bn);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BigNumber BigNumber::operator*=(const BigNumber &bn)
|
||||
BigNumber BigNumber::operator*=(const BigNumber& bn)
|
||||
{
|
||||
BN_CTX *bnctx;
|
||||
BN_CTX* bnctx;
|
||||
|
||||
bnctx = BN_CTX_new();
|
||||
BN_mul(_bn, _bn, bn._bn, bnctx);
|
||||
|
|
@ -104,9 +104,9 @@ BigNumber BigNumber::operator*=(const BigNumber &bn)
|
|||
return *this;
|
||||
}
|
||||
|
||||
BigNumber BigNumber::operator/=(const BigNumber &bn)
|
||||
BigNumber BigNumber::operator/=(const BigNumber& bn)
|
||||
{
|
||||
BN_CTX *bnctx;
|
||||
BN_CTX* bnctx;
|
||||
|
||||
bnctx = BN_CTX_new();
|
||||
BN_div(_bn, NULL, _bn, bn._bn, bnctx);
|
||||
|
|
@ -115,9 +115,9 @@ BigNumber BigNumber::operator/=(const BigNumber &bn)
|
|||
return *this;
|
||||
}
|
||||
|
||||
BigNumber BigNumber::operator%=(const BigNumber &bn)
|
||||
BigNumber BigNumber::operator%=(const BigNumber& bn)
|
||||
{
|
||||
BN_CTX *bnctx;
|
||||
BN_CTX* bnctx;
|
||||
|
||||
bnctx = BN_CTX_new();
|
||||
BN_mod(_bn, _bn, bn._bn, bnctx);
|
||||
|
|
@ -126,10 +126,10 @@ BigNumber BigNumber::operator%=(const BigNumber &bn)
|
|||
return *this;
|
||||
}
|
||||
|
||||
BigNumber BigNumber::Exp(const BigNumber &bn)
|
||||
BigNumber BigNumber::Exp(const BigNumber& bn)
|
||||
{
|
||||
BigNumber ret;
|
||||
BN_CTX *bnctx;
|
||||
BN_CTX* bnctx;
|
||||
|
||||
bnctx = BN_CTX_new();
|
||||
BN_exp(ret._bn, _bn, bn._bn, bnctx);
|
||||
|
|
@ -138,10 +138,10 @@ BigNumber BigNumber::Exp(const BigNumber &bn)
|
|||
return ret;
|
||||
}
|
||||
|
||||
BigNumber BigNumber::ModExp(const BigNumber &bn1, const BigNumber &bn2)
|
||||
BigNumber BigNumber::ModExp(const BigNumber& bn1, const BigNumber& bn2)
|
||||
{
|
||||
BigNumber ret;
|
||||
BN_CTX *bnctx;
|
||||
BN_CTX* bnctx;
|
||||
|
||||
bnctx = BN_CTX_new();
|
||||
BN_mod_exp(ret._bn, _bn, bn1._bn, bn2._bn, bnctx);
|
||||
|
|
@ -165,7 +165,7 @@ bool BigNumber::isZero() const
|
|||
return BN_is_zero(_bn)!=0;
|
||||
}
|
||||
|
||||
uint8 *BigNumber::AsByteArray(int minSize, bool reverse)
|
||||
uint8* BigNumber::AsByteArray(int minSize, bool reverse)
|
||||
{
|
||||
int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes();
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ uint8 *BigNumber::AsByteArray(int minSize, bool reverse)
|
|||
if (length > GetNumBytes())
|
||||
memset((void*)_array, 0, length);
|
||||
|
||||
BN_bn2bin(_bn, (unsigned char *)_array);
|
||||
BN_bn2bin(_bn, (unsigned char*)_array);
|
||||
|
||||
if (reverse)
|
||||
std::reverse(_array, _array + length);
|
||||
|
|
@ -188,12 +188,12 @@ uint8 *BigNumber::AsByteArray(int minSize, bool reverse)
|
|||
return _array;
|
||||
}
|
||||
|
||||
const char *BigNumber::AsHexStr()
|
||||
const char* BigNumber::AsHexStr()
|
||||
{
|
||||
return BN_bn2hex(_bn);
|
||||
}
|
||||
|
||||
const char *BigNumber::AsDecStr()
|
||||
const char* BigNumber::AsDecStr()
|
||||
{
|
||||
return BN_bn2dec(_bn);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,45 +27,45 @@ class BigNumber
|
|||
{
|
||||
public:
|
||||
BigNumber();
|
||||
BigNumber(const BigNumber &bn);
|
||||
BigNumber(const BigNumber& bn);
|
||||
BigNumber(uint32);
|
||||
~BigNumber();
|
||||
|
||||
void SetDword(uint32);
|
||||
void SetQword(uint64);
|
||||
void SetBinary(const uint8 *bytes, int len);
|
||||
void SetHexStr(const char *str);
|
||||
void SetBinary(const uint8* bytes, int len);
|
||||
void SetHexStr(const char* str);
|
||||
|
||||
void SetRand(int numbits);
|
||||
|
||||
BigNumber operator=(const BigNumber &bn);
|
||||
BigNumber operator=(const BigNumber& bn);
|
||||
|
||||
BigNumber operator+=(const BigNumber &bn);
|
||||
BigNumber operator+(const BigNumber &bn)
|
||||
BigNumber operator+=(const BigNumber& bn);
|
||||
BigNumber operator+(const BigNumber& bn)
|
||||
{
|
||||
BigNumber t(*this);
|
||||
return t += bn;
|
||||
}
|
||||
BigNumber operator-=(const BigNumber &bn);
|
||||
BigNumber operator-(const BigNumber &bn)
|
||||
BigNumber operator-=(const BigNumber& bn);
|
||||
BigNumber operator-(const BigNumber& bn)
|
||||
{
|
||||
BigNumber t(*this);
|
||||
return t -= bn;
|
||||
}
|
||||
BigNumber operator*=(const BigNumber &bn);
|
||||
BigNumber operator*(const BigNumber &bn)
|
||||
BigNumber operator*=(const BigNumber& bn);
|
||||
BigNumber operator*(const BigNumber& bn)
|
||||
{
|
||||
BigNumber t(*this);
|
||||
return t *= bn;
|
||||
}
|
||||
BigNumber operator/=(const BigNumber &bn);
|
||||
BigNumber operator/(const BigNumber &bn)
|
||||
BigNumber operator/=(const BigNumber& bn);
|
||||
BigNumber operator/(const BigNumber& bn)
|
||||
{
|
||||
BigNumber t(*this);
|
||||
return t /= bn;
|
||||
}
|
||||
BigNumber operator%=(const BigNumber &bn);
|
||||
BigNumber operator%(const BigNumber &bn)
|
||||
BigNumber operator%=(const BigNumber& bn);
|
||||
BigNumber operator%(const BigNumber& bn)
|
||||
{
|
||||
BigNumber t(*this);
|
||||
return t %= bn;
|
||||
|
|
@ -73,21 +73,21 @@ class BigNumber
|
|||
|
||||
bool isZero() const;
|
||||
|
||||
BigNumber ModExp(const BigNumber &bn1, const BigNumber &bn2);
|
||||
BigNumber Exp(const BigNumber &);
|
||||
BigNumber ModExp(const BigNumber& bn1, const BigNumber& bn2);
|
||||
BigNumber Exp(const BigNumber&);
|
||||
|
||||
int GetNumBytes(void);
|
||||
|
||||
struct bignum_st *BN() { return _bn; }
|
||||
struct bignum_st* BN() { return _bn; }
|
||||
|
||||
uint32 AsDword();
|
||||
uint8* AsByteArray(int minSize = 0, bool reverse = true);
|
||||
|
||||
const char *AsHexStr();
|
||||
const char *AsDecStr();
|
||||
const char* AsHexStr();
|
||||
const char* AsDecStr();
|
||||
|
||||
private:
|
||||
struct bignum_st *_bn;
|
||||
uint8 *_array;
|
||||
struct bignum_st* _bn;
|
||||
uint8* _array;
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include "Auth/HMACSHA1.h"
|
||||
#include "BigNumber.h"
|
||||
|
||||
HMACSHA1::HMACSHA1(uint32 len, uint8 *seed)
|
||||
HMACSHA1::HMACSHA1(uint32 len, uint8* seed)
|
||||
{
|
||||
HMAC_CTX_init(&m_ctx);
|
||||
HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL);
|
||||
|
|
@ -30,17 +30,17 @@ HMACSHA1::~HMACSHA1()
|
|||
HMAC_CTX_cleanup(&m_ctx);
|
||||
}
|
||||
|
||||
void HMACSHA1::UpdateBigNumber(BigNumber *bn)
|
||||
void HMACSHA1::UpdateBigNumber(BigNumber* bn)
|
||||
{
|
||||
UpdateData(bn->AsByteArray(), bn->GetNumBytes());
|
||||
}
|
||||
|
||||
void HMACSHA1::UpdateData(const uint8 *data, int length)
|
||||
void HMACSHA1::UpdateData(const uint8* data, int length)
|
||||
{
|
||||
HMAC_Update(&m_ctx, data, length);
|
||||
}
|
||||
|
||||
void HMACSHA1::UpdateData(const std::string &str)
|
||||
void HMACSHA1::UpdateData(const std::string& str)
|
||||
{
|
||||
UpdateData((uint8 const*)str.c_str(), str.length());
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ void HMACSHA1::Finalize()
|
|||
MANGOS_ASSERT(length == SHA_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
uint8 *HMACSHA1::ComputeHash(BigNumber *bn)
|
||||
uint8* HMACSHA1::ComputeHash(BigNumber* bn)
|
||||
{
|
||||
HMAC_Update(&m_ctx, bn->AsByteArray(), bn->GetNumBytes());
|
||||
Finalize();
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ class BigNumber;
|
|||
class HMACSHA1
|
||||
{
|
||||
public:
|
||||
HMACSHA1(uint32 len, uint8 *seed);
|
||||
HMACSHA1(uint32 len, uint8* seed);
|
||||
~HMACSHA1();
|
||||
void UpdateBigNumber(BigNumber *bn);
|
||||
void UpdateData(const uint8 *data, int length);
|
||||
void UpdateData(const std::string &str);
|
||||
void UpdateBigNumber(BigNumber* bn);
|
||||
void UpdateData(const uint8* data, int length);
|
||||
void UpdateData(const std::string& str);
|
||||
void Finalize();
|
||||
uint8 *ComputeHash(BigNumber *bn);
|
||||
uint8 *GetDigest() { return (uint8*)m_digest; }
|
||||
uint8* ComputeHash(BigNumber* bn);
|
||||
uint8* GetDigest() { return (uint8*)m_digest; }
|
||||
int GetLength() { return SHA_DIGEST_LENGTH; }
|
||||
private:
|
||||
HMAC_CTX m_ctx;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ SARC4::SARC4(uint8 len)
|
|||
EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
|
||||
}
|
||||
|
||||
SARC4::SARC4(uint8 *seed, uint8 len)
|
||||
SARC4::SARC4(uint8* seed, uint8 len)
|
||||
{
|
||||
EVP_CIPHER_CTX_init(&m_ctx);
|
||||
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
|
||||
|
|
@ -39,12 +39,12 @@ SARC4::~SARC4()
|
|||
EVP_CIPHER_CTX_cleanup(&m_ctx);
|
||||
}
|
||||
|
||||
void SARC4::Init(uint8 *seed)
|
||||
void SARC4::Init(uint8* seed)
|
||||
{
|
||||
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
|
||||
}
|
||||
|
||||
void SARC4::UpdateData(int len, uint8 *data)
|
||||
void SARC4::UpdateData(int len, uint8* data)
|
||||
{
|
||||
int outlen = 0;
|
||||
EVP_EncryptUpdate(&m_ctx, data, &outlen, data, len);
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ class SARC4
|
|||
{
|
||||
public:
|
||||
SARC4(uint8 len);
|
||||
SARC4(uint8 *seed, uint8 len);
|
||||
SARC4(uint8* seed, uint8 len);
|
||||
~SARC4();
|
||||
void Init(uint8 *seed);
|
||||
void UpdateData(int len, uint8 *data);
|
||||
void Init(uint8* seed);
|
||||
void UpdateData(int len, uint8* data);
|
||||
private:
|
||||
EVP_CIPHER_CTX m_ctx;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,27 +30,27 @@ Sha1Hash::~Sha1Hash()
|
|||
SHA1_Init(&mC);
|
||||
}
|
||||
|
||||
void Sha1Hash::UpdateData(const uint8 *dta, int len)
|
||||
void Sha1Hash::UpdateData(const uint8* dta, int len)
|
||||
{
|
||||
SHA1_Update(&mC, dta, len);
|
||||
}
|
||||
|
||||
void Sha1Hash::UpdateData(const std::string &str)
|
||||
void Sha1Hash::UpdateData(const std::string& str)
|
||||
{
|
||||
UpdateData((uint8 const*)str.c_str(), str.length());
|
||||
}
|
||||
|
||||
void Sha1Hash::UpdateBigNumbers(BigNumber *bn0, ...)
|
||||
void Sha1Hash::UpdateBigNumbers(BigNumber* bn0, ...)
|
||||
{
|
||||
va_list v;
|
||||
BigNumber *bn;
|
||||
BigNumber* bn;
|
||||
|
||||
va_start(v, bn0);
|
||||
bn = bn0;
|
||||
while (bn)
|
||||
{
|
||||
UpdateData(bn->AsByteArray(), bn->GetNumBytes());
|
||||
bn = va_arg(v, BigNumber *);
|
||||
bn = va_arg(v, BigNumber*);
|
||||
}
|
||||
va_end(v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@ class Sha1Hash
|
|||
Sha1Hash();
|
||||
~Sha1Hash();
|
||||
|
||||
void UpdateBigNumbers(BigNumber *bn0, ...);
|
||||
void UpdateBigNumbers(BigNumber* bn0, ...);
|
||||
|
||||
void UpdateData(const uint8 *dta, int len);
|
||||
void UpdateData(const std::string &str);
|
||||
void UpdateData(const uint8* dta, int len);
|
||||
void UpdateData(const std::string& str);
|
||||
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
|
||||
uint8 *GetDigest(void) { return mDigest; };
|
||||
uint8* GetDigest(void) { return mDigest; };
|
||||
int GetLength(void) { return SHA_DIGEST_LENGTH; };
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -74,18 +74,18 @@ typedef struct md5_state_s
|
|||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Initialize the algorithm. */
|
||||
void md5_init(md5_state_t *pms);
|
||||
void md5_init(md5_state_t* pms);
|
||||
|
||||
/* Append a string to the message. */
|
||||
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
|
||||
void md5_append(md5_state_t* pms, const md5_byte_t* data, int nbytes);
|
||||
|
||||
/* Finish the message and return the digest. */
|
||||
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
|
||||
void md5_finish(md5_state_t* pms, md5_byte_t digest[16]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
#endif /* md5_INCLUDED */
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class ByteBufferException
|
|||
void PrintPosError() const
|
||||
{
|
||||
sLog.outError("Attempted to %s in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD") value with size: " SIZEFMTD,
|
||||
(add ? "put" : "get"), pos, size, esize);
|
||||
(add ? "put" : "get"), pos, size, esize);
|
||||
}
|
||||
private:
|
||||
bool add;
|
||||
|
|
@ -68,7 +68,7 @@ class ByteBuffer
|
|||
}
|
||||
|
||||
// copy constructor
|
||||
ByteBuffer(const ByteBuffer &buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage) { }
|
||||
ByteBuffer(const ByteBuffer& buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage) { }
|
||||
|
||||
void clear()
|
||||
{
|
||||
|
|
@ -79,153 +79,153 @@ class ByteBuffer
|
|||
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)
|
||||
ByteBuffer& operator<<(uint8 value)
|
||||
{
|
||||
append<uint8>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(uint16 value)
|
||||
ByteBuffer& operator<<(uint16 value)
|
||||
{
|
||||
append<uint16>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(uint32 value)
|
||||
ByteBuffer& operator<<(uint32 value)
|
||||
{
|
||||
append<uint32>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(uint64 value)
|
||||
ByteBuffer& operator<<(uint64 value)
|
||||
{
|
||||
append<uint64>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// signed as in 2e complement
|
||||
ByteBuffer &operator<<(int8 value)
|
||||
ByteBuffer& operator<<(int8 value)
|
||||
{
|
||||
append<int8>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(int16 value)
|
||||
ByteBuffer& operator<<(int16 value)
|
||||
{
|
||||
append<int16>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(int32 value)
|
||||
ByteBuffer& operator<<(int32 value)
|
||||
{
|
||||
append<int32>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(int64 value)
|
||||
ByteBuffer& operator<<(int64 value)
|
||||
{
|
||||
append<int64>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// floating points
|
||||
ByteBuffer &operator<<(float value)
|
||||
ByteBuffer& operator<<(float value)
|
||||
{
|
||||
append<float>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(double value)
|
||||
ByteBuffer& operator<<(double value)
|
||||
{
|
||||
append<double>(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(const std::string &value)
|
||||
ByteBuffer& operator<<(const std::string& value)
|
||||
{
|
||||
append((uint8 const *)value.c_str(), value.length());
|
||||
append((uint8 const*)value.c_str(), value.length());
|
||||
append((uint8)0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator<<(const char *str)
|
||||
ByteBuffer& operator<<(const char* str)
|
||||
{
|
||||
append((uint8 const *)str, str ? strlen(str) : 0);
|
||||
append((uint8 const*)str, str ? strlen(str) : 0);
|
||||
append((uint8)0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(bool &value)
|
||||
ByteBuffer& operator>>(bool& value)
|
||||
{
|
||||
value = read<char>() > 0 ? true : false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint8 &value)
|
||||
ByteBuffer& operator>>(uint8& value)
|
||||
{
|
||||
value = read<uint8>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint16 &value)
|
||||
ByteBuffer& operator>>(uint16& value)
|
||||
{
|
||||
value = read<uint16>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint32 &value)
|
||||
ByteBuffer& operator>>(uint32& value)
|
||||
{
|
||||
value = read<uint32>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(uint64 &value)
|
||||
ByteBuffer& operator>>(uint64& value)
|
||||
{
|
||||
value = read<uint64>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
//signed as in 2e complement
|
||||
ByteBuffer &operator>>(int8 &value)
|
||||
ByteBuffer& operator>>(int8& value)
|
||||
{
|
||||
value = read<int8>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(int16 &value)
|
||||
ByteBuffer& operator>>(int16& value)
|
||||
{
|
||||
value = read<int16>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(int32 &value)
|
||||
ByteBuffer& operator>>(int32& value)
|
||||
{
|
||||
value = read<int32>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(int64 &value)
|
||||
ByteBuffer& operator>>(int64& value)
|
||||
{
|
||||
value = read<int64>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(float &value)
|
||||
ByteBuffer& operator>>(float& value)
|
||||
{
|
||||
value = read<float>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(double &value)
|
||||
ByteBuffer& operator>>(double& value)
|
||||
{
|
||||
value = read<double>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ByteBuffer &operator>>(std::string& value)
|
||||
ByteBuffer& operator>>(std::string& value)
|
||||
{
|
||||
value.clear();
|
||||
while (rpos() < size()) // prevent crash at wrong string format in packet
|
||||
|
|
@ -239,7 +239,7 @@ class ByteBuffer
|
|||
}
|
||||
|
||||
template<class T>
|
||||
ByteBuffer &operator>>(Unused<T> const&)
|
||||
ByteBuffer& operator>>(Unused<T> const&)
|
||||
{
|
||||
read_skip<T>();
|
||||
return *this;
|
||||
|
|
@ -272,7 +272,7 @@ class ByteBuffer
|
|||
|
||||
void read_skip(size_t skip)
|
||||
{
|
||||
if(_rpos + skip > size())
|
||||
if (_rpos + skip > size())
|
||||
throw ByteBufferException(false, _rpos, skip, size());
|
||||
_rpos += skip;
|
||||
}
|
||||
|
|
@ -286,16 +286,16 @@ class ByteBuffer
|
|||
|
||||
template <typename T> T read(size_t pos) const
|
||||
{
|
||||
if(pos + sizeof(T) > size())
|
||||
if (pos + sizeof(T) > size())
|
||||
throw ByteBufferException(false, pos, sizeof(T), size());
|
||||
T val = *((T const*)&_storage[pos]);
|
||||
EndianConvert(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
void read(uint8 *dest, size_t len)
|
||||
void read(uint8* dest, size_t len)
|
||||
{
|
||||
if(_rpos + len > size())
|
||||
if (_rpos + len > size())
|
||||
throw ByteBufferException(false, _rpos, len, size());
|
||||
memcpy(dest, &_storage[_rpos], len);
|
||||
_rpos += len;
|
||||
|
|
@ -307,9 +307,9 @@ class ByteBuffer
|
|||
uint8 guidmark = 0;
|
||||
(*this) >> guidmark;
|
||||
|
||||
for(int i = 0; i < 8; ++i)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if(guidmark & (uint8(1) << i))
|
||||
if (guidmark & (uint8(1) << i))
|
||||
{
|
||||
uint8 bit;
|
||||
(*this) >> bit;
|
||||
|
|
@ -320,7 +320,7 @@ class ByteBuffer
|
|||
return guid;
|
||||
}
|
||||
|
||||
const uint8 *contents() const { return &_storage[0]; }
|
||||
const uint8* contents() const { return &_storage[0]; }
|
||||
|
||||
size_t size() const { return _storage.size(); }
|
||||
bool empty() const { return _storage.empty(); }
|
||||
|
|
@ -343,17 +343,17 @@ class ByteBuffer
|
|||
append((uint8 const*)str.c_str(), str.size() + 1);
|
||||
}
|
||||
|
||||
void append(const char *src, size_t cnt)
|
||||
void append(const char* src, size_t cnt)
|
||||
{
|
||||
return append((const uint8 *)src, cnt);
|
||||
return append((const uint8*)src, cnt);
|
||||
}
|
||||
|
||||
template<class T> void append(const T *src, size_t cnt)
|
||||
template<class T> void append(const T* src, size_t cnt)
|
||||
{
|
||||
return append((const uint8 *)src, cnt * sizeof(T));
|
||||
return append((const uint8*)src, cnt * sizeof(T));
|
||||
}
|
||||
|
||||
void append(const uint8 *src, size_t cnt)
|
||||
void append(const uint8* src, size_t cnt)
|
||||
{
|
||||
if (!cnt)
|
||||
return;
|
||||
|
|
@ -368,7 +368,7 @@ class ByteBuffer
|
|||
|
||||
void append(const ByteBuffer& buffer)
|
||||
{
|
||||
if(buffer.wpos())
|
||||
if (buffer.wpos())
|
||||
append(buffer.contents(), buffer.wpos());
|
||||
}
|
||||
|
||||
|
|
@ -402,9 +402,9 @@ class ByteBuffer
|
|||
append(packGUID, size);
|
||||
}
|
||||
|
||||
void put(size_t pos, const uint8 *src, size_t cnt)
|
||||
void put(size_t pos, const uint8* src, size_t cnt)
|
||||
{
|
||||
if(pos + cnt > size())
|
||||
if (pos + cnt > size())
|
||||
throw ByteBufferException(true, pos, cnt, size());
|
||||
memcpy(&_storage[pos], src, cnt);
|
||||
}
|
||||
|
|
@ -487,7 +487,7 @@ class ByteBuffer
|
|||
template <typename T> void append(T value)
|
||||
{
|
||||
EndianConvert(value);
|
||||
append((uint8 *)&value, sizeof(value));
|
||||
append((uint8*)&value, sizeof(value));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
@ -496,7 +496,7 @@ class ByteBuffer
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> const& v)
|
||||
inline ByteBuffer& operator<<(ByteBuffer& b, std::vector<T> const& v)
|
||||
{
|
||||
b << (uint32)v.size();
|
||||
for (typename std::vector<T>::iterator i = v.begin(); i != v.end(); ++i)
|
||||
|
|
@ -507,12 +507,12 @@ inline ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> const& v)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v)
|
||||
inline ByteBuffer& operator>>(ByteBuffer& b, std::vector<T>& v)
|
||||
{
|
||||
uint32 vsize;
|
||||
b >> vsize;
|
||||
v.clear();
|
||||
while(vsize--)
|
||||
while (vsize--)
|
||||
{
|
||||
T t;
|
||||
b >> t;
|
||||
|
|
@ -522,7 +522,7 @@ inline ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator<<(ByteBuffer &b, std::list<T> const& v)
|
||||
inline ByteBuffer& operator<<(ByteBuffer& b, std::list<T> const& v)
|
||||
{
|
||||
b << (uint32)v.size();
|
||||
for (typename std::list<T>::iterator i = v.begin(); i != v.end(); ++i)
|
||||
|
|
@ -533,12 +533,12 @@ inline ByteBuffer &operator<<(ByteBuffer &b, std::list<T> const& v)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline ByteBuffer &operator>>(ByteBuffer &b, std::list<T> &v)
|
||||
inline ByteBuffer& operator>>(ByteBuffer& b, std::list<T>& v)
|
||||
{
|
||||
uint32 vsize;
|
||||
b >> vsize;
|
||||
v.clear();
|
||||
while(vsize--)
|
||||
while (vsize--)
|
||||
{
|
||||
T t;
|
||||
b >> t;
|
||||
|
|
@ -548,7 +548,7 @@ inline ByteBuffer &operator>>(ByteBuffer &b, std::list<T> &v)
|
|||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline ByteBuffer &operator<<(ByteBuffer &b, std::map<K, V> &m)
|
||||
inline ByteBuffer& operator<<(ByteBuffer& b, std::map<K, V>& m)
|
||||
{
|
||||
b << (uint32)m.size();
|
||||
for (typename std::map<K, V>::iterator i = m.begin(); i != m.end(); ++i)
|
||||
|
|
@ -559,12 +559,12 @@ inline ByteBuffer &operator<<(ByteBuffer &b, std::map<K, V> &m)
|
|||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline ByteBuffer &operator>>(ByteBuffer &b, std::map<K, V> &m)
|
||||
inline ByteBuffer& operator>>(ByteBuffer& b, std::map<K, V>& m)
|
||||
{
|
||||
uint32 msize;
|
||||
b >> msize;
|
||||
m.clear();
|
||||
while(msize--)
|
||||
while (msize--)
|
||||
{
|
||||
K k;
|
||||
V v;
|
||||
|
|
|
|||
|
|
@ -18,16 +18,17 @@
|
|||
|
||||
#include "Common.h"
|
||||
|
||||
char const* localeNames[MAX_LOCALE] = {
|
||||
"enUS", // also enGB
|
||||
"koKR",
|
||||
"frFR",
|
||||
"deDE",
|
||||
"zhCN",
|
||||
"zhTW",
|
||||
"esES",
|
||||
"esMX",
|
||||
"ruRU"
|
||||
char const* localeNames[MAX_LOCALE] =
|
||||
{
|
||||
"enUS", // also enGB
|
||||
"koKR",
|
||||
"frFR",
|
||||
"deDE",
|
||||
"zhCN",
|
||||
"zhTW",
|
||||
"esES",
|
||||
"esMX",
|
||||
"ruRU"
|
||||
};
|
||||
|
||||
// used for search by name or iterate all names
|
||||
|
|
@ -48,7 +49,7 @@ LocaleNameStr const fullLocaleNameList[] =
|
|||
|
||||
LocaleConstant GetLocaleByName(const std::string& name)
|
||||
{
|
||||
for(LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr)
|
||||
for (LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr)
|
||||
if (name==itr->name)
|
||||
return itr->locale;
|
||||
|
||||
|
|
|
|||
|
|
@ -226,9 +226,9 @@ struct LocaleNameStr
|
|||
extern LocaleNameStr const fullLocaleNameList[];
|
||||
|
||||
//operator new[] based version of strdup() function! Release memory by using operator delete[] !
|
||||
inline char * mangos_strdup(const char * source)
|
||||
inline char* mangos_strdup(const char* source)
|
||||
{
|
||||
char * dest = new char[strlen(source) + 1];
|
||||
char* dest = new char[strlen(source) + 1];
|
||||
strcpy(dest, source);
|
||||
return dest;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
INSTANTIATE_SINGLETON_1(Config);
|
||||
|
||||
static bool GetValueHelper(ACE_Configuration_Heap *mConf, const char *name, ACE_TString &result)
|
||||
static bool GetValueHelper(ACE_Configuration_Heap* mConf, const char* name, ACE_TString& result)
|
||||
{
|
||||
if (!mConf)
|
||||
return false;
|
||||
|
|
@ -45,7 +45,7 @@ static bool GetValueHelper(ACE_Configuration_Heap *mConf, const char *name, ACE_
|
|||
}
|
||||
|
||||
Config::Config()
|
||||
: mConf(NULL)
|
||||
: mConf(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ Config::~Config()
|
|||
delete mConf;
|
||||
}
|
||||
|
||||
bool Config::SetSource(const char *file)
|
||||
bool Config::SetSource(const char* file)
|
||||
{
|
||||
mFilename = file;
|
||||
|
||||
|
|
@ -92,8 +92,8 @@ bool Config::GetBoolDefault(const char* name, bool def)
|
|||
|
||||
const char* str = val.c_str();
|
||||
if (strcmp(str, "true") == 0 || strcmp(str, "TRUE") == 0 ||
|
||||
strcmp(str, "yes") == 0 || strcmp(str, "YES") == 0 ||
|
||||
strcmp(str, "1") == 0)
|
||||
strcmp(str, "yes") == 0 || strcmp(str, "YES") == 0 ||
|
||||
strcmp(str, "1") == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class MANGOS_DLL_SPEC Config
|
|||
Config();
|
||||
~Config();
|
||||
|
||||
bool SetSource(const char *file);
|
||||
bool SetSource(const char* file);
|
||||
bool Reload();
|
||||
|
||||
std::string GetStringDefault(const char* name, const char* def);
|
||||
|
|
@ -45,7 +45,7 @@ class MANGOS_DLL_SPEC Config
|
|||
private:
|
||||
|
||||
std::string mFilename;
|
||||
ACE_Configuration_Heap *mConf;
|
||||
ACE_Configuration_Heap* mConf;
|
||||
};
|
||||
|
||||
#define sConfig MaNGOS::Singleton<Config>::Instance()
|
||||
|
|
|
|||
|
|
@ -28,16 +28,16 @@
|
|||
namespace ACE_Based
|
||||
{
|
||||
template <class T, class LockType, typename StorageType=std::deque<T> >
|
||||
class LockedQueue
|
||||
class LockedQueue
|
||||
{
|
||||
//! Lock access to the queue.
|
||||
LockType _lock;
|
||||
//! Lock access to the queue.
|
||||
LockType _lock;
|
||||
|
||||
//! Storage backing the queue.
|
||||
StorageType _queue;
|
||||
//! Storage backing the queue.
|
||||
StorageType _queue;
|
||||
|
||||
//! Cancellation flag.
|
||||
/*volatile*/ bool _canceled;
|
||||
//! Cancellation flag.
|
||||
/*volatile*/ bool _canceled;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ namespace ACE_Based
|
|||
//! Gets the next result in the queue, if any.
|
||||
bool next(T& result)
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, g, this->_lock, false);
|
||||
ACE_GUARD_RETURN(LockType, g, this->_lock, false);
|
||||
|
||||
if (_queue.empty())
|
||||
return false;
|
||||
|
|
@ -76,13 +76,13 @@ namespace ACE_Based
|
|||
template<class Checker>
|
||||
bool next(T& result, Checker& check)
|
||||
{
|
||||
ACE_GUARD_RETURN (LockType, g, this->_lock, false);
|
||||
ACE_GUARD_RETURN(LockType, g, this->_lock, false);
|
||||
|
||||
if (_queue.empty())
|
||||
return false;
|
||||
|
||||
result = _queue.front();
|
||||
if(!check.Process(result))
|
||||
if (!check.Process(result))
|
||||
return false;
|
||||
|
||||
_queue.pop_front();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "ace/OS_NS_unistd.h"
|
||||
|
||||
INSTANTIATE_SINGLETON_1( Log );
|
||||
INSTANTIATE_SINGLETON_1(Log);
|
||||
|
||||
LogFilterData logFilterData[LOG_FILTER_COUNT] =
|
||||
{
|
||||
|
|
@ -82,18 +82,18 @@ void Log::InitColors(const std::string& str)
|
|||
|
||||
std::istringstream ss(str);
|
||||
|
||||
for(int i = 0; i < LogType_count; ++i)
|
||||
for (int i = 0; i < LogType_count; ++i)
|
||||
{
|
||||
ss >> color[i];
|
||||
|
||||
if(!ss)
|
||||
if (!ss)
|
||||
return;
|
||||
|
||||
if(color[i] < 0 || color[i] >= Color_count)
|
||||
if (color[i] < 0 || color[i] >= Color_count)
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < LogType_count; ++i)
|
||||
for (int i = 0; i < LogType_count; ++i)
|
||||
m_colors[i] = Color(color[i]);
|
||||
|
||||
m_colored = true;
|
||||
|
|
@ -101,7 +101,7 @@ void Log::InitColors(const std::string& str)
|
|||
|
||||
void Log::SetColor(bool stdout_stream, Color color)
|
||||
{
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
|
||||
static WORD WinColorFG[Color_count] =
|
||||
{
|
||||
|
|
@ -113,24 +113,24 @@ void Log::SetColor(bool stdout_stream, Color color)
|
|||
FOREGROUND_RED | FOREGROUND_BLUE,// MAGENTA
|
||||
FOREGROUND_GREEN | FOREGROUND_BLUE, // CYAN
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,// WHITE
|
||||
// YELLOW
|
||||
// YELLOW
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
||||
// RED_BOLD
|
||||
// RED_BOLD
|
||||
FOREGROUND_RED | FOREGROUND_INTENSITY,
|
||||
// GREEN_BOLD
|
||||
// GREEN_BOLD
|
||||
FOREGROUND_GREEN | FOREGROUND_INTENSITY,
|
||||
FOREGROUND_BLUE | FOREGROUND_INTENSITY, // BLUE_BOLD
|
||||
// MAGENTA_BOLD
|
||||
// MAGENTA_BOLD
|
||||
FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
|
||||
// CYAN_BOLD
|
||||
// CYAN_BOLD
|
||||
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
|
||||
// WHITE_BOLD
|
||||
// WHITE_BOLD
|
||||
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
|
||||
};
|
||||
|
||||
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE );
|
||||
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, WinColorFG[color]);
|
||||
#else
|
||||
#else
|
||||
|
||||
enum ANSITextAttr
|
||||
{
|
||||
|
|
@ -172,17 +172,17 @@ void Log::SetColor(bool stdout_stream, Color color)
|
|||
};
|
||||
|
||||
fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color<Color_count ?";1":""));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Log::ResetColor(bool stdout_stream)
|
||||
{
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE );
|
||||
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED );
|
||||
#else
|
||||
fprintf(( stdout_stream ? stdout : stderr ), "\x1b[0m");
|
||||
#endif
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
|
||||
#else
|
||||
fprintf((stdout_stream ? stdout : stderr), "\x1b[0m");
|
||||
#endif
|
||||
}
|
||||
|
||||
void Log::SetLogLevel(char* level)
|
||||
|
|
@ -271,7 +271,7 @@ void Log::Initialize()
|
|||
InitColors(sConfig.GetStringDefault("LogColors", ""));
|
||||
|
||||
m_logFilter = 0;
|
||||
for(int i = 0; i < LOG_FILTER_COUNT; ++i)
|
||||
for (int i = 0; i < LOG_FILTER_COUNT; ++i)
|
||||
if (*logFilterData[i].name)
|
||||
if (sConfig.GetBoolDefault(logFilterData[i].configName, logFilterData[i].defaultState))
|
||||
m_logFilter |= (1 << i);
|
||||
|
|
@ -353,18 +353,18 @@ void Log::outString()
|
|||
{
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
printf( "\n" );
|
||||
printf("\n");
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outString( const char * str, ... )
|
||||
void Log::outString(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -384,7 +384,7 @@ void Log::outString( const char * str, ... )
|
|||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
printf("\n");
|
||||
|
||||
if (logfile)
|
||||
{
|
||||
|
|
@ -392,7 +392,7 @@ void Log::outString( const char * str, ... )
|
|||
|
||||
va_start(ap, str);
|
||||
vfprintf(logfile, str, ap);
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
va_end(ap);
|
||||
|
||||
fflush(logfile);
|
||||
|
|
@ -401,7 +401,7 @@ void Log::outString( const char * str, ... )
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outError( const char * err, ... )
|
||||
void Log::outError(const char* err, ...)
|
||||
{
|
||||
if (!err)
|
||||
return;
|
||||
|
|
@ -421,17 +421,17 @@ void Log::outError( const char * err, ... )
|
|||
if (m_colored)
|
||||
ResetColor(false);
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf(stderr, "\n");
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
fprintf(logfile, "ERROR:" );
|
||||
fprintf(logfile, "ERROR:");
|
||||
|
||||
va_start(ap, err);
|
||||
vfprintf(logfile, err, ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
|
|
@ -443,26 +443,26 @@ void Log::outErrorDb()
|
|||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
fprintf(logfile, "ERROR:\n" );
|
||||
fprintf(logfile, "ERROR:\n");
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
if (dberLogfile)
|
||||
{
|
||||
outTimestamp(dberLogfile);
|
||||
fprintf(dberLogfile, "\n" );
|
||||
fprintf(dberLogfile, "\n");
|
||||
fflush(dberLogfile);
|
||||
}
|
||||
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
void Log::outErrorDb( const char * err, ... )
|
||||
void Log::outErrorDb(const char* err, ...)
|
||||
{
|
||||
if (!err)
|
||||
return;
|
||||
|
|
@ -482,18 +482,18 @@ void Log::outErrorDb( const char * err, ... )
|
|||
if (m_colored)
|
||||
ResetColor(false);
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
fprintf(logfile, "ERROR:" );
|
||||
fprintf(logfile, "ERROR:");
|
||||
|
||||
va_start(ap, err);
|
||||
vfprintf(logfile, err, ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
|
|
@ -506,14 +506,14 @@ void Log::outErrorDb( const char * err, ... )
|
|||
vfprintf(dberLogfile, err, ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(dberLogfile, "\n" );
|
||||
fprintf(dberLogfile, "\n");
|
||||
fflush(dberLogfile);
|
||||
}
|
||||
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
void Log::outBasic( const char * str, ... )
|
||||
void Log::outBasic(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -534,7 +534,7 @@ void Log::outBasic( const char * str, ... )
|
|||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_BASIC)
|
||||
|
|
@ -543,7 +543,7 @@ void Log::outBasic( const char * str, ... )
|
|||
outTimestamp(logfile);
|
||||
va_start(ap, str);
|
||||
vfprintf(logfile, str, ap);
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
va_end(ap);
|
||||
fflush(logfile);
|
||||
}
|
||||
|
|
@ -551,7 +551,7 @@ void Log::outBasic( const char * str, ... )
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outDetail( const char * str, ... )
|
||||
void Log::outDetail(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -573,7 +573,7 @@ void Log::outDetail( const char * str, ... )
|
|||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
|
||||
|
|
@ -585,14 +585,14 @@ void Log::outDetail( const char * str, ... )
|
|||
vfprintf(logfile, str, ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outDebug( const char * str, ... )
|
||||
void Log::outDebug(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -613,7 +613,7 @@ void Log::outDebug( const char * str, ... )
|
|||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
|
||||
|
|
@ -625,14 +625,14 @@ void Log::outDebug( const char * str, ... )
|
|||
vfprintf(logfile, str, ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outCommand( uint32 account, const char * str, ... )
|
||||
void Log::outCommand(uint32 account, const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -653,7 +653,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
|||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
|
||||
|
|
@ -662,20 +662,20 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
|||
outTimestamp(logfile);
|
||||
va_start(ap, str);
|
||||
vfprintf(logfile, str, ap);
|
||||
fprintf(logfile, "\n" );
|
||||
fprintf(logfile, "\n");
|
||||
va_end(ap);
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
if (m_gmlog_per_account)
|
||||
{
|
||||
if (FILE* per_file = openGmlogPerAccount (account))
|
||||
if (FILE* per_file = openGmlogPerAccount(account))
|
||||
{
|
||||
va_list ap;
|
||||
outTimestamp(per_file);
|
||||
va_start(ap, str);
|
||||
vfprintf(per_file, str, ap);
|
||||
fprintf(per_file, "\n" );
|
||||
fprintf(per_file, "\n");
|
||||
va_end(ap);
|
||||
fclose(per_file);
|
||||
}
|
||||
|
|
@ -686,7 +686,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
|||
outTimestamp(gmLogfile);
|
||||
va_start(ap, str);
|
||||
vfprintf(gmLogfile, str, ap);
|
||||
fprintf(gmLogfile, "\n" );
|
||||
fprintf(gmLogfile, "\n");
|
||||
va_end(ap);
|
||||
fflush(gmLogfile);
|
||||
}
|
||||
|
|
@ -694,7 +694,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outChar(const char * str, ... )
|
||||
void Log::outChar(const char* str, ...)
|
||||
{
|
||||
|
||||
if (!str)
|
||||
|
|
@ -706,13 +706,13 @@ void Log::outChar(const char * str, ... )
|
|||
outTimestamp(charLogfile);
|
||||
va_start(ap, str);
|
||||
vfprintf(charLogfile, str, ap);
|
||||
fprintf(charLogfile, "\n" );
|
||||
fprintf(charLogfile, "\n");
|
||||
va_end(ap);
|
||||
fflush(charLogfile);
|
||||
}
|
||||
}
|
||||
|
||||
void Log::outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming )
|
||||
void Log::outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming)
|
||||
{
|
||||
if (!worldLogfile)
|
||||
return;
|
||||
|
|
@ -720,8 +720,8 @@ void Log::outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeNa
|
|||
outTimestamp(worldLogfile);
|
||||
|
||||
fprintf(worldLogfile,"\n%s:\nSOCKET: %u\nLENGTH: " SIZEFMTD "\nOPCODE: %s (0x%.4X)\nDATA:\n",
|
||||
incoming ? "CLIENT" : "SERVER",
|
||||
socket, packet->size(), opcodeName, opcode);
|
||||
incoming ? "CLIENT" : "SERVER",
|
||||
socket, packet->size(), opcodeName, opcode);
|
||||
|
||||
size_t p = 0;
|
||||
while (p < packet->size())
|
||||
|
|
@ -736,16 +736,16 @@ void Log::outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeNa
|
|||
fflush(worldLogfile);
|
||||
}
|
||||
|
||||
void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name )
|
||||
void Log::outCharDump(const char* str, uint32 account_id, uint32 guid, const char* name)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void Log::outRALog( const char * str, ... )
|
||||
void Log::outRALog(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -756,7 +756,7 @@ void Log::outRALog( const char * str, ... )
|
|||
outTimestamp(raLogfile);
|
||||
va_start(ap, str);
|
||||
vfprintf(raLogfile, str, ap);
|
||||
fprintf(raLogfile, "\n" );
|
||||
fprintf(raLogfile, "\n");
|
||||
va_end(ap);
|
||||
fflush(raLogfile);
|
||||
}
|
||||
|
|
@ -773,13 +773,13 @@ void Log::WaitBeforeContinueIfNeed()
|
|||
printf("\nPress <Enter> for continue\n");
|
||||
|
||||
std::string line;
|
||||
std::getline (std::cin, line);
|
||||
std::getline(std::cin, line);
|
||||
}
|
||||
else if (mode > 0)
|
||||
{
|
||||
printf("\nWait %u secs for continue.\n",mode);
|
||||
BarGoLink bar(mode);
|
||||
for(int i = 0; i < mode; ++i)
|
||||
for (int i = 0; i < mode; ++i)
|
||||
{
|
||||
bar.step();
|
||||
ACE_OS::sleep(1);
|
||||
|
|
@ -787,7 +787,7 @@ void Log::WaitBeforeContinueIfNeed()
|
|||
}
|
||||
}
|
||||
|
||||
void outstring_log(const char * str, ...)
|
||||
void outstring_log(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -801,7 +801,7 @@ void outstring_log(const char * str, ...)
|
|||
sLog.outString("%s", buf);
|
||||
}
|
||||
|
||||
void detail_log(const char * str, ...)
|
||||
void detail_log(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -815,7 +815,7 @@ void detail_log(const char * str, ...)
|
|||
sLog.outDetail("%s", buf);
|
||||
}
|
||||
|
||||
void debug_log(const char * str, ...)
|
||||
void debug_log(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -829,7 +829,7 @@ void debug_log(const char * str, ...)
|
|||
DEBUG_LOG("%s", buf);
|
||||
}
|
||||
|
||||
void error_log(const char * str, ...)
|
||||
void error_log(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
@ -843,7 +843,7 @@ void error_log(const char * str, ...)
|
|||
sLog.outError("%s", buf);
|
||||
}
|
||||
|
||||
void error_db_log(const char * str, ...)
|
||||
void error_db_log(const char* str, ...)
|
||||
{
|
||||
if (!str)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -89,65 +89,65 @@ const int Color_count = int(WHITE)+1;
|
|||
|
||||
class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Thread_Mutex> >
|
||||
{
|
||||
friend class MaNGOS::OperatorNew<Log>;
|
||||
Log();
|
||||
friend class MaNGOS::OperatorNew<Log>;
|
||||
Log();
|
||||
|
||||
~Log()
|
||||
{
|
||||
if( logfile != NULL )
|
||||
fclose(logfile);
|
||||
logfile = NULL;
|
||||
~Log()
|
||||
{
|
||||
if (logfile != NULL)
|
||||
fclose(logfile);
|
||||
logfile = NULL;
|
||||
|
||||
if( gmLogfile != NULL )
|
||||
fclose(gmLogfile);
|
||||
gmLogfile = NULL;
|
||||
if (gmLogfile != NULL)
|
||||
fclose(gmLogfile);
|
||||
gmLogfile = NULL;
|
||||
|
||||
if (charLogfile != NULL)
|
||||
fclose(charLogfile);
|
||||
charLogfile = NULL;
|
||||
if (charLogfile != NULL)
|
||||
fclose(charLogfile);
|
||||
charLogfile = NULL;
|
||||
|
||||
if( dberLogfile != NULL )
|
||||
fclose(dberLogfile);
|
||||
dberLogfile = NULL;
|
||||
if (dberLogfile != NULL)
|
||||
fclose(dberLogfile);
|
||||
dberLogfile = NULL;
|
||||
|
||||
if (raLogfile != NULL)
|
||||
fclose(raLogfile);
|
||||
raLogfile = NULL;
|
||||
if (raLogfile != NULL)
|
||||
fclose(raLogfile);
|
||||
raLogfile = NULL;
|
||||
|
||||
if (worldLogfile != NULL)
|
||||
fclose(worldLogfile);
|
||||
worldLogfile = NULL;
|
||||
}
|
||||
if (worldLogfile != NULL)
|
||||
fclose(worldLogfile);
|
||||
worldLogfile = NULL;
|
||||
}
|
||||
public:
|
||||
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);
|
||||
// any log level
|
||||
void outError( const char * err, ... ) ATTR_PRINTF(2,3);
|
||||
// log level >= 1
|
||||
void outBasic( const char * str, ... ) ATTR_PRINTF(2,3);
|
||||
// log level >= 2
|
||||
void outDetail( const char * str, ... ) ATTR_PRINTF(2,3);
|
||||
// log level >= 3
|
||||
void outDebug( const char * str, ... ) ATTR_PRINTF(2,3);
|
||||
// any log level
|
||||
void outString(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
// any log level
|
||||
void outError(const char* err, ...) ATTR_PRINTF(2,3);
|
||||
// log level >= 1
|
||||
void outBasic(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
// log level >= 2
|
||||
void outDetail(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
// log level >= 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);
|
||||
// any log level
|
||||
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 outErrorDb(const char* str, ...) ATTR_PRINTF(2,3);
|
||||
// any log level
|
||||
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);
|
||||
uint32 GetLogLevel() const { return m_logLevel; }
|
||||
void SetLogLevel(char * Level);
|
||||
void SetLogFileLevel(char * Level);
|
||||
void SetLogLevel(char* Level);
|
||||
void SetLogFileLevel(char* Level);
|
||||
void SetColor(bool stdout_stream, Color color);
|
||||
void ResetColor(bool stdout_stream);
|
||||
void outTime();
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ void daemonSignal(int s)
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (sid) {
|
||||
if (sid)
|
||||
{
|
||||
kill(sid, s);
|
||||
}
|
||||
|
||||
|
|
@ -57,11 +58,13 @@ void startDaemon(uint32_t timeout)
|
|||
|
||||
sid = pid = fork();
|
||||
|
||||
if (pid < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
if (pid < 0)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (pid > 0) {
|
||||
if (pid > 0)
|
||||
{
|
||||
alarm(timeout);
|
||||
pause();
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -71,12 +74,14 @@ void startDaemon(uint32_t timeout)
|
|||
|
||||
sid = setsid();
|
||||
|
||||
if (sid < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
if (sid < 0)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if ((chdir("/")) < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
if ((chdir("/")) < 0)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
freopen("/dev/null", "rt", stdin);
|
||||
|
|
@ -87,7 +92,7 @@ void startDaemon(uint32_t timeout)
|
|||
void stopDaemon()
|
||||
{
|
||||
std::string pidfile = sConfig.GetStringDefault("PidFile", "");
|
||||
if(!pidfile.empty())
|
||||
if (!pidfile.empty())
|
||||
{
|
||||
std::fstream pf(pidfile.c_str(), std::ios::in);
|
||||
uint32_t pid = 0;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ BarGoLink::~BarGoLink()
|
|||
if (!m_showOutput)
|
||||
return;
|
||||
|
||||
printf( "\n" );
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
@ -66,17 +66,17 @@ void BarGoLink::init(int row_count)
|
|||
if (!m_showOutput)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
printf( "\x3D" );
|
||||
#else
|
||||
printf( "[" );
|
||||
#endif
|
||||
for ( int i = 0; i < indic_len; i++ ) printf( empty );
|
||||
#ifdef _WIN32
|
||||
printf( "\x3D 0%%\r\x3D" );
|
||||
#else
|
||||
printf( "] 0%%\r[" );
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
printf("\x3D");
|
||||
#else
|
||||
printf("[");
|
||||
#endif
|
||||
for (int i = 0; i < indic_len; i++) printf(empty);
|
||||
#ifdef _WIN32
|
||||
printf("\x3D 0%%\r\x3D");
|
||||
#else
|
||||
printf("] 0%%\r[");
|
||||
#endif
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
@ -87,24 +87,24 @@ void BarGoLink::step()
|
|||
|
||||
int i, n;
|
||||
|
||||
if ( num_rec == 0 ) return;
|
||||
if (num_rec == 0) return;
|
||||
++rec_no;
|
||||
n = rec_no * indic_len / num_rec;
|
||||
if ( n != rec_pos )
|
||||
if (n != rec_pos)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
printf( "\r\x3D" );
|
||||
#else
|
||||
printf( "\r[" );
|
||||
#endif
|
||||
for ( i = 0; i < n; i++ ) printf( full );
|
||||
for ( ; i < indic_len; i++ ) printf( empty );
|
||||
#ifdef _WIN32
|
||||
printf("\r\x3D");
|
||||
#else
|
||||
printf("\r[");
|
||||
#endif
|
||||
for (i = 0; i < n; i++) printf(full);
|
||||
for (; i < indic_len; i++) printf(empty);
|
||||
float percent = (((float)n/(float)indic_len)*100);
|
||||
#ifdef _WIN32
|
||||
printf( "\x3D %i%% \r\x3D", (int)percent);
|
||||
#else
|
||||
printf( "] %i%% \r[", (int)percent);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
printf("\x3D %i%% \r\x3D", (int)percent);
|
||||
#else
|
||||
printf("] %i%% \r[", (int)percent);
|
||||
#endif
|
||||
fflush(stdout);
|
||||
|
||||
rec_pos = n;
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ class MANGOS_DLL_SPEC BarGoLink
|
|||
void init(int row_count);
|
||||
|
||||
static bool m_showOutput; // not recommended change with existed active bar
|
||||
static char const * const empty;
|
||||
static char const * const full;
|
||||
static char const* const empty;
|
||||
static char const* const full;
|
||||
|
||||
int rec_no;
|
||||
int rec_pos;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
extern int main(int argc, char ** argv);
|
||||
extern int main(int argc, char** argv);
|
||||
extern char serviceLongName[];
|
||||
extern char serviceName[];
|
||||
extern char serviceDescription[];
|
||||
|
|
@ -43,7 +43,7 @@ SERVICE_STATUS serviceStatus;
|
|||
|
||||
SERVICE_STATUS_HANDLE serviceStatusHandle = 0;
|
||||
|
||||
typedef WINADVAPI BOOL (WINAPI *CSD_T)(SC_HANDLE, DWORD, LPCVOID);
|
||||
typedef WINADVAPI BOOL (WINAPI* CSD_T)(SC_HANDLE, DWORD, LPCVOID);
|
||||
|
||||
bool WinServiceInstall()
|
||||
{
|
||||
|
|
@ -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.");
|
||||
|
|
@ -68,19 +68,19 @@ bool WinServiceInstall()
|
|||
std::strcat(path, " -s run");
|
||||
|
||||
SC_HANDLE service = CreateService(serviceControlManager,
|
||||
serviceName, // name of service
|
||||
serviceLongName, // service name to display
|
||||
SERVICE_ALL_ACCESS, // desired access
|
||||
// service type
|
||||
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
|
||||
SERVICE_AUTO_START, // start type
|
||||
SERVICE_ERROR_IGNORE, // error control type
|
||||
path, // service's binary
|
||||
0, // no load ordering group
|
||||
0, // no tag identifier
|
||||
0, // no dependencies
|
||||
0, // LocalSystem account
|
||||
0); // no password
|
||||
serviceName, // name of service
|
||||
serviceLongName, // service name to display
|
||||
SERVICE_ALL_ACCESS, // desired access
|
||||
// service type
|
||||
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
|
||||
SERVICE_AUTO_START, // start type
|
||||
SERVICE_ERROR_IGNORE, // error control type
|
||||
path, // service's binary
|
||||
0, // no load ordering group
|
||||
0, // no tag identifier
|
||||
0, // no dependencies
|
||||
0, // LocalSystem account
|
||||
0); // no password
|
||||
|
||||
if (!service)
|
||||
{
|
||||
|
|
@ -90,7 +90,7 @@ bool WinServiceInstall()
|
|||
}
|
||||
|
||||
advapi32 = GetModuleHandle("ADVAPI32.DLL");
|
||||
if(!advapi32)
|
||||
if (!advapi32)
|
||||
{
|
||||
sLog.outError("SERVICE: Can't access ADVAPI32.DLL");
|
||||
CloseServiceHandle(service);
|
||||
|
|
@ -143,7 +143,7 @@ bool WinServiceUninstall()
|
|||
}
|
||||
|
||||
SC_HANDLE service = OpenService(serviceControlManager,
|
||||
serviceName, SERVICE_QUERY_STATUS | DELETE);
|
||||
serviceName, SERVICE_QUERY_STATUS | DELETE);
|
||||
|
||||
if (!service)
|
||||
{
|
||||
|
|
@ -192,7 +192,7 @@ void WINAPI ServiceControlHandler(DWORD controlCode)
|
|||
break;
|
||||
|
||||
default:
|
||||
if ( controlCode >= 128 && controlCode <= 255 )
|
||||
if (controlCode >= 128 && controlCode <= 255)
|
||||
// user defined control code
|
||||
break;
|
||||
else
|
||||
|
|
@ -203,7 +203,7 @@ void WINAPI ServiceControlHandler(DWORD controlCode)
|
|||
SetServiceStatus(serviceStatusHandle, &serviceStatus);
|
||||
}
|
||||
|
||||
void WINAPI ServiceMain(DWORD argc, char *argv[])
|
||||
void WINAPI ServiceMain(DWORD argc, char* argv[])
|
||||
{
|
||||
// initialise service status
|
||||
serviceStatus.dwServiceType = SERVICE_WIN32;
|
||||
|
|
@ -216,7 +216,7 @@ void WINAPI ServiceMain(DWORD argc, char *argv[])
|
|||
|
||||
serviceStatusHandle = RegisterServiceCtrlHandler(serviceName, ServiceControlHandler);
|
||||
|
||||
if ( serviceStatusHandle )
|
||||
if (serviceStatusHandle)
|
||||
{
|
||||
char path[_MAX_PATH + 1];
|
||||
unsigned int i, last_slash = 0;
|
||||
|
|
@ -240,7 +240,7 @@ void WINAPI ServiceMain(DWORD argc, char *argv[])
|
|||
// running
|
||||
serviceStatus.dwControlsAccepted |= (SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
|
||||
serviceStatus.dwCurrentState = SERVICE_RUNNING;
|
||||
SetServiceStatus( serviceStatusHandle, &serviceStatus );
|
||||
SetServiceStatus(serviceStatusHandle, &serviceStatus);
|
||||
|
||||
////////////////////////
|
||||
// service main cycle //
|
||||
|
|
|
|||
|
|
@ -43,16 +43,16 @@ ThreadPriority::ThreadPriority()
|
|||
pr_iter.next();
|
||||
}
|
||||
|
||||
MANGOS_ASSERT (!_tmp.empty());
|
||||
MANGOS_ASSERT(!_tmp.empty());
|
||||
|
||||
if(_tmp.size() >= MAXPRIORITYNUM)
|
||||
if (_tmp.size() >= MAXPRIORITYNUM)
|
||||
{
|
||||
const size_t max_pos = _tmp.size();
|
||||
size_t min_pos = 1;
|
||||
size_t norm_pos = 0;
|
||||
for (size_t i = 0; i < max_pos; ++i)
|
||||
{
|
||||
if(_tmp[i] == ACE_THR_PRI_OTHER_DEF)
|
||||
if (_tmp[i] == ACE_THR_PRI_OTHER_DEF)
|
||||
{
|
||||
norm_pos = i + 1;
|
||||
break;
|
||||
|
|
@ -65,7 +65,7 @@ ThreadPriority::ThreadPriority()
|
|||
//into ¹ piesces
|
||||
const size_t _divider = 4;
|
||||
size_t _div = (norm_pos - min_pos) / _divider;
|
||||
if(_div == 0)
|
||||
if (_div == 0)
|
||||
_div = 1;
|
||||
|
||||
min_pos = (norm_pos - 1);
|
||||
|
|
@ -74,7 +74,7 @@ ThreadPriority::ThreadPriority()
|
|||
m_priority[Lowest] = _tmp[min_pos -= _div ];
|
||||
|
||||
_div = (max_pos - norm_pos) / _divider;
|
||||
if(_div == 0)
|
||||
if (_div == 0)
|
||||
_div = 1;
|
||||
|
||||
min_pos = norm_pos - 1;
|
||||
|
|
@ -86,10 +86,10 @@ ThreadPriority::ThreadPriority()
|
|||
|
||||
int ThreadPriority::getPriority(Priority p) const
|
||||
{
|
||||
if(p < Idle)
|
||||
if (p < Idle)
|
||||
p = Idle;
|
||||
|
||||
if(p > Realtime)
|
||||
if (p > Realtime)
|
||||
p = Realtime;
|
||||
|
||||
return m_priority[p];
|
||||
|
|
@ -113,7 +113,7 @@ Thread::Thread(Runnable* instance) : m_iThreadId(0), m_hThreadHandle(0), m_task(
|
|||
m_task->incReference();
|
||||
|
||||
bool _start = start();
|
||||
MANGOS_ASSERT (_start);
|
||||
MANGOS_ASSERT(_start);
|
||||
}
|
||||
|
||||
Thread::~Thread()
|
||||
|
|
@ -181,9 +181,9 @@ void Thread::resume()
|
|||
ACE_Thread::resume(m_hThreadHandle);
|
||||
}
|
||||
|
||||
ACE_THR_FUNC_RETURN Thread::ThreadTask(void * param)
|
||||
ACE_THR_FUNC_RETURN Thread::ThreadTask(void* param)
|
||||
{
|
||||
Runnable * _task = (Runnable*)param;
|
||||
Runnable* _task = (Runnable*)param;
|
||||
_task->run();
|
||||
|
||||
// task execution complete, free referecne added at
|
||||
|
|
@ -205,17 +205,17 @@ ACE_hthread_t Thread::currentHandle()
|
|||
return _handle;
|
||||
}
|
||||
|
||||
Thread * Thread::current()
|
||||
Thread* Thread::current()
|
||||
{
|
||||
Thread * _thread = m_ThreadStorage.ts_object();
|
||||
if(!_thread)
|
||||
Thread* _thread = m_ThreadStorage.ts_object();
|
||||
if (!_thread)
|
||||
{
|
||||
_thread = new Thread();
|
||||
_thread->m_iThreadId = Thread::currentId();
|
||||
_thread->m_hThreadHandle = Thread::currentHandle();
|
||||
|
||||
Thread * _oldValue = m_ThreadStorage.ts_object(_thread);
|
||||
if(_oldValue)
|
||||
Thread* _oldValue = m_ThreadStorage.ts_object(_thread);
|
||||
if (_oldValue)
|
||||
delete _oldValue;
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ void Thread::setPriority(Priority type)
|
|||
int _priority = m_TpEnum.getPriority(type);
|
||||
int _ok = ACE_Thread::setprio(m_hThreadHandle, _priority);
|
||||
//remove this ASSERT in case you don't want to know is thread priority change was successful or not
|
||||
MANGOS_ASSERT (_ok == 0);
|
||||
MANGOS_ASSERT(_ok == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace ACE_Based
|
|||
void incReference() { ++m_refs; }
|
||||
void decReference()
|
||||
{
|
||||
if(!--m_refs)
|
||||
if (!--m_refs)
|
||||
delete this;
|
||||
}
|
||||
private:
|
||||
|
|
@ -84,17 +84,17 @@ namespace ACE_Based
|
|||
static void Sleep(unsigned long msecs);
|
||||
static ACE_thread_t currentId();
|
||||
static ACE_hthread_t currentHandle();
|
||||
static Thread * current();
|
||||
static Thread* current();
|
||||
|
||||
private:
|
||||
Thread(const Thread&);
|
||||
Thread& operator=(const Thread&);
|
||||
|
||||
static ACE_THR_FUNC_RETURN ThreadTask(void * param);
|
||||
static ACE_THR_FUNC_RETURN ThreadTask(void* param);
|
||||
|
||||
ACE_thread_t m_iThreadId;
|
||||
ACE_hthread_t m_hThreadHandle;
|
||||
Runnable * m_task;
|
||||
Runnable* m_task;
|
||||
|
||||
typedef ACE_TSS<Thread> ThreadStorage;
|
||||
//global object - container for Thread class representation of every thread
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class WorldTimer
|
|||
|
||||
private:
|
||||
WorldTimer();
|
||||
WorldTimer(const WorldTimer& );
|
||||
WorldTimer(const WorldTimer&);
|
||||
|
||||
//analogue to getMSTime() but it persists m_SystemTickTime
|
||||
static uint32 getMSTime_internal(bool savetime = false);
|
||||
|
|
|
|||
|
|
@ -68,47 +68,47 @@ uint32 WorldTimer::getMSTime_internal(bool savetime /*= false*/)
|
|||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int32 irand (int32 min, int32 max)
|
||||
int32 irand(int32 min, int32 max)
|
||||
{
|
||||
return int32 (mtRand->randInt (max - min)) + min;
|
||||
return int32(mtRand->randInt(max - min)) + min;
|
||||
}
|
||||
|
||||
uint32 urand (uint32 min, uint32 max)
|
||||
uint32 urand(uint32 min, uint32 max)
|
||||
{
|
||||
return mtRand->randInt (max - min) + min;
|
||||
return mtRand->randInt(max - min) + min;
|
||||
}
|
||||
|
||||
float frand (float min, float max)
|
||||
float frand(float min, float max)
|
||||
{
|
||||
return mtRand->randExc (max - min) + min;
|
||||
return mtRand->randExc(max - min) + min;
|
||||
}
|
||||
|
||||
int32 rand32 ()
|
||||
int32 rand32()
|
||||
{
|
||||
return mtRand->randInt ();
|
||||
return mtRand->randInt();
|
||||
}
|
||||
|
||||
double rand_norm(void)
|
||||
{
|
||||
return mtRand->randExc ();
|
||||
return mtRand->randExc();
|
||||
}
|
||||
|
||||
float rand_norm_f(void)
|
||||
{
|
||||
return (float)mtRand->randExc ();
|
||||
return (float)mtRand->randExc();
|
||||
}
|
||||
|
||||
double rand_chance (void)
|
||||
double rand_chance(void)
|
||||
{
|
||||
return mtRand->randExc (100.0);
|
||||
return mtRand->randExc(100.0);
|
||||
}
|
||||
|
||||
float rand_chance_f(void)
|
||||
{
|
||||
return (float)mtRand->randExc (100.0);
|
||||
return (float)mtRand->randExc(100.0);
|
||||
}
|
||||
|
||||
Tokens StrSplit(const std::string &src, const std::string &sep)
|
||||
Tokens StrSplit(const std::string& src, const std::string& sep)
|
||||
{
|
||||
Tokens r;
|
||||
std::string s;
|
||||
|
|
@ -130,7 +130,7 @@ Tokens StrSplit(const std::string &src, const std::string &sep)
|
|||
|
||||
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index)
|
||||
{
|
||||
if(index >= data.size())
|
||||
if (index >= data.size())
|
||||
return 0;
|
||||
|
||||
return (uint32)atoi(data[index].c_str());
|
||||
|
|
@ -145,18 +145,18 @@ float GetFloatValueFromArray(Tokens const& data, uint16 index)
|
|||
return result;
|
||||
}
|
||||
|
||||
void stripLineInvisibleChars(std::string &str)
|
||||
void stripLineInvisibleChars(std::string& str)
|
||||
{
|
||||
static std::string invChars = " \t\7\n";
|
||||
|
||||
size_t wpos = 0;
|
||||
|
||||
bool space = false;
|
||||
for(size_t pos = 0; pos < str.size(); ++pos)
|
||||
for (size_t pos = 0; pos < str.size(); ++pos)
|
||||
{
|
||||
if(invChars.find(str[pos])!=std::string::npos)
|
||||
if (invChars.find(str[pos])!=std::string::npos)
|
||||
{
|
||||
if(!space)
|
||||
if (!space)
|
||||
{
|
||||
str[wpos++] = ' ';
|
||||
space = true;
|
||||
|
|
@ -164,7 +164,7 @@ void stripLineInvisibleChars(std::string &str)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(wpos!=pos)
|
||||
if (wpos!=pos)
|
||||
str[wpos++] = str[pos];
|
||||
else
|
||||
++wpos;
|
||||
|
|
@ -172,7 +172,7 @@ void stripLineInvisibleChars(std::string &str)
|
|||
}
|
||||
}
|
||||
|
||||
if(wpos < str.size())
|
||||
if (wpos < str.size())
|
||||
str.erase(wpos,str.size());
|
||||
}
|
||||
|
||||
|
|
@ -184,15 +184,15 @@ std::string secsToTimeString(time_t timeInSecs, bool shortText, bool hoursOnly)
|
|||
time_t days = timeInSecs / DAY;
|
||||
|
||||
std::ostringstream ss;
|
||||
if(days)
|
||||
if (days)
|
||||
ss << days << (shortText ? "d" : " Day(s) ");
|
||||
if(hours || hoursOnly)
|
||||
if (hours || hoursOnly)
|
||||
ss << hours << (shortText ? "h" : " Hour(s) ");
|
||||
if(!hoursOnly)
|
||||
if (!hoursOnly)
|
||||
{
|
||||
if(minutes)
|
||||
if (minutes)
|
||||
ss << minutes << (shortText ? "m" : " Minute(s) ");
|
||||
if(secs || (!days && !hours && !minutes) )
|
||||
if (secs || (!days && !hours && !minutes))
|
||||
ss << secs << (shortText ? "s" : " Second(s).");
|
||||
}
|
||||
|
||||
|
|
@ -205,16 +205,16 @@ uint32 TimeStringToSecs(const std::string& timestring)
|
|||
uint32 buffer = 0;
|
||||
uint32 multiplier = 0;
|
||||
|
||||
for(std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); ++itr)
|
||||
for (std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); ++itr)
|
||||
{
|
||||
if(isdigit(*itr))
|
||||
if (isdigit(*itr))
|
||||
{
|
||||
buffer*=10;
|
||||
buffer+= (*itr)-'0';
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(*itr)
|
||||
switch (*itr)
|
||||
{
|
||||
case 'd': multiplier = DAY; break;
|
||||
case 'h': multiplier = HOUR; break;
|
||||
|
|
@ -248,7 +248,7 @@ std::string TimeToTimestampStr(time_t t)
|
|||
/// Check if the string is a valid ip address representation
|
||||
bool IsIPAddress(char const* ipaddress)
|
||||
{
|
||||
if(!ipaddress)
|
||||
if (!ipaddress)
|
||||
return false;
|
||||
|
||||
// Let the big boys do it.
|
||||
|
|
@ -259,7 +259,7 @@ bool IsIPAddress(char const* ipaddress)
|
|||
/// create PID file
|
||||
uint32 CreatePIDFile(const std::string& filename)
|
||||
{
|
||||
FILE * pid_file = fopen (filename.c_str(), "w" );
|
||||
FILE* pid_file = fopen(filename.c_str(), "w");
|
||||
if (pid_file == NULL)
|
||||
return 0;
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ uint32 CreatePIDFile(const std::string& filename)
|
|||
pid_t pid = getpid();
|
||||
#endif
|
||||
|
||||
fprintf(pid_file, "%d", pid );
|
||||
fprintf(pid_file, "%d", pid);
|
||||
fclose(pid_file);
|
||||
|
||||
return (uint32)pid;
|
||||
|
|
@ -281,7 +281,7 @@ size_t utf8length(std::string& utf8str)
|
|||
{
|
||||
return utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size());
|
||||
}
|
||||
catch(std::exception)
|
||||
catch (std::exception)
|
||||
{
|
||||
utf8str = "";
|
||||
return 0;
|
||||
|
|
@ -293,7 +293,7 @@ void utf8truncate(std::string& utf8str,size_t len)
|
|||
try
|
||||
{
|
||||
size_t wlen = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size());
|
||||
if(wlen <= len)
|
||||
if (wlen <= len)
|
||||
return;
|
||||
|
||||
std::wstring wstr;
|
||||
|
|
@ -303,7 +303,7 @@ void utf8truncate(std::string& utf8str,size_t len)
|
|||
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)
|
||||
catch (std::exception)
|
||||
{
|
||||
utf8str = "";
|
||||
}
|
||||
|
|
@ -314,9 +314,9 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
|
|||
try
|
||||
{
|
||||
size_t len = utf8::distance(utf8str,utf8str+csize);
|
||||
if(len > wsize)
|
||||
if (len > wsize)
|
||||
{
|
||||
if(wsize > 0)
|
||||
if (wsize > 0)
|
||||
wstr[0] = L'\0';
|
||||
wsize = 0;
|
||||
return false;
|
||||
|
|
@ -326,9 +326,9 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
|
|||
utf8::utf8to16(utf8str,utf8str+csize,wstr);
|
||||
wstr[len] = L'\0';
|
||||
}
|
||||
catch(std::exception)
|
||||
catch (std::exception)
|
||||
{
|
||||
if(wsize > 0)
|
||||
if (wsize > 0)
|
||||
wstr[0] = L'\0';
|
||||
wsize = 0;
|
||||
return false;
|
||||
|
|
@ -347,7 +347,7 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr)
|
|||
if (len)
|
||||
utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]);
|
||||
}
|
||||
catch(std::exception)
|
||||
catch (std::exception)
|
||||
{
|
||||
wstr = L"";
|
||||
return false;
|
||||
|
|
@ -367,7 +367,7 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str)
|
|||
utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail
|
||||
utf8str = utf8str2;
|
||||
}
|
||||
catch(std::exception)
|
||||
catch (std::exception)
|
||||
{
|
||||
utf8str = "";
|
||||
return false;
|
||||
|
|
@ -387,7 +387,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str)
|
|||
utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail
|
||||
utf8str = utf8str2;
|
||||
}
|
||||
catch(std::exception)
|
||||
catch (std::exception)
|
||||
{
|
||||
utf8str = "";
|
||||
return false;
|
||||
|
|
@ -401,7 +401,7 @@ typedef wchar_t const* const* wstrlist;
|
|||
std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
|
||||
{
|
||||
// supported only Cyrillic cases
|
||||
if(wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5)
|
||||
if (wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5)
|
||||
return wname;
|
||||
|
||||
// Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently)
|
||||
|
|
@ -423,7 +423,8 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
|
|||
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] = {
|
||||
static wchar_t const* const dropEnds[6][8] =
|
||||
{
|
||||
{ &a_End[1], &o_End[1], &ya_End[1], &ie_End[1], &soft_End[1], &j_End[1], NULL, NULL },
|
||||
{ &a_End[1], &ya_End[1], &yeru_End[1], &i_End[1], NULL, NULL, NULL, NULL },
|
||||
{ &ie_End[1], &u_End[1], &yu_End[1], &i_End[1], NULL, NULL, NULL, NULL },
|
||||
|
|
@ -432,11 +433,11 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension)
|
|||
{ &ie_End[1], &i_End[1], NULL, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
for(wchar_t const * const* itr = &dropEnds[declension][0]; *itr; ++itr)
|
||||
for (wchar_t const * const* itr = &dropEnds[declension][0]; *itr; ++itr)
|
||||
{
|
||||
size_t len = size_t((*itr)[-1]); // get length from string size field
|
||||
|
||||
if(wname.substr(wname.size()-len,len)==*itr)
|
||||
if (wname.substr(wname.size()-len,len)==*itr)
|
||||
return wname.substr(0,wname.size()-len);
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +448,7 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr)
|
|||
{
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
std::wstring wstr;
|
||||
if(!Utf8toWStr(utf8str,wstr))
|
||||
if (!Utf8toWStr(utf8str,wstr))
|
||||
return false;
|
||||
|
||||
conStr.resize(wstr.size());
|
||||
|
|
@ -479,19 +480,19 @@ bool Utf8FitTo(const std::string& str, std::wstring search)
|
|||
{
|
||||
std::wstring temp;
|
||||
|
||||
if(!Utf8toWStr(str,temp))
|
||||
if (!Utf8toWStr(str,temp))
|
||||
return false;
|
||||
|
||||
// converting to lower case
|
||||
wstrToLower( temp );
|
||||
wstrToLower(temp);
|
||||
|
||||
if(temp.find(search) == std::wstring::npos)
|
||||
if (temp.find(search) == std::wstring::npos)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void utf8printf(FILE *out, const char *str, ...)
|
||||
void utf8printf(FILE* out, const char* str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
|
|
@ -499,7 +500,7 @@ void utf8printf(FILE *out, const char *str, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void vutf8printf(FILE *out, const char *str, va_list* ap)
|
||||
void vutf8printf(FILE* out, const char* str, va_list* ap)
|
||||
{
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
char temp_buf[32*1024];
|
||||
|
|
@ -520,13 +521,13 @@ 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));
|
||||
char encodedNibble;
|
||||
if(nibble < 0x0A)
|
||||
if (nibble < 0x0A)
|
||||
encodedNibble = '0'+nibble;
|
||||
else
|
||||
encodedNibble = 'A'+nibble-0x0A;
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
typedef std::vector<std::string> Tokens;
|
||||
|
||||
Tokens StrSplit(const std::string &src, const std::string &sep);
|
||||
Tokens StrSplit(const std::string& src, const std::string& sep);
|
||||
uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
|
||||
float GetFloatValueFromArray(Tokens const& data, uint16 index);
|
||||
|
||||
void stripLineInvisibleChars(std::string &src);
|
||||
void stripLineInvisibleChars(std::string& src);
|
||||
|
||||
std::string secsToTimeString(time_t timeInSecs, bool shortText = false, bool hoursOnly = false);
|
||||
uint32 TimeStringToSecs(const std::string& timestring);
|
||||
|
|
@ -85,7 +85,7 @@ inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply)
|
|||
{
|
||||
int32 cur = var;
|
||||
cur += (apply ? val : -val);
|
||||
if(cur < 0)
|
||||
if (cur < 0)
|
||||
cur = 0;
|
||||
var = cur;
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply)
|
|||
inline void ApplyModFloatVar(float& var, float val, bool apply)
|
||||
{
|
||||
var += (apply ? val : -val);
|
||||
if(var < 0)
|
||||
if (var < 0)
|
||||
var = 0;
|
||||
}
|
||||
|
||||
|
|
@ -121,60 +121,60 @@ void utf8truncate(std::string& utf8str,size_t len);
|
|||
|
||||
inline bool isBasicLatinCharacter(wchar_t wchar)
|
||||
{
|
||||
if(wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
|
||||
if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
|
||||
return true;
|
||||
if(wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
|
||||
if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isExtendedLatinCharacter(wchar_t wchar)
|
||||
{
|
||||
if(isBasicLatinCharacter(wchar))
|
||||
if (isBasicLatinCharacter(wchar))
|
||||
return true;
|
||||
if(wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
return true;
|
||||
if(wchar >= 0x00D8 && wchar <= 0x00DF) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
|
||||
if (wchar >= 0x00D8 && wchar <= 0x00DF) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
|
||||
return true;
|
||||
if(wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
|
||||
if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
|
||||
return true;
|
||||
if(wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
|
||||
if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
|
||||
return true;
|
||||
if(wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
|
||||
if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
|
||||
return true;
|
||||
if(wchar >= 0x0100 && wchar <= 0x012F) // LATIN CAPITAL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK
|
||||
if (wchar >= 0x0100 && wchar <= 0x012F) // LATIN CAPITAL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK
|
||||
return true;
|
||||
if(wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
|
||||
if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isCyrillicCharacter(wchar_t wchar)
|
||||
{
|
||||
if(wchar >= 0x0410 && wchar <= 0x044F) // CYRILLIC CAPITAL LETTER A - CYRILLIC SMALL LETTER YA
|
||||
if (wchar >= 0x0410 && wchar <= 0x044F) // CYRILLIC CAPITAL LETTER A - CYRILLIC SMALL LETTER YA
|
||||
return true;
|
||||
if(wchar == 0x0401 || wchar == 0x0451) // CYRILLIC CAPITAL LETTER IO, CYRILLIC SMALL LETTER IO
|
||||
if (wchar == 0x0401 || wchar == 0x0451) // CYRILLIC CAPITAL LETTER IO, CYRILLIC SMALL LETTER IO
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isEastAsianCharacter(wchar_t wchar)
|
||||
{
|
||||
if(wchar >= 0x1100 && wchar <= 0x11F9) // Hangul Jamo
|
||||
if (wchar >= 0x1100 && wchar <= 0x11F9) // Hangul Jamo
|
||||
return true;
|
||||
if(wchar >= 0x3041 && wchar <= 0x30FF) // Hiragana + Katakana
|
||||
if (wchar >= 0x3041 && wchar <= 0x30FF) // Hiragana + Katakana
|
||||
return true;
|
||||
if(wchar >= 0x3131 && wchar <= 0x318E) // Hangul Compatibility Jamo
|
||||
if (wchar >= 0x3131 && wchar <= 0x318E) // Hangul Compatibility Jamo
|
||||
return true;
|
||||
if(wchar >= 0x31F0 && wchar <= 0x31FF) // Katakana Phonetic Ext.
|
||||
if (wchar >= 0x31F0 && wchar <= 0x31FF) // Katakana Phonetic Ext.
|
||||
return true;
|
||||
if(wchar >= 0x3400 && wchar <= 0x4DB5) // CJK Ideographs Ext. A
|
||||
if (wchar >= 0x3400 && wchar <= 0x4DB5) // CJK Ideographs Ext. A
|
||||
return true;
|
||||
if(wchar >= 0x4E00 && wchar <= 0x9FC3) // Unified CJK Ideographs
|
||||
if (wchar >= 0x4E00 && wchar <= 0x9FC3) // Unified CJK Ideographs
|
||||
return true;
|
||||
if(wchar >= 0xAC00 && wchar <= 0xD7A3) // Hangul Syllables
|
||||
if (wchar >= 0xAC00 && wchar <= 0xD7A3) // Hangul Syllables
|
||||
return true;
|
||||
if(wchar >= 0xFF01 && wchar <= 0xFFEE) // Halfwidth forms
|
||||
if (wchar >= 0xFF01 && wchar <= 0xFFEE) // Halfwidth forms
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -201,7 +201,7 @@ inline bool isNumericOrSpace(wchar_t wchar)
|
|||
|
||||
inline bool isNumeric(char const* str)
|
||||
{
|
||||
for(char const* c = str; *c; ++c)
|
||||
for (char const* c = str; *c; ++c)
|
||||
if (!isNumeric(*c))
|
||||
return false;
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ inline bool isNumeric(char const* str)
|
|||
|
||||
inline bool isNumeric(std::string const& str)
|
||||
{
|
||||
for(std::string::const_iterator itr = str.begin(); itr != str.end(); ++itr)
|
||||
for (std::string::const_iterator itr = str.begin(); itr != str.end(); ++itr)
|
||||
if (!isNumeric(*itr))
|
||||
return false;
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ inline bool isNumeric(std::string const& str)
|
|||
|
||||
inline bool isNumeric(std::wstring const& str)
|
||||
{
|
||||
for(std::wstring::const_iterator itr = str.begin(); itr != str.end(); ++itr)
|
||||
for (std::wstring::const_iterator itr = str.begin(); itr != str.end(); ++itr)
|
||||
if (!isNumeric(*itr))
|
||||
return false;
|
||||
|
||||
|
|
@ -228,64 +228,64 @@ inline bool isNumeric(std::wstring const& str)
|
|||
|
||||
inline bool isBasicLatinString(std::wstring wstr, bool numericOrSpace)
|
||||
{
|
||||
for(size_t i = 0; i < wstr.size(); ++i)
|
||||
if(!isBasicLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isBasicLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool isExtendedLatinString(std::wstring wstr, bool numericOrSpace)
|
||||
{
|
||||
for(size_t i = 0; i < wstr.size(); ++i)
|
||||
if(!isExtendedLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isExtendedLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool isCyrillicString(std::wstring wstr, bool numericOrSpace)
|
||||
{
|
||||
for(size_t i = 0; i < wstr.size(); ++i)
|
||||
if(!isCyrillicCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isCyrillicCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool isEastAsianString(std::wstring wstr, bool numericOrSpace)
|
||||
{
|
||||
for(size_t i = 0; i < wstr.size(); ++i)
|
||||
if(!isEastAsianCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isEastAsianCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void strToUpper(std::string& str)
|
||||
{
|
||||
std::transform( str.begin(), str.end(), str.begin(), toupper );
|
||||
std::transform(str.begin(), str.end(), str.begin(), toupper);
|
||||
}
|
||||
|
||||
inline void strToLower(std::string& str)
|
||||
{
|
||||
std::transform( str.begin(), str.end(), str.begin(), tolower );
|
||||
std::transform(str.begin(), str.end(), str.begin(), tolower);
|
||||
}
|
||||
|
||||
inline wchar_t wcharToUpper(wchar_t wchar)
|
||||
{
|
||||
if(wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
|
||||
if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
|
||||
return wchar_t(uint16(wchar)-0x0020);
|
||||
if(wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
|
||||
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
|
||||
if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
|
||||
return wchar_t(uint16(wchar)-0x0020);
|
||||
if(wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
|
||||
if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
|
||||
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 >= 0x0101 && wchar <= 0x012F) // LATIN SMALL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK (only %2=1)
|
||||
{
|
||||
if(wchar % 2 == 1)
|
||||
if (wchar % 2 == 1)
|
||||
return wchar_t(uint16(wchar)-0x0001);
|
||||
}
|
||||
if(wchar >= 0x0430 && wchar <= 0x044F) // CYRILLIC SMALL LETTER A - CYRILLIC SMALL LETTER YA
|
||||
if (wchar >= 0x0430 && wchar <= 0x044F) // CYRILLIC SMALL LETTER A - CYRILLIC SMALL LETTER YA
|
||||
return wchar_t(uint16(wchar)-0x0020);
|
||||
if(wchar == 0x0451) // CYRILLIC SMALL LETTER IO
|
||||
if (wchar == 0x0451) // CYRILLIC SMALL LETTER IO
|
||||
return wchar_t(0x0401);
|
||||
|
||||
return wchar;
|
||||
|
|
@ -298,22 +298,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
|
||||
if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
|
||||
return wchar_t(uint16(wchar)+0x0020);
|
||||
if(wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
|
||||
return wchar_t(uint16(wchar)+0x0020);
|
||||
if(wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
|
||||
if (wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
|
||||
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 >= 0x0100 && wchar <= 0x012E) // LATIN CAPITAL LETTER A WITH MACRON - LATIN CAPITAL LETTER I WITH OGONEK (only %2=0)
|
||||
{
|
||||
if(wchar % 2 == 0)
|
||||
if (wchar % 2 == 0)
|
||||
return wchar_t(uint16(wchar)+0x0001);
|
||||
}
|
||||
if(wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
|
||||
if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
|
||||
return wchar_t(0x00DF);
|
||||
if(wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO
|
||||
if (wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO
|
||||
return wchar_t(0x0451);
|
||||
if(wchar >= 0x0410 && wchar <= 0x042F) // CYRILLIC CAPITAL LETTER A - CYRILLIC CAPITAL LETTER YA
|
||||
if (wchar >= 0x0410 && wchar <= 0x042F) // CYRILLIC CAPITAL LETTER A - CYRILLIC CAPITAL LETTER YA
|
||||
return wchar_t(uint16(wchar)+0x0020);
|
||||
|
||||
return wchar;
|
||||
|
|
@ -321,12 +321,12 @@ inline wchar_t wcharToLower(wchar_t wchar)
|
|||
|
||||
inline void wstrToUpper(std::wstring& str)
|
||||
{
|
||||
std::transform( str.begin(), str.end(), str.begin(), wcharToUpper );
|
||||
std::transform(str.begin(), str.end(), str.begin(), wcharToUpper);
|
||||
}
|
||||
|
||||
inline void wstrToLower(std::wstring& str)
|
||||
{
|
||||
std::transform( str.begin(), str.end(), str.begin(), wcharToLower );
|
||||
std::transform(str.begin(), str.end(), str.begin(), wcharToLower);
|
||||
}
|
||||
|
||||
std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
|
||||
|
|
@ -334,8 +334,8 @@ 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 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);
|
||||
void utf8printf(FILE* out, const char* str, ...);
|
||||
void vutf8printf(FILE* out, const char* str, va_list* ap);
|
||||
|
||||
bool IsIPAddress(char const* ipaddress);
|
||||
uint32 CreatePIDFile(const std::string& filename);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -72,39 +72,39 @@ class WheatyExceptionReport
|
|||
{
|
||||
public:
|
||||
|
||||
WheatyExceptionReport( );
|
||||
~WheatyExceptionReport( );
|
||||
WheatyExceptionReport();
|
||||
~WheatyExceptionReport();
|
||||
|
||||
// entry point where control comes on an unhandled exception
|
||||
static LONG WINAPI WheatyUnhandledExceptionFilter(
|
||||
PEXCEPTION_POINTERS pExceptionInfo );
|
||||
PEXCEPTION_POINTERS pExceptionInfo);
|
||||
|
||||
static void printTracesForAllThreads();
|
||||
private:
|
||||
// where report info is extracted and generated
|
||||
static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo );
|
||||
static void GenerateExceptionReport(PEXCEPTION_POINTERS pExceptionInfo);
|
||||
static void PrintSystemInfo();
|
||||
static BOOL _GetWindowsVersion(TCHAR* szVersion, DWORD cntMax);
|
||||
static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount);
|
||||
|
||||
// Helper functions
|
||||
static LPTSTR GetExceptionString( DWORD dwCode );
|
||||
static BOOL GetLogicalAddress( PVOID addr, PTSTR szModule, DWORD len,
|
||||
DWORD& section, DWORD_PTR& offset );
|
||||
static LPTSTR GetExceptionString(DWORD dwCode);
|
||||
static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len,
|
||||
DWORD& section, DWORD_PTR& offset);
|
||||
|
||||
static void WriteStackDetails( PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
|
||||
static void WriteStackDetails(PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
|
||||
|
||||
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID);
|
||||
|
||||
static bool FormatSymbolValue( PSYMBOL_INFO, STACKFRAME *, char * pszBuffer, unsigned cbBuffer );
|
||||
static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME*, char* pszBuffer, unsigned cbBuffer);
|
||||
|
||||
static char * DumpTypeIndex( char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool & , char*);
|
||||
static char* DumpTypeIndex(char*, DWORD64, DWORD, unsigned, DWORD_PTR, bool& , char*);
|
||||
|
||||
static char * FormatOutputValue( char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress );
|
||||
static char* FormatOutputValue(char* pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress);
|
||||
|
||||
static BasicType GetBasicType( DWORD typeIndex, DWORD64 modBase );
|
||||
static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase);
|
||||
|
||||
static int __cdecl _tprintf(const TCHAR * format, ...);
|
||||
static int __cdecl _tprintf(const TCHAR* format, ...);
|
||||
|
||||
// Variables used by the class
|
||||
static TCHAR m_szLogFileName[MAX_PATH];
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@
|
|||
class WorldPacket : public ByteBuffer
|
||||
{
|
||||
public:
|
||||
// just container for later use
|
||||
// just container for later use
|
||||
WorldPacket() : ByteBuffer(0), m_opcode(0)
|
||||
{
|
||||
}
|
||||
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)
|
||||
// copy constructor
|
||||
WorldPacket(const WorldPacket& packet) : ByteBuffer(packet), m_opcode(packet.m_opcode)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12061"
|
||||
#define REVISION_NR "12062"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue