mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/PacketIO: Updated and enabled battlefield opcodes
This commit is contained in:
@@ -106,7 +106,7 @@ void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
|
||||
if (m_PlayersInWar[player->GetTeamId()].find(player->GetGUID()) != m_PlayersInWar[player->GetTeamId()].end())
|
||||
{
|
||||
m_PlayersInWar[player->GetTeamId()].erase(player->GetGUID());
|
||||
player->GetSession()->SendBfLeaveMessage(m_Guid);
|
||||
player->GetSession()->SendBfLeaveMessage(GetQueueId(), GetState(), player->GetZoneId() == GetZoneId());
|
||||
if (Group* group = player->GetGroup()) // Remove the player from the raid group
|
||||
group->RemoveMember(player->GetGUID());
|
||||
|
||||
@@ -210,7 +210,7 @@ void Battlefield::InvitePlayerToQueue(Player* player)
|
||||
return;
|
||||
|
||||
if (m_PlayersInQueue[player->GetTeamId()].size() <= m_MinPlayer || m_PlayersInQueue[GetOtherTeam(player->GetTeamId())].size() >= m_MinPlayer)
|
||||
player->GetSession()->SendBfInvitePlayerToQueue(m_Guid);
|
||||
player->GetSession()->SendBfInvitePlayerToQueue(GetQueueId(), GetState());
|
||||
}
|
||||
|
||||
void Battlefield::InvitePlayersInQueueToWar()
|
||||
@@ -279,7 +279,7 @@ void Battlefield::InvitePlayerToWar(Player* player)
|
||||
|
||||
m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
|
||||
m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = time(NULL) + m_TimeForAcceptInvite;
|
||||
player->GetSession()->SendBfInvitePlayerToWar(m_Guid, m_ZoneId, m_TimeForAcceptInvite);
|
||||
player->GetSession()->SendBfInvitePlayerToWar(GetQueueId(), m_ZoneId, m_TimeForAcceptInvite);
|
||||
}
|
||||
|
||||
void Battlefield::InitStalker(uint32 entry, Position const& pos)
|
||||
@@ -361,7 +361,7 @@ void Battlefield::PlayerAcceptInviteToQueue(Player* player)
|
||||
// Add player in queue
|
||||
m_PlayersInQueue[player->GetTeamId()].insert(player->GetGUID());
|
||||
// Send notification
|
||||
player->GetSession()->SendBfQueueInviteResponse(m_Guid, m_ZoneId);
|
||||
player->GetSession()->SendBfQueueInviteResponse(GetQueueId(), m_ZoneId, GetState());
|
||||
}
|
||||
|
||||
// Called in WorldSession::HandleBfExitRequest
|
||||
@@ -379,7 +379,7 @@ void Battlefield::PlayerAcceptInviteToWar(Player* player)
|
||||
|
||||
if (AddOrSetPlayerToCorrectBfGroup(player))
|
||||
{
|
||||
player->GetSession()->SendBfEntered(m_Guid);
|
||||
player->GetSession()->SendBfEntered(GetQueueId(), player->GetZoneId() != GetZoneId(), player->GetTeamId() == GetAttackerTeam());
|
||||
m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID());
|
||||
m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
|
||||
|
||||
|
||||
@@ -30,7 +30,16 @@ enum BattlefieldTypes
|
||||
|
||||
enum BattlefieldIDs
|
||||
{
|
||||
BATTLEFIELD_BATTLEID_WG = 1 // Wintergrasp battle
|
||||
BATTLEFIELD_BATTLEID_WG = 1, // Wintergrasp battle
|
||||
BATTLEFIELD_BATTLEID_TB = 21, // Tol Barad
|
||||
BATTLEFIELD_BATTLEID_ASHRAN = 24 // Ashran
|
||||
};
|
||||
|
||||
enum BattlefieldState
|
||||
{
|
||||
BATTLEFIELD_INACTIVE = 0,
|
||||
BATTLEFIELD_WARMUP = 1,
|
||||
BATTLEFIELD_IN_PROGRESS = 2
|
||||
};
|
||||
|
||||
enum BattlefieldObjectiveStates
|
||||
@@ -224,13 +233,15 @@ class Battlefield : public ZoneScript
|
||||
|
||||
uint32 GetTypeId() const { return m_TypeId; }
|
||||
uint32 GetZoneId() const { return m_ZoneId; }
|
||||
ObjectGuid GetGUID() const { return m_Guid; }
|
||||
uint64 GetQueueId() const { return MAKE_PAIR64(m_BattleId | 0x20000, 0x1F100000); }
|
||||
|
||||
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
|
||||
|
||||
/// Return true if battle is start, false if battle is not started
|
||||
bool IsWarTime() const { return m_isActive; }
|
||||
|
||||
int8 GetState() const { return m_isActive ? BATTLEFIELD_IN_PROGRESS : (m_Timer <= m_StartGroupingTimer ? BATTLEFIELD_WARMUP : BATTLEFIELD_INACTIVE); }
|
||||
|
||||
/// Enable or Disable battlefield
|
||||
void ToggleBattlefield(bool enable) { m_IsEnabled = enable; }
|
||||
/// Return if battlefield is enable
|
||||
@@ -344,8 +355,6 @@ class Battlefield : public ZoneScript
|
||||
void InitStalker(uint32 entry, Position const& pos);
|
||||
|
||||
protected:
|
||||
ObjectGuid m_Guid;
|
||||
|
||||
ObjectGuid StalkerGuid;
|
||||
uint32 m_Timer; // Global timer for event
|
||||
bool m_IsEnabled;
|
||||
|
||||
@@ -122,11 +122,11 @@ Battlefield* BattlefieldMgr::GetBattlefieldByBattleId(uint32 battleId)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Battlefield* BattlefieldMgr::GetBattlefieldByGUID(ObjectGuid guid)
|
||||
Battlefield* BattlefieldMgr::GetBattlefieldByQueueId(uint64 queueId)
|
||||
{
|
||||
for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
|
||||
if ((*itr)->GetGUID() == guid)
|
||||
return *itr;
|
||||
for (Battlefield* bf : _battlefieldSet)
|
||||
if (bf->GetQueueId() == queueId)
|
||||
return bf;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class BattlefieldMgr
|
||||
// return assigned battlefield
|
||||
Battlefield* GetBattlefieldToZoneId(uint32 zoneId);
|
||||
Battlefield* GetBattlefieldByBattleId(uint32 battleId);
|
||||
Battlefield* GetBattlefieldByGUID(ObjectGuid guid);
|
||||
Battlefield* GetBattlefieldByQueueId(uint64 queueId);
|
||||
|
||||
ZoneScript* GetZoneScript(uint32 zoneId);
|
||||
|
||||
|
||||
@@ -25,290 +25,115 @@
|
||||
|
||||
#include "Battlefield.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "BattlefieldPackets.h"
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::SendBfInvitePlayerToWar(ObjectGuid guid, uint32 zoneId, uint32 acceptTime)
|
||||
* @fn void WorldSession::SendBfInvitePlayerToWar(uint64 queueId, uint32 zoneId, uint32 acceptTime)
|
||||
*
|
||||
* @brief This send to player windows for invite player to join the war.
|
||||
*
|
||||
* @param guid The guid of Bf
|
||||
* @param queueId The queue id of Bf
|
||||
* @param zoneId The zone where the battle is (4197 for wg)
|
||||
* @param acceptTime Time in second that the player have for accept
|
||||
*/
|
||||
void WorldSession::SendBfInvitePlayerToWar(ObjectGuid guid, uint32 zoneId, uint32 acceptTime)
|
||||
void WorldSession::SendBfInvitePlayerToWar(uint64 queueId, uint32 zoneId, uint32 acceptTime)
|
||||
{
|
||||
WorldPacket data(SMSG_BF_MGR_ENTRY_INVITE, 16);
|
||||
|
||||
data.WriteBit(guid[5]);
|
||||
data.WriteBit(guid[3]);
|
||||
data.WriteBit(guid[7]);
|
||||
data.WriteBit(guid[2]);
|
||||
data.WriteBit(guid[6]);
|
||||
data.WriteBit(guid[4]);
|
||||
data.WriteBit(guid[1]);
|
||||
data.WriteBit(guid[0]);
|
||||
|
||||
data.WriteByteSeq(guid[6]);
|
||||
data << uint32(zoneId); // Zone Id
|
||||
data.WriteByteSeq(guid[1]);
|
||||
data.WriteByteSeq(guid[3]);
|
||||
data.WriteByteSeq(guid[4]);
|
||||
data.WriteByteSeq(guid[2]);
|
||||
data.WriteByteSeq(guid[0]);
|
||||
data << uint32(time(NULL) + acceptTime); // Invite lasts until
|
||||
data.WriteByteSeq(guid[7]);
|
||||
data.WriteByteSeq(guid[5]);
|
||||
SendPacket(&data);
|
||||
WorldPackets::Battlefield::BFMgrEntryInvite bfMgrEntryInvite;
|
||||
bfMgrEntryInvite.QueueID = queueId;
|
||||
bfMgrEntryInvite.AreaID = zoneId;
|
||||
bfMgrEntryInvite.ExpireTime = time(nullptr) + acceptTime;
|
||||
SendPacket(bfMgrEntryInvite.Write());
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::SendBfInvitePlayerToQueue(ObjectGuid guid)
|
||||
* @fn void WorldSession::SendBfInvitePlayerToQueue(uint64 queueId, int8 battleState)
|
||||
*
|
||||
* @brief This send invitation to player to join the queue.
|
||||
*
|
||||
* @param guid The guid of Bf
|
||||
* @param queueId The queue id of Bf
|
||||
*/
|
||||
void WorldSession::SendBfInvitePlayerToQueue(ObjectGuid guid)
|
||||
void WorldSession::SendBfInvitePlayerToQueue(uint64 queueId, int8 battleState)
|
||||
{
|
||||
WorldPacket data(SMSG_BF_MGR_QUEUE_INVITE, 5);
|
||||
|
||||
data.WriteBit(1); // unk
|
||||
data.WriteBit(0); // Has Warmup
|
||||
data.WriteBit(1); // unk
|
||||
data.WriteBit(guid[0]);
|
||||
data.WriteBit(1); // unk
|
||||
data.WriteBit(guid[2]);
|
||||
data.WriteBit(guid[6]);
|
||||
data.WriteBit(guid[3]);
|
||||
data.WriteBit(1); // unk
|
||||
data.WriteBit(0); // unk
|
||||
data.WriteBit(guid[1]);
|
||||
data.WriteBit(guid[5]);
|
||||
data.WriteBit(guid[4]);
|
||||
data.WriteBit(1); // unk
|
||||
data.WriteBit(guid[7]);
|
||||
|
||||
data.FlushBits();
|
||||
|
||||
data.WriteByteSeq(guid[2]);
|
||||
data.WriteByteSeq(guid[3]);
|
||||
data.WriteByteSeq(guid[6]);
|
||||
data << uint8(1); // Warmup
|
||||
data.WriteByteSeq(guid[5]);
|
||||
data.WriteByteSeq(guid[0]);
|
||||
data.WriteByteSeq(guid[4]);
|
||||
data.WriteByteSeq(guid[1]);
|
||||
data.WriteByteSeq(guid[7]);
|
||||
SendPacket(&data);
|
||||
WorldPackets::Battlefield::BFMgrQueueInvite bfMgrQueueInvite;
|
||||
bfMgrQueueInvite.QueueID = queueId;
|
||||
bfMgrQueueInvite.BattleState = battleState;
|
||||
SendPacket(bfMgrQueueInvite.Write());
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::SendBfQueueInviteResponse(ObjectGuid guid, uint32 zoneId, bool canQueue, bool full)
|
||||
* @fn void WorldSession::SendBfQueueInviteResponse(uint64 queueId, uint32 zoneId, int8 battleStatus, bool canQueue, bool loggingIn)
|
||||
*
|
||||
* @brief This send packet for inform player that he join queue.
|
||||
*
|
||||
* @param guid The guid of Bf
|
||||
* @param queueId The queue id of Bf
|
||||
* @param zoneId The zone where the battle is (4197 for wg)
|
||||
* @param battleStatus Battlefield status
|
||||
* @param canQueue if able to queue
|
||||
* @param full on log in is full
|
||||
* @param loggingIn on log in send queue status
|
||||
*/
|
||||
void WorldSession::SendBfQueueInviteResponse(ObjectGuid guid, uint32 zoneId, bool canQueue, bool full)
|
||||
void WorldSession::SendBfQueueInviteResponse(uint64 queueId, uint32 zoneId, int8 battleStatus, bool canQueue /*= true*/, bool loggingIn /*= false*/)
|
||||
{
|
||||
const bool hasSecondGuid = false;
|
||||
const bool warmup = true;
|
||||
|
||||
WorldPacket data(SMSG_BF_MGR_QUEUE_REQUEST_RESPONSE, 16);
|
||||
|
||||
data.WriteBit(guid[1]);
|
||||
data.WriteBit(guid[6]);
|
||||
data.WriteBit(guid[5]);
|
||||
data.WriteBit(guid[7]);
|
||||
data.WriteBit(full); // Logging In, VERIFYME
|
||||
data.WriteBit(guid[0]);
|
||||
data.WriteBit(!hasSecondGuid);
|
||||
data.WriteBit(guid[4]);
|
||||
|
||||
// if (hasSecondGuid) 7 3 0 4 2 6 1 5
|
||||
|
||||
data.WriteBit(guid[3]);
|
||||
data.WriteBit(guid[2]);
|
||||
|
||||
// if (hasSecondGuid) 2 5 3 0 4 6 1 7
|
||||
|
||||
data.FlushBits();
|
||||
|
||||
data << uint8(canQueue); // Accepted
|
||||
|
||||
data.WriteByteSeq(guid[1]);
|
||||
data.WriteByteSeq(guid[3]);
|
||||
data.WriteByteSeq(guid[6]);
|
||||
data.WriteByteSeq(guid[7]);
|
||||
data.WriteByteSeq(guid[0]);
|
||||
|
||||
data << uint8(warmup);
|
||||
|
||||
data.WriteByteSeq(guid[2]);
|
||||
data.WriteByteSeq(guid[4]);
|
||||
data.WriteByteSeq(guid[5]);
|
||||
|
||||
data << uint32(zoneId);
|
||||
|
||||
SendPacket(&data);
|
||||
WorldPackets::Battlefield::BFMgrQueueRequestResponse bfMgrQueueRequestResponse;
|
||||
bfMgrQueueRequestResponse.QueueID = queueId;
|
||||
bfMgrQueueRequestResponse.AreaID = zoneId;
|
||||
bfMgrQueueRequestResponse.Result = canQueue ? 1 : 0;
|
||||
bfMgrQueueRequestResponse.BattleState = battleStatus;
|
||||
bfMgrQueueRequestResponse.LoggingIn = loggingIn;
|
||||
SendPacket(bfMgrQueueRequestResponse.Write());
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::SendBfEntered(ObjectGuid guid)
|
||||
* @fn void WorldSession::SendBfEntered(uint64 queueId, bool relocated, bool onOffense)
|
||||
*
|
||||
* @brief This is call when player accept to join war.
|
||||
*
|
||||
* @param guid The guid of Bf
|
||||
* @param queueId The queue id of Bf
|
||||
* @param relocated Whether player is added to Bf on the spot or teleported from queue
|
||||
* @param onOffense Whether player belongs to attacking team or not
|
||||
*/
|
||||
void WorldSession::SendBfEntered(ObjectGuid guid)
|
||||
void WorldSession::SendBfEntered(uint64 queueId, bool relocated, bool onOffense)
|
||||
{
|
||||
uint8 isAFK = _player->isAFK() ? 1 : 0;
|
||||
|
||||
WorldPacket data(SMSG_BF_MGR_ENTERING, 11);
|
||||
|
||||
data.WriteBit(0); // unk
|
||||
data.WriteBit(isAFK); // Clear AFK
|
||||
data.WriteBit(guid[1]);
|
||||
data.WriteBit(guid[4]);
|
||||
data.WriteBit(guid[5]);
|
||||
data.WriteBit(guid[0]);
|
||||
data.WriteBit(guid[3]);
|
||||
data.WriteBit(0); // unk
|
||||
data.WriteBit(guid[6]);
|
||||
data.WriteBit(guid[7]);
|
||||
data.WriteBit(guid[2]);
|
||||
|
||||
data.FlushBits();
|
||||
|
||||
data.WriteByteSeq(guid[5]);
|
||||
data.WriteByteSeq(guid[3]);
|
||||
data.WriteByteSeq(guid[0]);
|
||||
data.WriteByteSeq(guid[4]);
|
||||
data.WriteByteSeq(guid[1]);
|
||||
data.WriteByteSeq(guid[7]);
|
||||
data.WriteByteSeq(guid[2]);
|
||||
data.WriteByteSeq(guid[6]);
|
||||
|
||||
SendPacket(&data);
|
||||
WorldPackets::Battlefield::BFMgrEntering bfMgrEntering;
|
||||
bfMgrEntering.ClearedAFK = _player->isAFK();
|
||||
bfMgrEntering.Relocated = relocated;
|
||||
bfMgrEntering.OnOffense = onOffense;
|
||||
bfMgrEntering.QueueID = queueId;
|
||||
SendPacket(bfMgrEntering.Write());
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::SendBfLeaveMessage(ObjectGuid guid, BFLeaveReason reason)
|
||||
* @fn void WorldSession::SendBfLeaveMessage(uint64 queueId, int8 battleState, bool relocated, BFLeaveReason reason)
|
||||
*
|
||||
* @brief This is call when player leave battlefield zone.
|
||||
*
|
||||
* @param guid The guid of Bf
|
||||
* @param queueId The queue id of Bf
|
||||
* @param battleState Battlefield status
|
||||
* @param relocated Whether player is added to Bf on the spot or teleported from queue
|
||||
* @param reason Reason why player left battlefield
|
||||
*/
|
||||
void WorldSession::SendBfLeaveMessage(ObjectGuid guid, BFLeaveReason reason /*= BF_LEAVE_REASON_EXITED*/)
|
||||
void WorldSession::SendBfLeaveMessage(uint64 queueId, int8 battleState, bool relocated, BFLeaveReason reason /*= BF_LEAVE_REASON_EXITED*/)
|
||||
{
|
||||
WorldPacket data(SMSG_BF_MGR_EJECTED, 11);
|
||||
|
||||
data.WriteBit(guid[2]);
|
||||
data.WriteBit(guid[5]);
|
||||
data.WriteBit(guid[1]);
|
||||
data.WriteBit(guid[0]);
|
||||
data.WriteBit(guid[3]);
|
||||
data.WriteBit(guid[6]);
|
||||
data.WriteBit(0); // Relocated
|
||||
data.WriteBit(guid[7]);
|
||||
data.WriteBit(guid[4]);
|
||||
|
||||
data.FlushBits();
|
||||
|
||||
data << uint8(2); // BattleStatus
|
||||
data.WriteByteSeq(guid[1]);
|
||||
data.WriteByteSeq(guid[7]);
|
||||
data.WriteByteSeq(guid[4]);
|
||||
data.WriteByteSeq(guid[2]);
|
||||
data.WriteByteSeq(guid[3]);
|
||||
data << uint8(reason); // Reason
|
||||
data.WriteByteSeq(guid[6]);
|
||||
data.WriteByteSeq(guid[0]);
|
||||
data.WriteByteSeq(guid[5]);
|
||||
|
||||
SendPacket(&data);
|
||||
WorldPackets::Battlefield::BFMgrEjected bfMgrEjected;
|
||||
bfMgrEjected.QueueID = queueId;
|
||||
bfMgrEjected.Reason = reason;
|
||||
bfMgrEjected.BattleState = battleState;
|
||||
bfMgrEjected.Relocated = relocated;
|
||||
SendPacket(bfMgrEjected.Write());
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::HandleBfQueueInviteResponse(WorldPacket& recvData)
|
||||
*
|
||||
* @brief Send by client when he click on accept for queue.
|
||||
*/
|
||||
void WorldSession::HandleBfQueueInviteResponse(WorldPacket& recvData)
|
||||
{
|
||||
uint8 accepted;
|
||||
ObjectGuid guid;
|
||||
|
||||
guid[2] = recvData.ReadBit();
|
||||
guid[0] = recvData.ReadBit();
|
||||
guid[4] = recvData.ReadBit();
|
||||
guid[3] = recvData.ReadBit();
|
||||
guid[5] = recvData.ReadBit();
|
||||
guid[7] = recvData.ReadBit();
|
||||
accepted = recvData.ReadBit();
|
||||
guid[1] = recvData.ReadBit();
|
||||
guid[6] = recvData.ReadBit();
|
||||
|
||||
recvData.ReadByteSeq(guid[1]);
|
||||
recvData.ReadByteSeq(guid[3]);
|
||||
recvData.ReadByteSeq(guid[2]);
|
||||
recvData.ReadByteSeq(guid[4]);
|
||||
recvData.ReadByteSeq(guid[6]);
|
||||
recvData.ReadByteSeq(guid[7]);
|
||||
recvData.ReadByteSeq(guid[0]);
|
||||
recvData.ReadByteSeq(guid[5]);
|
||||
|
||||
TC_LOG_ERROR("misc", "HandleQueueInviteResponse: %s, accepted: %u", guid.ToString().c_str(), accepted);
|
||||
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByGUID(guid);
|
||||
if (!bf)
|
||||
return;
|
||||
|
||||
if (accepted)
|
||||
bf->PlayerAcceptInviteToQueue(_player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData)
|
||||
* @fn void WorldSession::HandleBfEntryInviteResponse(WorldPackets::Battlefield::BFMgrEntryInviteResponse& bfMgrEntryInviteResponse)
|
||||
*
|
||||
* @brief Send by client on clicking in accept or refuse of invitation windows for join game.
|
||||
*/
|
||||
void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData)
|
||||
void WorldSession::HandleBfEntryInviteResponse(WorldPackets::Battlefield::BFMgrEntryInviteResponse& bfMgrEntryInviteResponse)
|
||||
{
|
||||
uint8 accepted;
|
||||
ObjectGuid guid;
|
||||
|
||||
guid[6] = recvData.ReadBit();
|
||||
guid[1] = recvData.ReadBit();
|
||||
accepted = recvData.ReadBit();
|
||||
guid[5] = recvData.ReadBit();
|
||||
guid[3] = recvData.ReadBit();
|
||||
guid[2] = recvData.ReadBit();
|
||||
guid[0] = recvData.ReadBit();
|
||||
guid[7] = recvData.ReadBit();
|
||||
guid[4] = recvData.ReadBit();
|
||||
|
||||
recvData.ReadByteSeq(guid[0]);
|
||||
recvData.ReadByteSeq(guid[3]);
|
||||
recvData.ReadByteSeq(guid[4]);
|
||||
recvData.ReadByteSeq(guid[2]);
|
||||
recvData.ReadByteSeq(guid[1]);
|
||||
recvData.ReadByteSeq(guid[6]);
|
||||
recvData.ReadByteSeq(guid[7]);
|
||||
recvData.ReadByteSeq(guid[5]);
|
||||
|
||||
TC_LOG_ERROR("misc", "HandleBattlefieldInviteResponse: GUID: %s, accepted: %u", guid.ToString().c_str(), accepted);
|
||||
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByGUID(guid);
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByQueueId(bfMgrEntryInviteResponse.QueueID);
|
||||
if (!bf)
|
||||
return;
|
||||
|
||||
// If player accept invitation
|
||||
if (accepted)
|
||||
if (bfMgrEntryInviteResponse.AcceptedInvite)
|
||||
{
|
||||
bf->PlayerAcceptInviteToWar(_player);
|
||||
}
|
||||
@@ -320,35 +145,28 @@ void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::HandleBfExitRequest(WorldPacket& recvData)
|
||||
* @fn void WorldSession::HandleBfQueueInviteResponse(WorldPackets::Battlefield::BFMgrQueueInviteResponse& bfMgrQueueInviteResponse)
|
||||
*
|
||||
* @brief Send by client when he click on accept for queue.
|
||||
*/
|
||||
void WorldSession::HandleBfQueueInviteResponse(WorldPackets::Battlefield::BFMgrQueueInviteResponse& bfMgrQueueInviteResponse)
|
||||
{
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByQueueId(bfMgrQueueInviteResponse.QueueID);
|
||||
if (!bf)
|
||||
return;
|
||||
|
||||
if (bfMgrQueueInviteResponse.AcceptedInvite)
|
||||
bf->PlayerAcceptInviteToQueue(_player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn void WorldSession::HandleBfExitRequest(WorldPackets::Battlefield::BFMgrQueueExitRequest& bfMgrQueueExitRequest)
|
||||
*
|
||||
* @brief Send by client when exited battlefield
|
||||
*/
|
||||
void WorldSession::HandleBfExitRequest(WorldPacket& recvData)
|
||||
void WorldSession::HandleBfQueueExitRequest(WorldPackets::Battlefield::BFMgrQueueExitRequest& bfMgrQueueExitRequest)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
|
||||
guid[2] = recvData.ReadBit();
|
||||
guid[0] = recvData.ReadBit();
|
||||
guid[3] = recvData.ReadBit();
|
||||
guid[7] = recvData.ReadBit();
|
||||
guid[4] = recvData.ReadBit();
|
||||
guid[5] = recvData.ReadBit();
|
||||
guid[6] = recvData.ReadBit();
|
||||
guid[1] = recvData.ReadBit();
|
||||
|
||||
recvData.ReadByteSeq(guid[5]);
|
||||
recvData.ReadByteSeq(guid[2]);
|
||||
recvData.ReadByteSeq(guid[0]);
|
||||
recvData.ReadByteSeq(guid[1]);
|
||||
recvData.ReadByteSeq(guid[4]);
|
||||
recvData.ReadByteSeq(guid[3]);
|
||||
recvData.ReadByteSeq(guid[7]);
|
||||
recvData.ReadByteSeq(guid[6]);
|
||||
|
||||
TC_LOG_ERROR("misc", "HandleBfExitRequest: GUID: %s", guid.ToString().c_str());
|
||||
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByGUID(guid);
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByQueueId(bfMgrQueueExitRequest.QueueID);
|
||||
if (!bf)
|
||||
return;
|
||||
|
||||
|
||||
87
src/server/game/Server/Packets/BattlefieldPackets.cpp
Normal file
87
src/server/game/Server/Packets/BattlefieldPackets.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "BattlefieldPackets.h"
|
||||
|
||||
WorldPacket const* WorldPackets::Battlefield::BFMgrEntryInvite::Write()
|
||||
{
|
||||
_worldPacket << uint64(QueueID);
|
||||
_worldPacket << uint32(AreaID);
|
||||
_worldPacket << uint32(ExpireTime);
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
void WorldPackets::Battlefield::BFMgrEntryInviteResponse::Read()
|
||||
{
|
||||
_worldPacket >> QueueID;
|
||||
AcceptedInvite = _worldPacket.ReadBit();
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Battlefield::BFMgrQueueInvite::Write()
|
||||
{
|
||||
_worldPacket << uint64(QueueID);
|
||||
_worldPacket << int8(BattleState);
|
||||
_worldPacket << uint32(Timeout);
|
||||
_worldPacket << int32(MinLevel);
|
||||
_worldPacket << int32(MaxLevel);
|
||||
_worldPacket << int32(MapID);
|
||||
_worldPacket << uint32(InstanceID);
|
||||
_worldPacket.WriteBit(Index);
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
void WorldPackets::Battlefield::BFMgrQueueInviteResponse::Read()
|
||||
{
|
||||
_worldPacket >> QueueID;
|
||||
AcceptedInvite = _worldPacket.ReadBit();
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Battlefield::BFMgrQueueRequestResponse::Write()
|
||||
{
|
||||
_worldPacket << uint64(QueueID);
|
||||
_worldPacket << int32(AreaID);
|
||||
_worldPacket << int8(Result);
|
||||
_worldPacket << FailedPlayerGUID;
|
||||
_worldPacket << int8(BattleState);
|
||||
_worldPacket.WriteBit(LoggingIn);
|
||||
_worldPacket.FlushBits();
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
void WorldPackets::Battlefield::BFMgrQueueExitRequest::Read()
|
||||
{
|
||||
_worldPacket >> QueueID;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Battlefield::BFMgrEntering::Write()
|
||||
{
|
||||
_worldPacket.WriteBit(ClearedAFK);
|
||||
_worldPacket.WriteBit(Relocated);
|
||||
_worldPacket.WriteBit(OnOffense);
|
||||
_worldPacket << uint64(QueueID);
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Battlefield::BFMgrEjected::Write()
|
||||
{
|
||||
_worldPacket << uint64(QueueID);
|
||||
_worldPacket << int8(Reason);
|
||||
_worldPacket << int8(BattleState);
|
||||
_worldPacket.WriteBit(Relocated);
|
||||
_worldPacket.FlushBits();
|
||||
return &_worldPacket;
|
||||
}
|
||||
132
src/server/game/Server/Packets/BattlefieldPackets.h
Normal file
132
src/server/game/Server/Packets/BattlefieldPackets.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BattlefieldPackets_h__
|
||||
#define BattlefieldPackets_h__
|
||||
|
||||
#include "Packet.h"
|
||||
#include "ObjectGuid.h"
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Battlefield
|
||||
{
|
||||
class BFMgrEntryInvite final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
BFMgrEntryInvite() : ServerPacket(SMSG_BF_MGR_ENTRY_INVITE, 8 + 4 + 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint64 QueueID = 0;
|
||||
int32 AreaID = 0;
|
||||
time_t ExpireTime = time_t(0);
|
||||
};
|
||||
|
||||
class BFMgrEntryInviteResponse final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BFMgrEntryInviteResponse(WorldPacket&& packet) : ClientPacket(CMSG_BF_MGR_ENTRY_INVITE_RESPONSE, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint64 QueueID = 0;
|
||||
bool AcceptedInvite = false;
|
||||
};
|
||||
|
||||
class BFMgrQueueInvite final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
BFMgrQueueInvite() : ServerPacket(SMSG_BF_MGR_QUEUE_INVITE, 8 + 4 + 4 + 4 + 4 + 4 + 1 + 1) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint64 QueueID = 0;
|
||||
int8 BattleState = 0;
|
||||
uint32 Timeout = std::numeric_limits<uint32>::max(); // unused in client
|
||||
int32 MinLevel = 0; // unused in client
|
||||
int32 MaxLevel = 0; // unused in client
|
||||
int32 MapID = 0; // unused in client
|
||||
uint32 InstanceID = 0; // unused in client
|
||||
int8 Index = 0; // unused in client
|
||||
};
|
||||
|
||||
class BFMgrQueueInviteResponse final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BFMgrQueueInviteResponse(WorldPacket&& packet) : ClientPacket(CMSG_BF_MGR_QUEUE_INVITE_RESPONSE, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint64 QueueID = 0;
|
||||
bool AcceptedInvite = false;
|
||||
};
|
||||
|
||||
class BFMgrQueueRequestResponse final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
BFMgrQueueRequestResponse() : ServerPacket(SMSG_BF_MGR_QUEUE_REQUEST_RESPONSE, 8 + 4 + 1 + 16 + 1 + 1) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint64 QueueID = 0;
|
||||
int32 AreaID = 0;
|
||||
int8 Result = 0;
|
||||
ObjectGuid FailedPlayerGUID;
|
||||
int8 BattleState = 0;
|
||||
bool LoggingIn = false;
|
||||
};
|
||||
|
||||
class BFMgrQueueExitRequest final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BFMgrQueueExitRequest(WorldPacket&& packet) : ClientPacket(CMSG_BF_MGR_QUEUE_EXIT_REQUEST, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint64 QueueID = 0;
|
||||
};
|
||||
|
||||
class BFMgrEntering final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
BFMgrEntering() : ServerPacket(SMSG_BF_MGR_ENTERING, 1 + 8) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
bool ClearedAFK = false;
|
||||
bool Relocated = false;
|
||||
bool OnOffense = false;
|
||||
uint64 QueueID = 0;
|
||||
};
|
||||
|
||||
class BFMgrEjected final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
BFMgrEjected() : ServerPacket(SMSG_BF_MGR_EJECTED, 8 + 1 + 1 + 1) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint64 QueueID = 0;
|
||||
int8 Reason = 0;
|
||||
int8 BattleState = 0;
|
||||
bool Relocated = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BattlefieldPackets_h__
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Packets/AchievementPackets.h"
|
||||
#include "Packets/AuctionHousePackets.h"
|
||||
#include "Packets/BankPackets.h"
|
||||
#include "Packets/BattlefieldPackets.h"
|
||||
#include "Packets/BattlegroundPackets.h"
|
||||
#include "Packets/BattlePetPackets.h"
|
||||
#include "Packets/BlackMarketPackets.h"
|
||||
@@ -217,9 +218,9 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_HANDLER(CMSG_BATTLE_PET_SUMMON, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::BattlePet::BattlePetSummon, &WorldSession::HandleBattlePetSummon);
|
||||
DEFINE_HANDLER(CMSG_BATTLE_PET_UPDATE_NOTIFY, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
DEFINE_HANDLER(CMSG_BEGIN_TRADE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Trade::BeginTrade, &WorldSession::HandleBeginTradeOpcode);
|
||||
DEFINE_OPCODE_HANDLER_OLD(CMSG_BF_MGR_ENTRY_INVITE_RESPONSE, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleBfEntryInviteResponse );
|
||||
DEFINE_OPCODE_HANDLER_OLD(CMSG_BF_MGR_QUEUE_EXIT_REQUEST, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::HandleBfExitRequest);
|
||||
DEFINE_OPCODE_HANDLER_OLD(CMSG_BF_MGR_QUEUE_INVITE_RESPONSE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::HandleBfQueueInviteResponse );
|
||||
DEFINE_HANDLER(CMSG_BF_MGR_ENTRY_INVITE_RESPONSE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battlefield::BFMgrEntryInviteResponse, &WorldSession::HandleBfEntryInviteResponse);
|
||||
DEFINE_HANDLER(CMSG_BF_MGR_QUEUE_EXIT_REQUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battlefield::BFMgrQueueExitRequest, &WorldSession::HandleBfQueueExitRequest);
|
||||
DEFINE_HANDLER(CMSG_BF_MGR_QUEUE_INVITE_RESPONSE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battlefield::BFMgrQueueInviteResponse, &WorldSession::HandleBfQueueInviteResponse);
|
||||
DEFINE_HANDLER(CMSG_BF_MGR_QUEUE_REQUEST, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
DEFINE_HANDLER(CMSG_BINDER_ACTIVATE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::NPC::Hello, &WorldSession::HandleBinderActivateOpcode);
|
||||
DEFINE_HANDLER(CMSG_BLACK_MARKET_BID_ON_ITEM, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL);
|
||||
@@ -930,12 +931,12 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLE_PET_UPDATES, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_DROP_TIMER_CANCELLED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_DROP_TIMER_STARTED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_EJECTED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_EJECTED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_EJECT_PENDING, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_ENTERING, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_ENTRY_INVITE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_QUEUE_INVITE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_QUEUE_REQUEST_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_ENTERING, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_ENTRY_INVITE, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_QUEUE_INVITE, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_QUEUE_REQUEST_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_QUEUE_STATUS_UPDATE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BF_MGR_STATE_CHANGED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_BINDER_CONFIRM, STATUS_NEVER, CONNECTION_TYPE_REALM);
|
||||
|
||||
@@ -104,6 +104,13 @@ namespace WorldPackets
|
||||
class BuyBankSlot;
|
||||
}
|
||||
|
||||
namespace Battlefield
|
||||
{
|
||||
class BFMgrEntryInviteResponse;
|
||||
class BFMgrQueueInviteResponse;
|
||||
class BFMgrQueueExitRequest;
|
||||
}
|
||||
|
||||
namespace Battleground
|
||||
{
|
||||
class AreaSpiritHealerQuery;
|
||||
@@ -719,11 +726,13 @@ enum BarberShopResult
|
||||
|
||||
enum BFLeaveReason
|
||||
{
|
||||
BF_LEAVE_REASON_CLOSE = 0x00000001,
|
||||
//BF_LEAVE_REASON_UNK1 = 0x00000002, (not used)
|
||||
//BF_LEAVE_REASON_UNK2 = 0x00000004, (not used)
|
||||
BF_LEAVE_REASON_EXITED = 0x00000008,
|
||||
BF_LEAVE_REASON_LOW_LEVEL = 0x00000010
|
||||
BF_LEAVE_REASON_CLOSE = 1,
|
||||
//BF_LEAVE_REASON_UNK1 = 2, (not used)
|
||||
//BF_LEAVE_REASON_UNK2 = 4, (not used)
|
||||
BF_LEAVE_REASON_EXITED = 8,
|
||||
BF_LEAVE_REASON_LOW_LEVEL = 10,
|
||||
BF_LEAVE_REASON_NOT_WHILE_IN_RAID = 15,
|
||||
BF_LEAVE_REASON_DESERTER = 16
|
||||
};
|
||||
|
||||
enum ChatRestrictionType
|
||||
@@ -1444,14 +1453,14 @@ class WorldSession
|
||||
void HandleRequestBattlefieldStatusOpcode(WorldPackets::Battleground::RequestBattlefieldStatus& requestBattlefieldStatus);
|
||||
|
||||
// Battlefield
|
||||
void SendBfInvitePlayerToWar(ObjectGuid guid, uint32 zoneId, uint32 time);
|
||||
void SendBfInvitePlayerToQueue(ObjectGuid guid);
|
||||
void SendBfQueueInviteResponse(ObjectGuid guid, uint32 zoneId, bool canQueue = true, bool full = false);
|
||||
void SendBfEntered(ObjectGuid guid);
|
||||
void SendBfLeaveMessage(ObjectGuid guid, BFLeaveReason reason = BF_LEAVE_REASON_EXITED);
|
||||
void HandleBfQueueInviteResponse(WorldPacket& recvData);
|
||||
void HandleBfEntryInviteResponse(WorldPacket& recvData);
|
||||
void HandleBfExitRequest(WorldPacket& recvData);
|
||||
void SendBfInvitePlayerToWar(uint64 queueId, uint32 zoneId, uint32 acceptTime);
|
||||
void SendBfInvitePlayerToQueue(uint64 queueId, int8 battleState);
|
||||
void SendBfQueueInviteResponse(uint64 queueId, uint32 zoneId, int8 battleStatus, bool canQueue = true, bool loggingIn = false);
|
||||
void SendBfEntered(uint64 queueId, bool relocated, bool onOffense);
|
||||
void SendBfLeaveMessage(uint64 queueId, int8 battleState, bool relocated, BFLeaveReason reason = BF_LEAVE_REASON_EXITED);
|
||||
void HandleBfEntryInviteResponse(WorldPackets::Battlefield::BFMgrEntryInviteResponse& bfMgrEntryInviteResponse);
|
||||
void HandleBfQueueInviteResponse(WorldPackets::Battlefield::BFMgrQueueInviteResponse& bfMgrQueueInviteResponse);
|
||||
void HandleBfQueueExitRequest(WorldPackets::Battlefield::BFMgrQueueExitRequest& bfMgrQueueExitRequest);
|
||||
|
||||
void HandleWardenDataOpcode(WorldPacket& recvData);
|
||||
void HandleWorldTeleportOpcode(WorldPackets::Misc::WorldTeleport& worldTeleport);
|
||||
|
||||
Reference in New Issue
Block a user