mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 07:36:23 +00:00
1st commit
This commit is contained in:
@@ -51,6 +51,10 @@
|
||||
#include "WorldSocket.h"
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
#include "Playerbot.h"
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string const DefaultPlayerName = "<none>";
|
||||
@@ -211,6 +215,20 @@ void WorldSession::SendPacket(WorldPacket const* packet)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
if (Player* player = GetPlayer())
|
||||
{
|
||||
if (PlayerbotAI* playerbotAI = player->GetPlayerbotAI())
|
||||
{
|
||||
playerbotAI->HandleBotOutgoingPacket(*packet);
|
||||
}
|
||||
else if (PlayerbotMgr* playerbotMgr = GetPlayer()->GetPlayerbotMgr())
|
||||
{
|
||||
playerbotMgr->HandleMasterOutgoingPacket(*packet);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!m_Socket)
|
||||
return;
|
||||
|
||||
@@ -287,6 +305,11 @@ void WorldSession::LogUnprocessedTail(WorldPacket* packet)
|
||||
/// Update the WorldSession (triggered by World update)
|
||||
bool WorldSession::Update(uint32 diff, PacketFilter& updater)
|
||||
{
|
||||
#ifdef PLAYERBOTS
|
||||
if (GetPlayer() && GetPlayer()->GetPlayerbotAI())
|
||||
return true;
|
||||
#endif
|
||||
|
||||
///- Before we process anything:
|
||||
/// If necessary, kick the player because the client didn't send anything for too long
|
||||
/// (or they've been idling in character select)
|
||||
@@ -347,6 +370,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
|
||||
|
||||
opHandle->Call(this, *packet);
|
||||
LogUnprocessedTail(packet);
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
if (_player && _player->GetPlayerbotMgr())
|
||||
_player->GetPlayerbotMgr()->HandleMasterIncomingPacket(*packet);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case STATUS_TRANSFER:
|
||||
@@ -457,6 +485,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
|
||||
|
||||
ProcessQueryCallbacks();
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
if (GetPlayer() && GetPlayer()->GetPlayerbotMgr())
|
||||
GetPlayer()->GetPlayerbotMgr()->UpdateSessions(0);
|
||||
#endif
|
||||
|
||||
//check if we are safe to proceed with logout
|
||||
//logout procedure should happen only in World::UpdateSessions() method!!!
|
||||
if (updater.ProcessUnsafe())
|
||||
@@ -613,6 +646,7 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
// there are some positive auras from boss encounters that can be kept by logging out and logging in after boss is dead, and may be used on next bosses
|
||||
_player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CHANGE_MAP);
|
||||
|
||||
#ifndef PLAYERBOTS
|
||||
///- If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.
|
||||
_player->UninviteFromGroup();
|
||||
|
||||
@@ -621,6 +655,7 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && !_player->GetGroup()->isLFGGroup() && m_Socket)
|
||||
_player->RemoveFromGroup();
|
||||
|
||||
#endif
|
||||
// pussywizard: checked second time after being removed from a group
|
||||
if (!_player->IsBeingTeleportedFar() && !_player->m_InstanceValid && !_player->IsGameMaster())
|
||||
_player->RepopAtGraveyard();
|
||||
@@ -1614,3 +1649,17 @@ void WorldSession::SendTimeSync()
|
||||
_timeSyncTimer = _timeSyncNextCounter == 0 ? 5000 : 10000;
|
||||
_timeSyncNextCounter++;
|
||||
}
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
void WorldSession::HandleBotPackets()
|
||||
{
|
||||
WorldPacket* packet;
|
||||
while (_recvQueue.next(packet))
|
||||
{
|
||||
OpcodeClient opcode = static_cast<OpcodeClient>(packet->GetOpcode());
|
||||
ClientOpcodeHandler const* opHandle = opcodeTable[opcode];
|
||||
opHandle->Call(this, *packet);
|
||||
delete packet;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -442,6 +442,11 @@ public:
|
||||
// Time Synchronisation
|
||||
void ResetTimeSync();
|
||||
void SendTimeSync();
|
||||
|
||||
#ifdef PLAYERBOTS
|
||||
void HandleBotPackets();
|
||||
#endif
|
||||
|
||||
public: // opcodes handlers
|
||||
void Handle_NULL(WorldPacket& null); // not used
|
||||
void Handle_EarlyProccess(WorldPacket& recvPacket); // just mark packets processed in WorldSocket::OnRead
|
||||
@@ -984,6 +989,8 @@ public: // opcodes handlers
|
||||
bool GetShouldSetOfflineInDB() const { return _shouldSetOfflineInDB; }
|
||||
bool IsSocketClosed() const;
|
||||
|
||||
void SetAddress(std::string const& address) { m_Address = address; }
|
||||
|
||||
/*
|
||||
* CALLBACKS
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user