[10850] Move common check part for recently added filter classes to helper function.

This is more safe have expected tio be same check in one function.

Also apply some code style fixes.
This commit is contained in:
VladimirMangos 2010-12-10 01:52:46 +03:00
parent 028fda6b64
commit 92ce21d009
3 changed files with 43 additions and 44 deletions

View file

@ -39,18 +39,15 @@
#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)
return false;
Player * plr = m_pSession->GetPlayer();
// we do not process not loggined player packets
Player * plr = session->GetPlayer();
if (!plr)
return false;
@ -58,6 +55,17 @@ bool MapSessionFilter::Process(WorldPacket * packet)
return plr->IsInWorld();
}
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)
@ -67,17 +75,8 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
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

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10849"
#define REVISION_NR "10850"
#endif // __REVISION_NR_H__