本文整理汇总了C++中PacketFilter::ProcessLogout方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketFilter::ProcessLogout方法的具体用法?C++ PacketFilter::ProcessLogout怎么用?C++ PacketFilter::ProcessLogout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketFilter
的用法示例。
在下文中一共展示了PacketFilter::ProcessLogout方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
//.........这里部分代码省略.........
if (sLog->IsOutDebug() && packet->rpos() > packet->wpos())
LogUnprocessedTail(packet);
}
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT:
if (!_player && !m_playerRecentlyLogout)
LogUnexpectedOpcode(packet, "STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT",
"the player has not logged in yet and not recently logout");
else
{
// not expected _player or must checked in packet handler
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*clientServerOpHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() > packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_TRANSFER:
if (!_player)
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
else
{
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*clientServerOpHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() > packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*clientOpHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() > packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog->outError("SESSION (account: %u, guidlow: %u, char: %s): received not allowed opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;
/* NOT USED !!!
case STATUS_UNHANDLED:
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION (account: %u, guidlow: %u, char: %s): received not handled opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;*/
}
}
catch(ByteBufferException &)
{
sLog->outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog->IsOutDebug())
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Dumping error causing packet:");
packet->hexlike();
}
}
}
delete packet;
}
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
time_t currTime = time(NULL);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
if (!m_Socket)
return false; //Will remove this session from the world session map
}
return true;
}
示例2: Update
//.........这里部分代码省略.........
switch (opHandle.status)
{
case STATUS_LOGGEDIN:
if (!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
if (!m_playerRecentlyLogout)
LogUnexpectedOpcode(*packet, "the player has not logged in yet");
}
else if (_player->IsInWorld())
ExecuteOpcode(opHandle, *packet);
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:
if (!_player && !m_playerRecentlyLogout)
{
LogUnexpectedOpcode(*packet, "the player has not logged in yet and not recently logout");
}
else
// not expected _player or must checked in packet hanlder
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_TRANSFER:
if (!_player)
LogUnexpectedOpcode(*packet, "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(*packet, "the player is still in world");
else
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(*packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_NEVER:
sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
}
}
catch (ByteBufferException&)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error causing packet:");
packet->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
}
}
}
// check if we are safe to proceed with logout
// logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
///- If necessary, log the player out
const time_t currTime = time(nullptr);
if (m_Socket->IsClosed() || (ShouldLogOut(currTime) && !m_playerLoading))
LogoutPlayer(true);
// finalize the session if disconnected.
if (m_Socket->IsClosed())
return false;
}
return true;
}
示例3: Update
//.........这里部分代码省略.........
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT:
if (!_player && !m_playerRecentlyLogout)
LogUnexpectedOpcode(packet, "STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT",
"the player has not logged in yet and not recently logout");
else
{
// not expected _player or must checked in packet hanlder
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_TRANSFER:
if (!_player)
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
else
{
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog->outError("SESSION (account: %u, guidlow: %u, char: %s): received not allowed opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;
case STATUS_UNHANDLED:
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION (account: %u, guidlow: %u, char: %s): received not handled opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;
}
}
catch (ByteBufferException &)
{
sLog->outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog->IsOutDebug())
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Dumping error causing packet:");
packet->hexlike();
}
}
if (deletePacket)
delete packet;
}
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
time_t currTime = time(NULL);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
if (!m_Socket)
return false; //Will remove this session from the world session map
}
return true;
}
示例4: Update
//.........这里部分代码省略.........
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
ExecuteOpcode(opHandle, packet);
break;
case STATUS_NEVER:
sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
}
}
catch (ByteBufferException &)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error causing packet:");
packet->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
}
}
delete packet;
}
// Playerbot mod - Process player bot packets
// The PlayerbotAI class adds to the packet queue to simulate a real player
// since Playerbots are known to the World obj only by its master's WorldSession object
// we need to process all master's bot's packets.
if (!sWorld.getConfig(CONFIG_BOOL_PLAYERBOT_DISABLE))
{
if (GetPlayer() && GetPlayer()->GetPlayerbotMgr())
{
for (PlayerBotMap::const_iterator itr = GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsBegin();
itr != GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsEnd(); ++itr)
{
Player* const botPlayer = itr->second;
WorldSession* const pBotWorldSession = botPlayer->GetSession();
if (botPlayer->IsBeingTeleported())
botPlayer->GetPlayerbotAI()->HandleTeleportAck();
else if (botPlayer->IsInWorld())
{
WorldPacket* packet;
while (pBotWorldSession->_recvQueue.next(packet))
{
OpcodeHandler& opHandle = opcodeTable[packet->GetOpcode()];
(pBotWorldSession->*opHandle.handler)(*packet);
delete packet;
}
}
}
}
}
if (m_Socket && !m_Socket->IsClosed() && m_Warden && GetPlayer() && !GetPlayer()->GetPlayerbotAI())
m_Warden->Update();
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if(updater.ProcessLogout())
{
///- If necessary, log the player out
time_t currTime = time(NULL);
if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading))
LogoutPlayer(true);
if (!m_Socket)
return false; //Will remove this session from the world session map
}
return true;
}
示例5: Update
//.........这里部分代码省略.........
#ifdef BUILD_PLAYERBOT
// Process player bot packets
// The PlayerbotAI class adds to the packet queue to simulate a real player
// since Playerbots are known to the World obj only by its master's WorldSession object
// we need to process all master's bot's packets.
if (GetPlayer() && GetPlayer()->GetPlayerbotMgr())
{
for (PlayerBotMap::const_iterator itr = GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsBegin();
itr != GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsEnd(); ++itr)
{
Player* const botPlayer = itr->second;
WorldSession* const pBotWorldSession = botPlayer->GetSession();
if (botPlayer->IsBeingTeleported())
botPlayer->GetPlayerbotAI()->HandleTeleportAck();
else if (botPlayer->IsInWorld())
{
while (!pBotWorldSession->m_recvQueue.empty())
{
auto const botpacket = std::move(pBotWorldSession->m_recvQueue.front());
pBotWorldSession->m_recvQueue.pop_front();
OpcodeHandler const& opHandle = opcodeTable[botpacket->GetOpcode()];
pBotWorldSession->ExecuteOpcode(opHandle, *botpacket);
};
pBotWorldSession->m_recvQueue.clear();
}
}
}
#endif
// check if we are safe to proceed with logout
// logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
switch (m_sessionState)
{
case WORLD_SESSION_STATE_CREATED:
{
if (m_requestSocket)
{
if (!IsOffline())
SetOffline();
m_Socket = m_requestSocket;
m_requestSocket = nullptr;
sLog.outString("New Session key %s", m_Socket->GetSessionKey().AsHexStr());
SendAuthOk();
}
else
{
if (m_inQueue)
SendAuthQueued();
else
SendAuthOk();
}
m_sessionState = WORLD_SESSION_STATE_CHAR_SELECTION;
return true;
}
case WORLD_SESSION_STATE_CHAR_SELECTION:
// waiting to go online
// TODO:: Maybe check if have to send queue update?
if (!m_Socket || (m_Socket && m_Socket->IsClosed()))
{
示例6: Update
//.........这里部分代码省略.........
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
break;
}
// some auth opcodes can be recieved before STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes
// however when we recieve CMSG_CHAR_ENUM we are surely no longer during the logout process.
if (packet->GetOpcode() == CMSG_CHAR_ENUM)
m_playerRecentlyLogout = false;
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle->handler)(*packet);
if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog->outError(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str()
, GetPlayerName(false).c_str());
break;
case STATUS_UNHANDLED:
sLog->outError(LOG_FILTER_OPCODES, "Received not handled opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str()
, GetPlayerName(false).c_str());
break;
}
}
catch(ByteBufferException &)
{
sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
packet->hexlike();
}
nbPacket++;
std::map<uint32, OpcodeInfo>::iterator itr = pktHandle.find(packet->GetOpcode());
if (itr == pktHandle.end())
pktHandle.insert(std::make_pair(packet->GetOpcode(), OpcodeInfo(1, getMSTime() - pktTime)));
else
{
OpcodeInfo& data = (*itr).second;
data.nbPkt += 1;
data.totalTime += getMSTime() - pktTime;
}
if (deletePacket)
delete packet;
#define MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE 500
processedPackets++;
//process only a max amout of packets in 1 Update() call.
//Any leftover will be processed in next update
if (processedPackets > MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE)
break;
}
if (m_Socket && !m_Socket->IsClosed() && _warden)
_warden->Update();
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
time_t currTime = time(NULL);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
if (m_Socket && GetPlayer() && _warden)
_warden->Update();
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
if (!m_Socket)
return false; //Will remove this session from the world session map
}
sessionDiff = getMSTime() - sessionDiff;
if (sessionDiff > 50)
{
sLog->OutPandashan("Session of account [%u] take more than 50 ms to execute (%u ms)", GetAccountId(), sessionDiff);
for (auto itr : pktHandle)
sLog->OutPandashan("-----> %u %s (%u ms)", itr.second.nbPkt, GetOpcodeNameForLogging((Opcodes)itr.first).c_str(), itr.second.totalTime);
}
return true;
}
示例7: Update
//.........这里部分代码省略.........
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
else
{
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle.handler)(*packet);
if (sLog->IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog->outError("SESSION (account: %u, guidlow: %u, char: %s): received not allowed opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;
case STATUS_UNHANDLED:
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION (account: %u, guidlow: %u, char: %s): received not handled opcode %s (0x%.4X)",
GetAccountId(), m_GUIDLow, _player ? _player->GetName() : "<none>",
LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode());
break;
}
}
catch(ByteBufferException &)
{
sLog->outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog->IsOutDebug())
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Dumping error causing packet:");
packet->hexlike();
}
}
}
delete packet;
}
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
time_t currTime = time(NULL);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
//Playerbot mod - Process player bot packets
//The PlayerbotAI class adds to the packet queue to simulate a real player
//since Playerbots are known to the World obj only its master's
//WorldSession object we need to process all master's bot's packets.
for(PlayerBotMap::const_iterator itr = GetPlayerBotsBegin(); itr != GetPlayerBotsEnd(); ++itr)
{
Player *const botPlayer = itr->second;
WorldSession *const pBotWorldSession = botPlayer->GetSession();
if(botPlayer->IsBeingTeleportedFar())
{
pBotWorldSession->HandleMoveWorldportAckOpcode();
} else if(botPlayer->IsInWorld())
{
WorldPacket *packet;
while(pBotWorldSession->_recvQueue.next(packet))
{
OpcodeHandler &opHandle = opcodeTable[packet->GetOpcode()];
(pBotWorldSession->*opHandle.handler)(*packet);
delete packet;
}
}
}
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
if (!m_Socket)
return false; //Will remove this session from the world session map
}
return true;
}
示例8: Update
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(uint32 diff, PacketFilter& updater)
{
if (updater.ProcessLogout())
{
UpdateTimeOutTime(diff);
if (IsConnectionIdle())
m_Socket->CloseSocket();
}
HandleTeleportTimeout(updater.ProcessLogout());
uint32 _startMSTime = getMSTime();
WorldPacket* packet = NULL;
WorldPacket* movementPacket = NULL;
bool deletePacket = true;
WorldPacket* firstDelayedPacket = NULL;
uint32 processedPackets = 0;
while (m_Socket && !m_Socket->IsClosed() && !_recvQueue.empty() && _recvQueue.peek(true) != firstDelayedPacket && _recvQueue.next(packet, updater))
{
if (packet->GetOpcode() < NUM_MSG_TYPES)
{
OpcodeHandler &opHandle = opcodeTable[packet->GetOpcode()];
try
{
switch (opHandle.status)
{
case STATUS_LOGGEDIN:
if (!_player)
{
// pussywizard: such packets were sent to do something for a character that has already logged out, skip them
}
else if (!_player->IsInWorld())
{
// pussywizard: such packets may do something important and the player is just being teleported, move to the end of the queue
// pussywizard: previously such were skipped, so leave it as it is xD proper code below if we wish to change that
// pussywizard: requeue only important packets not related to maps (PROCESS_THREADUNSAFE)
/*if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
{
if (!firstDelayedPacket)
firstDelayedPacket = packet;
deletePacket = false;
QueuePacket(packet);
}*/
}
else
{
if (opHandle.isGrouppedMovementOpcode)
{
if (movementPacket)
delete movementPacket;
movementPacket = new WorldPacket(packet->GetOpcode(), 0);
movementPacket->append(*((ByteBuffer*)packet));
}
else
{
if (movementPacket)
{
HandleMovementOpcodes(*movementPacket);
delete movementPacket;
movementPacket = NULL;
}
sScriptMgr->OnPacketReceive(this, *packet);
#ifdef ELUNA
if (!sEluna->OnPacketReceive(this, *packet))
break;
#endif
(this->*opHandle.handler)(*packet);
}
}
break;
case STATUS_TRANSFER:
if (_player && !_player->IsInWorld())
{
if (movementPacket)
{
delete movementPacket;
movementPacket = NULL;
}
sScriptMgr->OnPacketReceive(this, *packet);
#ifdef ELUNA
if (!sEluna->OnPacketReceive(this, *packet))
break;
#endif
(this->*opHandle.handler)(*packet);
}
break;
case STATUS_AUTHED:
if (m_inQueue) // prevent cheating
break;
sScriptMgr->OnPacketReceive(this, *packet);
#ifdef ELUNA
if (!sEluna->OnPacketReceive(this, *packet))
break;
#endif
(this->*opHandle.handler)(*packet);
break;
//.........这里部分代码省略.........
示例9: Update
//.........这里部分代码省略.........
else
// not expected _player or must checked in packet hanlder
{ ExecuteOpcode(opHandle, packet); }
break;
case STATUS_TRANSFER:
if (!_player)
{ LogUnexpectedOpcode(packet, "the player has not logged in yet"); }
else if (_player->IsInWorld())
{ LogUnexpectedOpcode(packet, "the player is still in world"); }
else
{ ExecuteOpcode(opHandle, packet); }
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
m_playerRecentlyLogout = false;
ExecuteOpcode(opHandle, packet);
break;
case STATUS_NEVER:
sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
}
}
catch (ByteBufferException&)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error causing packet:");
packet->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
}
}
delete packet;
}
#ifdef ENABLE_PLAYERBOTS
if (GetPlayer() && GetPlayer()->GetPlayerbotMgr())
GetPlayer()->GetPlayerbotMgr()->UpdateSessions(0);
#endif
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
// Warden
if (m_Socket && !m_Socket->IsClosed() && _warden)
_warden->Update();
// check if we are safe to proceed with logout
// logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
///- If necessary, log the player out
time_t currTime = time(NULL);
if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading))
{ LogoutPlayer(true); }
// Warden
if (m_Socket && GetPlayer() && _warden)
_warden->Update();
if (!m_Socket)
{ return false; } // Will remove this session from the world session map
}
return true;
}