From 3736cc5963a94b77ff0bf6d06edc2f1f793629a5 Mon Sep 17 00:00:00 2001 From: Aokromes Date: Sat, 21 Jan 2017 18:08:52 +0100 Subject: [PATCH] Core/Opcodes: Implement CMSG_BATTLEFIELD_MGR_QUEUE_REQUEST By ArcCORE. --- .../game/Handlers/BattlefieldHandler.cpp | 44 +++++++++++++++++++ src/server/game/Server/Protocol/Opcodes.cpp | 2 +- src/server/game/Server/WorldSession.h | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/server/game/Handlers/BattlefieldHandler.cpp b/src/server/game/Handlers/BattlefieldHandler.cpp index 2b5cd93e577..88553baea51 100644 --- a/src/server/game/Handlers/BattlefieldHandler.cpp +++ b/src/server/game/Handlers/BattlefieldHandler.cpp @@ -352,3 +352,47 @@ void WorldSession::HandleBfExitRequest(WorldPacket& recvData) bf->AskToLeaveQueue(_player); } + +/** + * @fn void WorldSession::HandleBfQueueRequest(WorldPacket & recvData) + * + * @brief Send by client when queued battlefield + */ +void WorldSession::HandleBfQueueRequest(WorldPacket & recvData) +{ + ObjectGuid guid; + + guid[0] = recvData.ReadBit(); + guid[3] = recvData.ReadBit(); + guid[7] = recvData.ReadBit(); + guid[4] = recvData.ReadBit(); + guid[6] = recvData.ReadBit(); + guid[2] = recvData.ReadBit(); + guid[1] = recvData.ReadBit(); + guid[5] = recvData.ReadBit(); + + recvData.ReadByteSeq(guid[6]); + recvData.ReadByteSeq(guid[3]); + recvData.ReadByteSeq(guid[2]); + recvData.ReadByteSeq(guid[4]); + recvData.ReadByteSeq(guid[7]); + recvData.ReadByteSeq(guid[1]); + recvData.ReadByteSeq(guid[5]); + recvData.ReadByteSeq(guid[0]); + + Battlefield *pBf = sBattlefieldMgr->GetBattlefieldByGUID(guid); + if(pBf) + { + BattlefieldQueue *pQueue = sBattlefieldMgr->GetQueueForBattlefield(guid); + if(pQueue) + { + bool canJoin = true; + + //check if player is queued in BG/LFG, if so - set canJoin to false + if(pQueue->HasEnoughSpace(GetPlayer()) && canJoin) + pQueue->AddPlayerToQueue(GetPlayer()); + + SendBfQueueInviteResponse(guid,pQueue->GetId(),pBf->GetZoneId(),canJoin,!pQueue->HasEnoughSpace(GetPlayer()),pBf->IsWarTime()); + } + } +} \ No newline at end of file diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 1a8143e409f..7ac161da0a3 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -102,7 +102,7 @@ void OpcodeTable::Initialize() DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_MGR_ENTRY_INVITE_RESPONSE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBfEntryInviteResponse ); DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_MGR_EXIT_REQUEST, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBfExitRequest ); DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBfQueueInviteResponse ); - DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_MGR_QUEUE_REQUEST, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); + DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_MGR_QUEUE_REQUEST, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBfQueueRequest ); DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_PORT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattleFieldPortOpcode ); DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_STATUS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlefieldStatusOpcode ); DEFINE_OPCODE_HANDLER(CMSG_BATTLEGROUND_PLAYER_POSITIONS, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBattlegroundPlayerPositionsOpcode); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index e76c5bfdd41..afb86d0af19 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -848,6 +848,7 @@ class TC_GAME_API WorldSession //Battleground void HandleBattlemasterHelloOpcode(WorldPacket& recvData); + void HandleBfQueueRequest(WorldPacket & recvData); void HandleBattlemasterJoinOpcode(WorldPacket& recvData); void HandleBattlegroundPlayerPositionsOpcode(WorldPacket& recvData); void HandlePVPLogDataOpcode(WorldPacket& recvData);