TrinityCore
Loading...
Searching...
No Matches
BattlefieldHandler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "WorldSession.h"
19#include "Battlefield.h"
20#include "BattlefieldMgr.h"
21#include "GameTime.h"
22#include "Log.h"
23#include "Opcodes.h"
24#include "Player.h"
25#include "WorldPacket.h"
26
37{
39 data << uint32(battleId);
40 data << uint32(zoneId);
41 data << uint32(GameTime::GetGameTime() + acceptTime);
42 SendPacket(&data);
43}
44
53{
55 data << uint32(battleId);
56 data << uint8(1); // warmup ? used ?
57 SendPacket(&data);
58}
59
70void WorldSession::SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue, bool full)
71{
73 data << uint32(battleId);
74 data << uint32(zoneId);
75 data << uint8(canQueue ? 1 : 0); // Accepted // 0 you cannot queue wg // 1 you are queued
76 data << uint8(full ? 0 : 1); // Logging In // 0 wg full // 1 queue for upcoming
77 data << uint8(1); // Warmup
78 SendPacket(&data);
79}
80
89{
91 data << uint32(battleId);
92 data << uint8(1); // unk
93 data << uint8(1); // unk
94 data << uint8(_player->isAFK() ? 1 : 0); // Clear AFK
95 SendPacket(&data);
96}
97
106void WorldSession::SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason /*= BF_LEAVE_REASON_EXITED*/)
107{
109 data << uint32(battleId);
110 data << uint8(reason); // byte Reason
111 data << uint8(2); // byte BattleStatus
112 data << uint8(0); // bool Relocated
113 SendPacket(&data);
114}
115
122{
123 uint32 battleId;
124 uint8 accepted;
125
126 recvData >> battleId >> accepted;
127
128 TC_LOG_DEBUG("misc", "HandleBfQueueInviteResponse: BattleID:{} Accepted:{}", battleId, accepted);
129
130 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
131 if (!bf)
132 return;
133
134 if (accepted)
136}
137
144{
145 uint32 battleId;
146 uint8 accepted;
147
148 recvData >> battleId >> accepted;
149
150 TC_LOG_DEBUG("misc", "HandleBfEntryInviteResponse: battleId: {}, accepted: {}", battleId, accepted);
151
152 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
153 if (!bf)
154 return;
155
156 // If player accept invitation
157 if (accepted)
159 else
160 if (_player->GetZoneId() == bf->GetZoneId())
162}
163
170{
171 uint32 battleId;
172
173 recvData >> battleId;
174
175 TC_LOG_DEBUG("misc", "HandleBfQueueExitRequest: battleId: {} ", battleId);
176
177 if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId))
178 bf->AskToLeaveQueue(_player);
179}
#define sBattlefieldMgr
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
uint32 GetZoneId() const
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
void PlayerAcceptInviteToWar(Player *player)
void PlayerAcceptInviteToQueue(Player *player)
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
bool isAFK() const
Definition Player.h:975
uint32 GetZoneId() const
Definition Object.h:373
void SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason=BF_LEAVE_REASON_EXITED)
This is call when player leave battlefield zone.
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
void HandleBfQueueInviteResponse(WorldPacket &recvData)
Send by client when he click on accept for queue.
void SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue=true, bool full=false)
This send packet for inform player that he join queue.
void HandleBfEntryInviteResponse(WorldPacket &recvData)
Send by client on clicking in accept or refuse of invitation windows for join game.
void SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 time)
This send to player windows for invite player to join the war.
Player * _player
void SendBfInvitePlayerToQueue(uint32 battleId)
This send invitation to player to join the queue.
void SendBfEntered(uint32 battleId)
This is call when player accept to join war.
void HandleBfQueueExitRequest(WorldPacket &recvData)
Send by client when exited battlefield.
BFLeaveReason
@ SMSG_BATTLEFIELD_MGR_EJECTED
Definition Opcodes.h:1283
@ SMSG_BATTLEFIELD_MGR_ENTRY_INVITE
Definition Opcodes.h:1275
@ SMSG_BATTLEFIELD_MGR_ENTERED
Definition Opcodes.h:1277
@ SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE
Definition Opcodes.h:1281
@ SMSG_BATTLEFIELD_MGR_QUEUE_INVITE
Definition Opcodes.h:1278
time_t GetGameTime()
Definition GameTime.cpp:42