Merge remote branch 'origin/master' into 330

Conflicts:
	src/game/Unit.cpp
This commit is contained in:
tomrus88 2010-03-10 20:24:28 +03:00
commit e73c5d3b79
177 changed files with 24212 additions and 2127 deletions

View file

@ -45,6 +45,12 @@ class ByteBufferException
size_t size;
};
template<class T>
struct Unused
{
Unused() {}
};
class ByteBuffer
{
public:
@ -71,12 +77,6 @@ class ByteBuffer
_rpos = _wpos = 0;
}
template <typename T> void append(T value)
{
EndianConvert(value);
append((uint8 *)&value, sizeof(value));
}
template <typename T> void put(size_t pos,T value)
{
EndianConvert(value);
@ -239,6 +239,14 @@ class ByteBuffer
return *this;
}
template<class T>
ByteBuffer &operator>>(Unused<T> const&)
{
read_skip<T>();
return *this;
}
uint8 operator[](size_t pos) const
{
return read<uint8>(pos);
@ -294,13 +302,9 @@ class ByteBuffer
_rpos += len;
}
bool readPackGUID(uint64& guid)
uint64 readPackGUID()
{
if(rpos() + 1 > size())
return false;
guid = 0;
uint64 guid = 0;
uint8 guidmark = 0;
(*this) >> guidmark;
@ -308,16 +312,13 @@ class ByteBuffer
{
if(guidmark & (uint8(1) << i))
{
if(rpos() + 1 > size())
return false;
uint8 bit;
(*this) >> bit;
guid |= (uint64(bit) << (i * 8));
}
}
return true;
return guid;
}
const uint8 *contents() const { return &_storage[0]; }
@ -491,6 +492,13 @@ class ByteBuffer
}
sLog.outDebugInLine("\n");
}
private:
// limited for internal use because can "append" any unexpected type (like pointer and etc) with hard detection problem
template <typename T> void append(T value)
{
EndianConvert(value);
append((uint8 *)&value, sizeof(value));
}
protected:
size_t _rpos, _wpos;
@ -498,7 +506,7 @@ class ByteBuffer
};
template <typename T>
inline ByteBuffer &operator<<(ByteBuffer &b, std::vector<T> 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)
@ -524,7 +532,7 @@ inline ByteBuffer &operator>>(ByteBuffer &b, std::vector<T> &v)
}
template <typename T>
inline ByteBuffer &operator<<(ByteBuffer &b, std::list<T> 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)

View file

@ -75,6 +75,10 @@
#include <signal.h>
#include <assert.h>
#if defined(__sun__)
#include <ieeefp.h> // finite() on Solaris
#endif
#include <set>
#include <list>
#include <string>
@ -146,6 +150,15 @@ inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; }
#define STRINGIZE(a) #a
// used for creating values for respawn for example
#define MAKE_PAIR64(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
#define PAIR64_HIPART(x) (uint32)((uint64(x) >> 32) & UI64LIT(0x00000000FFFFFFFF))
#define PAIR64_LOPART(x) (uint32)(uint64(x) & UI64LIT(0x00000000FFFFFFFF))
#define MAKE_PAIR32(l, h) uint32( uint16(l) | ( uint32(h) << 16 ) )
#define PAIR32_HIPART(x) (uint16)((uint32(x) >> 16) & 0x0000FFFF)
#define PAIR32_LOPART(x) (uint16)(uint32(x) & 0x0000FFFF)
enum TimeConstants
{
MINUTE = 60,

View file

@ -40,6 +40,7 @@ bool Database::Initialize(const char *)
m_logsDir.append("/");
}
m_pingIntervallms = sConfig.GetIntDefault ("MaxPingTime", 30) * (MINUTE * 1000);
return true;
}
@ -228,4 +229,4 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
sLog.outErrorDb("Table `%s` fields list query fail but expected have `%s`! No records in `%s`?",table_name,required_name,table_name);
return false;
}
}

View file

@ -130,8 +130,11 @@ class MANGOS_DLL_SPEC Database
void SetResultQueue(SqlResultQueue * queue);
bool CheckRequiredField(char const* table_name, char const* required_name);
uint32 GetPingIntervall() { return m_pingIntervallms;}
private:
bool m_logSQL;
std::string m_logsDir;
uint32 m_pingIntervallms;
};
#endif

View file

@ -33,8 +33,8 @@ const char CreatureInfoAddonInfofmt[]="iiiiiis";
const char EquipmentInfofmt[]="iiii";
const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis";
const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiii";
const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiii";
const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii";
const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii";
const char PageTextfmt[]="isi";
const char InstanceTemplatesrcfmt[]="iiiiffffs";
const char InstanceTemplatedstfmt[]="iiiiffffi";

View file

@ -30,17 +30,28 @@ void SqlDelayThread::run()
mysql_thread_init();
#endif
const uint32 loopSleepms = 10;
const uint32 pingEveryLoop = m_dbEngine->GetPingIntervall()/loopSleepms;
uint32 loopCounter = 0;
while (m_running)
{
// if the running state gets turned off while sleeping
// empty the queue before exiting
ACE_Based::Thread::Sleep(10);
ACE_Based::Thread::Sleep(loopSleepms);
SqlOperation* s;
while (m_sqlQueue.next(s))
{
s->Execute(m_dbEngine);
delete s;
}
if((loopCounter++) >= pingEveryLoop)
{
loopCounter = 0;
delete m_dbEngine->Query("SELECT 1");
}
}
#ifndef DO_POSTGRESQL

View file

@ -95,7 +95,11 @@ int ThreadPriority::getPriority(Priority p) const
return m_priority[p];
}
#define THREADFLAG (THR_NEW_LWP | THR_SCHED_DEFAULT| THR_JOINABLE)
#ifndef __sun__
# define THREADFLAG (THR_NEW_LWP | THR_JOINABLE | THR_SCHED_DEFAULT)
#else
# define THREADFLAG (THR_NEW_LWP | THR_JOINABLE)
#endif
Thread::Thread() : m_task(0), m_iThreadId(0), m_hThreadHandle(0)
{
@ -220,10 +224,12 @@ Thread * Thread::current()
void Thread::setPriority(Priority type)
{
#ifndef __sun__
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
ASSERT (_ok == 0);
#endif
}
void Thread::Sleep(unsigned long msecs)

View file

@ -18,10 +18,10 @@
#include "Util.h"
#include "sockets/socket_include.h"
#include "utf8cpp/utf8.h"
#include "mersennetwister/MersenneTwister.h"
#include <ace/TSS_T.h>
#include <ace/INET_Addr.h>
typedef ACE_TSS<MTRand> MTRandTSS;
static MTRandTSS mtRand;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9439"
#define REVISION_NR "9565"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_9375_01_characters_character_glyphs"
#define REVISION_DB_MANGOS "required_9385_01_mangos_command"
#define REVISION_DB_MANGOS "required_9539_01_mangos_spell_bonus_data"
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
#endif // __REVISION_SQL_H__