Merge commit 'origin/master' into 320

Conflicts:
	src/game/DBCStructure.h
	src/game/DBCfmt.h
	src/game/MiscHandler.cpp
	src/game/ObjectMgr.cpp
This commit is contained in:
tomrus88 2009-09-04 21:16:59 +04:00
commit 4a8431f581
51 changed files with 739 additions and 612 deletions

View file

@ -159,6 +159,11 @@ uint32 BigNumber::AsDword()
return (uint32)BN_get_word(_bn);
}
bool BigNumber::isZero() const
{
return BN_is_zero(_bn)!=0;
}
uint8 *BigNumber::AsByteArray(int minSize)
{
int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes();

View file

@ -72,6 +72,8 @@ class BigNumber
return t %= bn;
}
bool isZero() const;
BigNumber ModExp(const BigNumber &bn1, const BigNumber &bn2);
BigNumber Exp(const BigNumber &);

View file

@ -42,8 +42,6 @@ class Sha1Hash
uint8 *GetDigest(void) { return mDigest; };
int GetLength(void) { return SHA_DIGEST_LENGTH; };
BigNumber GetBigNumber();
private:
SHA_CTX mC;
uint8 mDigest[SHA_DIGEST_LENGTH];

View file

@ -220,12 +220,12 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
delete result;
if(!reqName.empty())
{
sLog.outErrorDb("Table `%s` have field `%s` but expected `%s`! Not all sql updates applied?",table_name,reqName.c_str(),required_name);
return false;
}
else
sLog.outErrorDb("Table `%s` not have required_* field but expected `%s`! Not all sql updates applied?",table_name,required_name);
}
else
sLog.outErrorDb("Table `%s` fields list query fail but expected have `%s`! No records in `%s`?",table_name,required_name,table_name);
sLog.outErrorDb("Table `%s` not have required_* field but expected `%s`! Not all sql updates applied?",table_name,required_name);
return false;
}

View file

@ -26,7 +26,6 @@ SqlDelayThread::SqlDelayThread(Database* db) : m_dbEngine(db), m_running(true)
void SqlDelayThread::run()
{
SqlOperation* s;
#ifndef DO_POSTGRESQL
mysql_thread_init();
#endif
@ -36,9 +35,9 @@ void SqlDelayThread::run()
// if the running state gets turned off while sleeping
// empty the queue before exiting
ACE_Based::Thread::Sleep(10);
while (!m_sqlQueue.empty())
SqlOperation* s;
while (m_sqlQueue.next(s))
{
s = m_sqlQueue.next();
s->Execute(m_dbEngine);
delete s;
}

View file

@ -71,9 +71,9 @@ void SqlQuery::Execute(Database *db)
void SqlResultQueue::Update()
{
/// execute the callbacks waiting in the synchronization queue
while(!empty())
MaNGOS::IQueryCallback* callback;
while (next(callback))
{
MaNGOS::IQueryCallback * callback = next();
callback->Execute();
delete callback;
}

View file

@ -30,99 +30,65 @@ namespace ACE_Based
template <class T, class LockType, typename StorageType=std::deque<T> >
class LockedQueue
{
//! Serialize access to the Queue
//! Lock access to the queue.
LockType _lock;
//! Storage backing the queue
//! Storage backing the queue.
StorageType _queue;
//! Cancellation flag
volatile bool _canceled;
//! Cancellation flag.
/*volatile*/ bool _canceled;
public:
//! Create a LockedQueue
//! Create a LockedQueue.
LockedQueue() : _canceled(false) {}
//! Destroy a LockedQueue
//! Destroy a LockedQueue.
virtual ~LockedQueue() { }
/**
* @see Queue::add(const T& item)
*/
//! Adds an item to the queue.
void add(const T& item)
{
ACE_Guard<LockType> g(this->_lock);
ASSERT(!this->_canceled);
//ASSERT(!this->_canceled);
// throw Cancellation_Exception();
this->_queue.push_back(item);
_queue.push_back(item);
}
/**
* @see Queue::next()
*/
T next()
//! Gets the next result in the queue, if any.
bool next(T& result)
{
ACE_Guard<LockType> g(this->_lock);
ASSERT (!_queue.empty() || !this->_canceled);
if (_queue.empty())
return false;
//ASSERT (!_queue.empty() || !this->_canceled);
// throw Cancellation_Exception();
T item = this->_queue.front();
this->_queue.pop_front();
result = _queue.front();
_queue.pop_front();
return item;
return true;
}
T front()
{
ACE_Guard<LockType> g(this->_lock);
ASSERT (!this->_queue.empty());
// throw NoSuchElement_Exception();
return this->_queue.front();
}
/**
* @see Queue::cancel()
*/
//! Cancels the queue.
void cancel()
{
ACE_Guard<LockType> g(this->_lock);
this->_canceled = true;
_canceled = true;
}
/**
* @see Queue::isCanceled()
*/
bool isCanceled()
{
// Faster check since the queue will not become un-canceled
if(this->_canceled)
return true;
ACE_Guard<LockType> g(this->_lock);
return this->_canceled;
}
/**
* @see Queue::size()
*/
size_t size()
//! Checks if the queue is cancelled.
bool cancelled()
{
ACE_Guard<LockType> g(this->_lock);
return this->_queue.size();
}
bool empty()
{
ACE_Guard<LockType> g(this->_lock);
return this->_queue.empty();
return _canceled;
}
};
}

View file

@ -441,3 +441,23 @@ void vutf8printf(FILE *out, const char *str, va_list* ap)
vfprintf(out, str, *ap);
#endif
}
void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result)
{
std::ostringstream ss;
for(uint32 i=0; i<arrayLen; ++i)
{
for(uint8 j=0; j<2; ++j)
{
unsigned char nibble = 0x0F & (bytes[i]>>((1-j)*4));
char encodedNibble;
if(nibble < 0x0A)
encodedNibble = '0'+nibble;
else
encodedNibble = 'A'+nibble-0x0A;
ss << encodedNibble;
}
}
result = ss.str();
}

View file

@ -289,4 +289,5 @@ void vutf8printf(FILE *out, const char *str, va_list* ap);
bool IsIPAddress(char const* ipaddress);
uint32 CreatePIDFile(const std::string& filename);
void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result);
#endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8441"
#define REVISION_NR "8467"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_8433_01_characters_character_account_data"
#define REVISION_DB_MANGOS "required_8416_01_mangos_spell_learn_spell"
#define REVISION_DB_MANGOS "required_8462_01_mangos_creature_ai_texts"
#define REVISION_DB_REALMD "required_8332_01_realmd_realmcharacters"
#endif // __REVISION_SQL_H__