diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index bda661ca1..61b6365d2 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -39,45 +39,44 @@ #include "Auth/HMACSHA1.h" #include "zlib/zlib.h" -bool MapSessionFilter::Process(WorldPacket * packet) +// select opcodes appropriate for processing in Map::Update context for current session state +static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& opHandle) { - OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; - //let's check if our opcode can be really processed in Map::Update() - if(opHandle.packetProcessing == PROCESS_INPLACE) - return true; - - //we do not process thread-unsafe packets - if(opHandle.packetProcessing == PROCESS_THREADUNSAFE) + // we do not process thread-unsafe packets + if (opHandle.packetProcessing == PROCESS_THREADUNSAFE) return false; - Player * plr = m_pSession->GetPlayer(); - if(!plr) + // we do not process not loggined player packets + Player * plr = session->GetPlayer(); + if (!plr) return false; - //in Map::Update() we do not process packets where player is not in world! + // in Map::Update() we do not process packets where player is not in world! return plr->IsInWorld(); } -//we should process ALL packets when player is not in world/logged in -//OR packet handler is not thread-safe! + +bool MapSessionFilter::Process(WorldPacket * packet) +{ + OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; + if (opHandle.packetProcessing == PROCESS_INPLACE) + return true; + + // let's check if our opcode can be really processed in Map::Update() + return MapSessionFilterHelper(m_pSession, opHandle); +} + +// we should process ALL packets when player is not in world/logged in +// OR packet handler is not thread-safe! bool WorldSessionFilter::Process(WorldPacket* packet) { OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; - //check if packet handler is supposed to be safe - if(opHandle.packetProcessing == PROCESS_INPLACE) + // check if packet handler is supposed to be safe + if (opHandle.packetProcessing == PROCESS_INPLACE) return true; - //thread-unsafe packets should be processed in World::UpdateSessions() - if(opHandle.packetProcessing == PROCESS_THREADUNSAFE) - return true; - - //no player attached? -> our client! ^^ - Player * plr = m_pSession->GetPlayer(); - if(!plr) - return true; - - //lets process all packets for non-in-the-world player - return (plr->IsInWorld() == false); + // let's check if our opcode can't be processed in Map::Update() + return !MapSessionFilterHelper(m_pSession, opHandle); } /// WorldSession constructor diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 6c4ef4df7..f3c179cba 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -148,37 +148,37 @@ enum TutorialDataState //allows to determine if next packet is safe to be processed class PacketFilter { -public: - explicit PacketFilter(WorldSession * pSession) : m_pSession(pSession) {} - virtual ~PacketFilter() {} + public: + explicit PacketFilter(WorldSession * pSession) : m_pSession(pSession) {} + virtual ~PacketFilter() {} - virtual bool Process(WorldPacket * packet) { return true; } - virtual bool ProcessLogout() const { return true; } + virtual bool Process(WorldPacket * packet) { return true; } + virtual bool ProcessLogout() const { return true; } -protected: - WorldSession * const m_pSession; + 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() {} + 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; } + 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() {} + public: + explicit WorldSessionFilter(WorldSession * pSession) : PacketFilter(pSession) {} + ~WorldSessionFilter() {} - virtual bool Process(WorldPacket* packet); + virtual bool Process(WorldPacket* packet); }; /// Player session in the World diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8e6567207..ba72f9d19 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10849" + #define REVISION_NR "10850" #endif // __REVISION_NR_H__