Jump to content

XTZGZoReX

Members
  • Posts

    240
  • Joined

  • Last visited

    Never
  • Donations

    0.00 GBP 

Everything posted by XTZGZoReX

  1. I think it's ok, as long as gossip handling for the gossip type stays in core.
  2. One word: Awesome.
  3. Anything can crash when you use custom patches .
  4. Theoretically it should work in 2.x as well, since all that has been changed is the value of the update field names. But, keep in mind, the SQL query might not work, since it uses hardcoded numbers.
  5. Yes, I agree.
  6. Uh... Not really. Less CPU usage at the cost of more RAM.. preferable.
  7. http://paste2.org/p/366976 This uses CREATURE_MAX_SPELLS for the m_charmspells array and the loop in the constructor, mostly for consistency.
  8. What does this patch do?: * Makes LockedQueue 100% thread-safe by killing race conditions in several functions (::size(), ::empty(), ::next(), ::front(), etc). * Removes ::empty(), ::front() and ::size() as they make no sense in the context of a locked queue. * Converts existing code to do: SomeObj* obj; while (queue.next(obj)) { obj->dowork(); delete obj; } - instead of using .empty() which may give wrong results. diff --git a/src/game/World.cpp b/src/game/World.cpp index d8a5ab6..9ee21a2 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -112,8 +112,9 @@ World::~World() m_weathers.clear(); - while (!cliCmdQueue.empty()) - delete cliCmdQueue.next(); + CliCommandHolder* command; + while (cliCmdQueue.next(command)) + delete command; VMAP::VMapFactory::clear(); @@ -1967,11 +1968,9 @@ void World::SendServerMessage(ServerMessageType type, const char *text, Player* void World::UpdateSessions( uint32 diff ) { ///- Add new sessions - while(!addSessQueue.empty()) - { - WorldSession* sess = addSessQueue.next (); + WorldSession* sess; + while(addSessQueue.next(sess)) AddSession_ (sess); - } ///- Then send an update signal to remaining ones for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next) @@ -1995,25 +1994,20 @@ void World::UpdateSessions( uint32 diff ) // This handles the issued and queued CLI commands void World::ProcessCliCommands() { - if (cliCmdQueue.empty()) - return; + CliCommandHolder::Print* zprint = NULL; - CliCommandHolder::Print* zprint; - - while (!cliCmdQueue.empty()) + CliCommandHolder* command; + while (cliCmdQueue.next(command)) { sLog.outDebug("CLI command under processing..."); - CliCommandHolder *command = cliCmdQueue.next(); - zprint = command->m_print; - CliHandler(zprint).ParseCommands(command->m_command); - delete command; } // print the console message here so it looks right - zprint("mangos>"); + if (zprint) + zprint("mangos>"); } void World::InitResultQueue() diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 5c8b44b..b4b3076 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -69,11 +69,9 @@ WorldSession::~WorldSession() } ///- empty incoming packet queue - while(!_recvQueue.empty()) - { - WorldPacket *packet = _recvQueue.next (); + WorldPacket* packet; + while(_recvQueue.next(packet)) delete packet; - } } void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const @@ -154,10 +152,9 @@ bool WorldSession::Update(uint32 /*diff*/) { ///- Retrieve packets from the receive queue and call the appropriate handlers /// not proccess packets if socket already closed - while (!_recvQueue.empty() && m_Socket && !m_Socket->IsClosed ()) + WorldPacket* packet; + while (_recvQueue.next(packet) && m_Socket && !m_Socket->IsClosed ()) { - WorldPacket *packet = _recvQueue.next(); - /*#if 1 sLog.outError( "MOEP: %s (0x%.4X)", LookupOpcodeName(packet->GetOpcode()), diff --git a/src/shared/Database/SqlDelayThread.cpp b/src/shared/Database/SqlDelayThread.cpp index 2ff8908..813e12d 100644 --- a/src/shared/Database/SqlDelayThread.cpp +++ b/src/shared/Database/SqlDelayThread.cpp @@ -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; } diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index a430998..d47e85d 100644 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -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; } diff --git a/src/shared/LockedQueue.h b/src/shared/LockedQueue.h index 4087ebf..72ec9e1 100644 --- a/src/shared/LockedQueue.h +++ b/src/shared/LockedQueue.h @@ -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); - // throw Cancellation_Exception(); - - T item = this->_queue.front(); - this->_queue.pop_front(); - - return item; - } + if (_queue.empty()) + return false; - T front() - { - ACE_Guard<LockType> g(this->_lock); + //ASSERT (!_queue.empty() || !this->_canceled); + // throw Cancellation_Exception(); - ASSERT (!this->_queue.empty()); - // throw NoSuchElement_Exception(); + result = _queue.front(); + _queue.pop_front(); - return this->_queue.front(); + return true; } - /** - * @see Queue::cancel() - */ + //! Cancels the queue. void cancel() { ACE_Guard<LockType> g(this->_lock); - this->_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; + _canceled = true; } - /** - * @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; } }; }
  9. diff --git a/src/game/Player.cpp b/src/game/Player.cpp index a4c8872..1f13b1d 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -15917,7 +15917,7 @@ void Player::outDebugValues() const sLog.outDebug("HP is: \\t\\t\\t%u\\t\\tMP is: \\t\\t\\t%u",GetMaxHealth(), GetMaxPower(POWER_MANA)); sLog.outDebug("AGILITY is: \\t\\t%f\\t\\tSTRENGTH is: \\t\\t%f",GetStat(STAT_AGILITY), GetStat(STAT_STRENGTH)); sLog.outDebug("INTELLECT is: \\t\\t%f\\t\\tSPIRIT is: \\t\\t%f",GetStat(STAT_INTELLECT), GetStat(STAT_SPIRIT)); - sLog.outDebug("STAMINA is: \\t\\t%f\\t\\tSPIRIT is: \\t\\t%f",GetStat(STAT_STAMINA), GetStat(STAT_SPIRIT)); + sLog.outDebug("STAMINA is: \\t\\t%f",GetStat(STAT_STAMINA)); sLog.outDebug("Armor is: \\t\\t%u\\t\\tBlock is: \\t\\t%f",GetArmor(), GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); sLog.outDebug("HolyRes is: \\t\\t%u\\t\\tFireRes is: \\t\\t%u",GetResistance(SPELL_SCHOOL_HOLY), GetResistance(SPELL_SCHOOL_FIRE)); sLog.outDebug("NatureRes is: \\t\\t%u\\t\\tFrostRes is: \\t\\t%u",GetResistance(SPELL_SCHOOL_NATURE), GetResistance(SPELL_SCHOOL_FROST)); Don't see any reason for it to be there twice .
  10. I'd just like to know if this is taken from Trinity? If so, proper credit must be provided. If not, nevermind me .
  11. Good job, I'll give it a go.
  12. Just fixing up some mistakes in OP's patch... I've no clue if the patch is correct, I'm just fixing the ArenaTeam:: which shouldn't be there and some codestyle. EDIT: New patch - http://paste2.org/p/345148 My version above checks if the season is is '6' (see link posted by Dietrich) so that the arena system is compatible with older seasons, too.
  13. Why don't we move extractor into main src/ folder and put it in mangosd.sln? Then we can also use ACE for type defs.
  14. Normally I wouldn't point at other projects, but Trinity has an ok-ish implementation written by megamage, that you can look at.
  15. Well, I think if it's a seperate process, we should as a first step make realmd<->worldd intercommunicate first .
  16. If anything, movement pathing should _definitely_ have its own thread and mob movement, as well, would have to be threaded. That's the only real way we can efficiently implement it in MaNGOS as it is. People who intend to use movement pathing in the future surely also must be aware of how heavy it will be...
  17. That's some damned nice progress there. If you need a hand in memory management, just poke me.
  18. Does retail really work that way? I have not been able to confirm. But anyway, to really achieve this, we need some sort of intercommunication... Which is hard to realize in C++, without using CORBA or something (see multimangos). So you think I should load value at WorldSession creation and save at player disconnect?
  19. Short answer: no. Long answer: check MapInstanced.cpp Generally, it's not possible in a non-hacky way - but sure, it can be done.
  20. For Windows, get Platform SDK.
  21. You'd only really see the effect if you had 2 or more realms, yes.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use