mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 19:37:01 +00:00
[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:
parent
028fda6b64
commit
92ce21d009
3 changed files with 43 additions and 44 deletions
|
|
@ -39,18 +39,15 @@
|
||||||
#include "Auth/HMACSHA1.h"
|
#include "Auth/HMACSHA1.h"
|
||||||
#include "zlib/zlib.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
|
// we do not process thread-unsafe packets
|
||||||
if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
|
if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player * plr = m_pSession->GetPlayer();
|
// we do not process not loggined player packets
|
||||||
|
Player * plr = session->GetPlayer();
|
||||||
if (!plr)
|
if (!plr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -58,6 +55,17 @@ bool MapSessionFilter::Process(WorldPacket * packet)
|
||||||
return plr->IsInWorld();
|
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
|
// we should process ALL packets when player is not in world/logged in
|
||||||
// OR packet handler is not thread-safe!
|
// OR packet handler is not thread-safe!
|
||||||
bool WorldSessionFilter::Process(WorldPacket* packet)
|
bool WorldSessionFilter::Process(WorldPacket* packet)
|
||||||
|
|
@ -67,17 +75,8 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
|
||||||
if (opHandle.packetProcessing == PROCESS_INPLACE)
|
if (opHandle.packetProcessing == PROCESS_INPLACE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//thread-unsafe packets should be processed in World::UpdateSessions()
|
// let's check if our opcode can't be processed in Map::Update()
|
||||||
if(opHandle.packetProcessing == PROCESS_THREADUNSAFE)
|
return !MapSessionFilterHelper(m_pSession, opHandle);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WorldSession constructor
|
/// WorldSession constructor
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10849"
|
#define REVISION_NR "10850"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue