diff options
Diffstat (limited to 'src/server/game/Handlers/BattlefieldHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/BattlefieldHandler.cpp | 193 |
1 files changed, 115 insertions, 78 deletions
diff --git a/src/server/game/Handlers/BattlefieldHandler.cpp b/src/server/game/Handlers/BattlefieldHandler.cpp index 078c2eb1084..b0580681f91 100644 --- a/src/server/game/Handlers/BattlefieldHandler.cpp +++ b/src/server/game/Handlers/BattlefieldHandler.cpp @@ -15,136 +15,173 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "Opcodes.h" +#include "Player.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Battlefield.h" #include "BattlefieldMgr.h" -#include "Opcodes.h" -#include "Player.h" -//This send to player windows for invite player to join the war -//Param1:(BattleId) the BattleId 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) +/** + * @fn void WorldSession::SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 acceptTime) + * + * @brief This send to player windows for invite player to join the war. + * + * @param battleId The BattleId 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(uint32 battleId, uint32 zoneId, uint32 acceptTime) { - //Send packet WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 12); - data << uint32(BattleId); - data << uint32(ZoneId); - data << uint32((time(NULL) + p_time)); - - //Sending the packet to player + data << uint32(battleId); + data << uint32(zoneId); + data << uint32(time(NULL) + acceptTime); SendPacket(&data); } -//This send invitation to player to join the queue -//Param1:(BattleId) the BattleId of Bf -void WorldSession::SendBfInvitePlayerToQueue(uint32 BattleId) +/** + * @fn void WorldSession::SendBfInvitePlayerToQueue(uint32 battleId) + * + * @brief This send invitation to player to join the queue. + * + * @param battleId The BattleId of Bf + */ +void WorldSession::SendBfInvitePlayerToQueue(uint32 battleId) { WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_INVITE, 5); - - data << uint32(BattleId); - data << uint8(1); //warmup ? used ? - - //Sending packet to player + data << uint32(battleId); + data << uint8(1); // warmup ? used ? SendPacket(&data); } -//This send packet for inform player that he join queue -//Param1:(BattleId) the BattleId 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) +/** + * @fn void WorldSession::SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue, bool full) + * + * @brief This send packet for inform player that he join queue. + * + * @param battleId The BattleId of Bf + * @param zoneId The zone where the battle is (4197 for wg) + * @param canQueue if able to queue + * @param full on log in is full + */ +void WorldSession::SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue, bool full) { WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE, 11); - data << uint32(BattleId); - 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 + data << uint32(battleId); + 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) +/** + * @fn void WorldSession::SendBfEntered(uint32 battleId) + * + * @brief This is call when player accept to join war. + * + * @param battleId The BattleId of Bf + */ +void WorldSession::SendBfEntered(uint32 battleId) { -// 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 + data << uint32(battleId); + data << uint8(1); // unk + data << uint8(1); // unk + data << uint8(_player->isAFK() ? 1 : 0); // Clear AFK SendPacket(&data); } -void WorldSession::SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason) +/** + * @fn void WorldSession::SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason) + * + * @brief This is call when player leave battlefield zone. + * + * @param battleId The BattleId of Bf + * @param reason Reason why player left battlefield + */ +void WorldSession::SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason /*= BF_LEAVE_REASON_EXITED*/) { 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 + data << uint32(battleId); + data << uint8(reason); // byte Reason + data << uint8(2); // byte BattleStatus + data << uint8(0); // bool Relocated SendPacket(&data); } -//Send by client when he click on accept for queue -void WorldSession::HandleBfQueueInviteResponse(WorldPacket & recvData) +/** + * @fn void WorldSession::HandleBfQueueInviteResponse(WorldPacket& recvData) + * + * @brief Send by client when he click on accept for queue. + */ +void WorldSession::HandleBfQueueInviteResponse(WorldPacket& recvData) { - uint32 BattleId; - uint8 Accepted; + uint32 battleId; + uint8 accepted; + + recvData >> battleId >> accepted; - recvData >> BattleId >> Accepted; - TC_LOG_DEBUG("misc", "HandleQueueInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted); - Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); - if (!Bf) + TC_LOG_DEBUG("misc", "HandleBfQueueInviteResponse: BattleID:%u Accepted:%u", battleId, accepted); + + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); + 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 & recvData) +/** + * @fn void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData) + * + * @brief Send by client on clicking in accept or refuse of invitation windows for join game. + */ +void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData) { - uint32 BattleId; - uint8 Accepted; + uint32 battleId; + uint8 accepted; + + recvData >> battleId >> accepted; + + TC_LOG_DEBUG("misc", "HandleBfEntryInviteResponse: battleId: %u, accepted: %u", battleId, accepted); - recvData >> BattleId >> Accepted; - TC_LOG_DEBUG("misc", "HandleBattlefieldInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted); - Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); - if (!Bf) + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); + if (!bf) return; - //If player accept invitation - if (Accepted) + // If player accept invitation + if (accepted) { - Bf->PlayerAcceptInviteToWar(_player); + 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 & recvData) +/** + * @fn void WorldSession::HandleBfExitRequest(WorldPacket& recvData) + * + * @brief Send by client when exited battlefield + */ +void WorldSession::HandleBfExitRequest(WorldPacket& recvData) { - uint32 BattleId; + uint32 battleId; + + recvData >> battleId; + + TC_LOG_DEBUG("misc", "HandleBfExitRequest: battleId: %u ", battleId); - recvData >> BattleId; - TC_LOG_DEBUG("misc", "HandleBfExitRequest: BattleID:%u ", BattleId); - Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); - if (!Bf) + Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId); + if (!bf) return; - Bf->AskToLeaveQueue(_player); + bf->AskToLeaveQueue(_player); } |