Core: Add new system for parallelizing client packet processing. Handle WorldSession updates in Map::Update() where we are safe to proceed. Patch by Ambal.

(And clean up tabs and whitespace while rummaging around in there)
Closes issue 5084.

--HG--
branch : trunk
This commit is contained in:
click
2010-12-13 22:37:56 +01:00
parent 89a33bbf61
commit 2642894342
58 changed files with 1625 additions and 1502 deletions
+38 -1
View File
@@ -138,6 +138,43 @@ enum CharterTypes
ARENA_TEAM_CHARTER_5v5_TYPE = 5
};
//class to deal with packet processing
//allows to determine if next packet is safe to be processed
class PacketFilter
{
public:
explicit PacketFilter(WorldSession * pSession) : m_pSession(pSession) {}
virtual ~PacketFilter() {}
virtual bool Process(WorldPacket * packet) { return true; }
virtual bool ProcessLogout() const { return true; }
protected:
WorldSession * const m_pSession;
};
//process only thread-safe packets in Map::Update()
class MapSessionFilter : public PacketFilter
{
public:
explicit MapSessionFilter(WorldSession * pSession) : PacketFilter(pSession) {}
~MapSessionFilter() {}
virtual bool Process(WorldPacket * packet);
//in Map::Update() we do not process player logout!
virtual bool ProcessLogout() const { return false; }
};
//class used to filer only thread-unsafe packets from queue
//in order to update only be used in World::UpdateSessions()
class WorldSessionFilter : public PacketFilter
{
public:
explicit WorldSessionFilter(WorldSession * pSession) : PacketFilter(pSession) {}
~WorldSessionFilter() {}
virtual bool Process(WorldPacket* packet);
};
/// Player session in the World
class WorldSession
{
@@ -201,7 +238,7 @@ class WorldSession
void KickPlayer();
void QueuePacket(WorldPacket* new_packet);
bool Update(uint32 diff);
bool Update(uint32 diff, PacketFilter& updater);
/// Handle the authentication waiting queue (to be completed)
void SendAuthWaitQue(uint32 position);