diff options
Diffstat (limited to 'src/server/game/Battlefield/BattlefieldHandler.cpp')
-rw-r--r-- | src/server/game/Battlefield/BattlefieldHandler.cpp | 301 |
1 files changed, 234 insertions, 67 deletions
diff --git a/src/server/game/Battlefield/BattlefieldHandler.cpp b/src/server/game/Battlefield/BattlefieldHandler.cpp index b852082d582..ddb903a6d4e 100644 --- a/src/server/game/Battlefield/BattlefieldHandler.cpp +++ b/src/server/game/Battlefield/BattlefieldHandler.cpp @@ -27,124 +27,291 @@ #include "Opcodes.h" //This send to player windows for invite player to join the war -//Param1:(BattleId) the BattleId of Bf +//Param1:(guid) the guid of Bf //Param2:(ZoneId) the zone where the battle is (4197 for wg) //Param3:(time) Time in second that the player have for accept -void WorldSession::SendBfInvitePlayerToWar(uint32 BattleId, uint32 ZoneId, uint32 p_time) +void WorldSession::SendBfInvitePlayerToWar(uint64 guid, uint32 zoneId, uint32 pTime) { - //Send packet - WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 12); - data << uint32(BattleId); - data << uint32(ZoneId); - data << uint32((time(NULL) + p_time)); + ObjectGuid guidBytes = guid; + + WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 16); + + data.WriteBit(guidBytes[5]); + data.WriteBit(guidBytes[3]); + data.WriteBit(guidBytes[7]); + data.WriteBit(guidBytes[2]); + data.WriteBit(guidBytes[6]); + data.WriteBit(guidBytes[4]); + data.WriteBit(guidBytes[1]); + data.WriteBit(guidBytes[0]); + + data.WriteByteSeq(guidBytes[6]); + data << uint32(zoneId); // Zone Id + data.WriteByteSeq(guidBytes[1]); + data.WriteByteSeq(guidBytes[3]); + data.WriteByteSeq(guidBytes[4]); + data.WriteByteSeq(guidBytes[2]); + data.WriteByteSeq(guidBytes[0]); + data << uint32(time(NULL) + pTime); // Invite lasts until + data.WriteByteSeq(guidBytes[7]); + data.WriteByteSeq(guidBytes[5]); //Sending the packet to player SendPacket(&data); } //This send invitation to player to join the queue -//Param1:(BattleId) the BattleId of Bf -void WorldSession::SendBfInvitePlayerToQueue(uint32 BattleId) +void WorldSession::SendBfInvitePlayerToQueue(uint64 guid) { + ObjectGuid guidBytes = guid; + WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_INVITE, 5); - data << uint32(BattleId); - data << uint8(1); //warmup ? used ? + data.WriteBit(1); // unk + data.WriteBit(0); // Has Warmup + data.WriteBit(1); // unk + data.WriteBit(guidBytes[0]); + data.WriteBit(1); // unk + data.WriteBit(guidBytes[2]); + data.WriteBit(guidBytes[6]); + data.WriteBit(guidBytes[3]); + data.WriteBit(1); // unk + data.WriteBit(0); // unk + data.WriteBit(guidBytes[1]); + data.WriteBit(guidBytes[5]); + data.WriteBit(guidBytes[4]); + data.WriteBit(1); // unk + data.WriteBit(guidBytes[7]); + + data.FlushBits(); + + data.WriteByteSeq(guidBytes[2]); + data.WriteByteSeq(guidBytes[3]); + data.WriteByteSeq(guidBytes[6]); + data << uint8(1); // Warmup + data.WriteByteSeq(guidBytes[5]); + data.WriteByteSeq(guidBytes[0]); + data.WriteByteSeq(guidBytes[4]); + data.WriteByteSeq(guidBytes[1]); + data.WriteByteSeq(guidBytes[7]); //Sending packet to player SendPacket(&data); } //This send packet for inform player that he join queue -//Param1:(BattleId) the BattleId of Bf +//Param1:(guid) the guid of Bf //Param2:(ZoneId) the zone where the battle is (4197 for wg) //Param3:(CanQueue) if able to queue //Param4:(Full) on log in is full -void WorldSession::SendBfQueueInviteResponse(uint32 BattleId,uint32 ZoneId, bool CanQueue, bool Full) +void WorldSession::SendBfQueueInviteResponse(uint64 guid, uint32 ZoneId, bool CanQueue, bool Full) { - WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE, 11); - data << uint32(BattleId); + const bool hasSecondGuid = false; + const bool warmup = true; + ObjectGuid guidBytes = guid; + + WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE, 16); + + data.WriteBit(guidBytes[1]); + data.WriteBit(guidBytes[6]); + data.WriteBit(guidBytes[5]); + data.WriteBit(guidBytes[7]); + data.WriteBit(Full); // Logging In, VERIFYME + data.WriteBit(guidBytes[0]); + data.WriteBit(!hasSecondGuid); + data.WriteBit(guidBytes[4]); + + // if (hasSecondGuid) 7 3 0 4 2 6 1 5 + + data.WriteBit(guidBytes[3]); + data.WriteBit(guidBytes[2]); + + // if (hasSecondGuid) 2 5 3 0 4 6 1 7 + + data.FlushBits(); + + data << uint8(CanQueue); // Accepted + + data.WriteByteSeq(guidBytes[1]); + data.WriteByteSeq(guidBytes[3]); + data.WriteByteSeq(guidBytes[6]); + data.WriteByteSeq(guidBytes[7]); + data.WriteByteSeq(guidBytes[0]); + + data << uint8(warmup); + + data.WriteByteSeq(guidBytes[2]); + data.WriteByteSeq(guidBytes[4]); + data.WriteByteSeq(guidBytes[5]); + data << uint32(ZoneId); - data << uint8((CanQueue ? 1 : 0)); //Accepted //0 you cannot queue wg //1 you are queued - data << uint8((Full ? 0 : 1)); //Logging In //0 wg full //1 queue for upcoming - data << uint8(1); //Warmup + SendPacket(&data); } //This is call when player accept to join war -//Param1:(BattleId) the BattleId of Bf -void WorldSession::SendBfEntered(uint32 BattleId) +void WorldSession::SendBfEntered(uint64 guid) { -// m_PlayerInWar[player->GetTeamId()].insert(player->GetGUID()); - WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTERED, 7); - data << uint32(BattleId); - data << uint8(1); //unk - data << uint8(1); //unk - data << uint8(_player->isAFK() ? 1 : 0); //Clear AFK + uint8 isAFK = _player->isAFK() ? 1 : 0; + ObjectGuid guidBytes = guid; + + WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTERED, 11); + + data.WriteBit(0); // unk + data.WriteBit(isAFK); // Clear AFK + data.WriteBit(guidBytes[1]); + data.WriteBit(guidBytes[4]); + data.WriteBit(guidBytes[5]); + data.WriteBit(guidBytes[0]); + data.WriteBit(guidBytes[3]); + data.WriteBit(0); // unk + data.WriteBit(guidBytes[6]); + data.WriteBit(guidBytes[7]); + data.WriteBit(guidBytes[2]); + + data.FlushBits(); + + data.WriteByteSeq(guidBytes[5]); + data.WriteByteSeq(guidBytes[3]); + data.WriteByteSeq(guidBytes[0]); + data.WriteByteSeq(guidBytes[4]); + data.WriteByteSeq(guidBytes[1]); + data.WriteByteSeq(guidBytes[7]); + data.WriteByteSeq(guidBytes[2]); + data.WriteByteSeq(guidBytes[6]); + SendPacket(&data); } -void WorldSession::SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason) +void WorldSession::SendBfLeaveMessage(uint64 guid, BFLeaveReason reason) { - WorldPacket data(SMSG_BATTLEFIELD_MGR_EJECTED, 7); - data << uint32(BattleId); - data << uint8(reason);//byte Reason - data << uint8(2);//byte BattleStatus - data << uint8(0);//bool Relocated + ObjectGuid guidBytes = guid; + + WorldPacket data(SMSG_BATTLEFIELD_MGR_EJECTED, 11); + + data.WriteBit(guidBytes[2]); + data.WriteBit(guidBytes[5]); + data.WriteBit(guidBytes[1]); + data.WriteBit(guidBytes[0]); + data.WriteBit(guidBytes[3]); + data.WriteBit(guidBytes[6]); + data.WriteBit(0); // Relocated + data.WriteBit(guidBytes[7]); + data.WriteBit(guidBytes[4]); + + data.FlushBits(); + + data << uint8(2); // BattleStatus + data.WriteByteSeq(guidBytes[1]); + data.WriteByteSeq(guidBytes[7]); + data.WriteByteSeq(guidBytes[4]); + data.WriteByteSeq(guidBytes[2]); + data.WriteByteSeq(guidBytes[3]); + data << uint8(reason); // Reason + data.WriteByteSeq(guidBytes[6]); + data.WriteByteSeq(guidBytes[0]); + data.WriteByteSeq(guidBytes[5]); + SendPacket(&data); } //Send by client when he click on accept for queue -void WorldSession::HandleBfQueueInviteResponse(WorldPacket & recv_data) +void WorldSession::HandleBfQueueInviteResponse(WorldPacket& recvData) { - uint32 BattleId; - uint8 Accepted; + 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]); - recv_data >> BattleId >> Accepted; - sLog->outError(LOG_FILTER_GENERAL, "HandleQueueInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted); - Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); - if (!Bf) + sLog->outError(LOG_FILTER_GENERAL, "HandleQueueInviteResponse: GUID:"UI64FMTD" Accepted:%u", guid, accepted); + + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByGUID(guid); + if (!bf) return; - if (Accepted) - { - Bf->PlayerAcceptInviteToQueue(_player); - } + if (accepted) + bf->PlayerAcceptInviteToQueue(_player); } //Send by client on clicking in accept or refuse of invitation windows for join game -void WorldSession::HandleBfEntryInviteResponse(WorldPacket & recv_data) +void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData) { - uint32 BattleId; - uint8 Accepted; + 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]); + + sLog->outError(LOG_FILTER_GENERAL, "HandleBattlefieldInviteResponse: GUID:"UI64FMTD" Accepted:%u", guid, accepted); - recv_data >> BattleId >> Accepted; - sLog->outError(LOG_FILTER_GENERAL, "HandleBattlefieldInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted); - Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); - if (!Bf) + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByGUID(guid); + if (!bf) return; - //If player accept invitation - if (Accepted) - { - Bf->PlayerAcceptInviteToWar(_player); - } + if (accepted) + bf->PlayerAcceptInviteToWar(_player); else - { - if (_player->GetZoneId() == Bf->GetZoneId()) - Bf->KickPlayerFromBattlefield(_player->GetGUID()); - } + if (_player->GetZoneId() == bf->GetZoneId()) + bf->KickPlayerFromBattlefield(_player->GetGUID()); } -void WorldSession::HandleBfExitRequest(WorldPacket & recv_data) +void WorldSession::HandleBfExitRequest(WorldPacket& recvData) { - uint32 BattleId; + ObjectGuid guid; - recv_data >> BattleId; - sLog->outError(LOG_FILTER_GENERAL, "HandleBfExitRequest: BattleID:%u ", BattleId); - Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); - if (!Bf) - return; + 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]); + + sLog->outError(LOG_FILTER_GENERAL, "HandleBfExitRequest: GUID:"UI64FMTD" ", guid); - Bf->AskToLeaveQueue(_player); + if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldByGUID(guid)) + bf->AskToLeaveQueue(_player); } |