TrinityCore
Loading...
Searching...
No Matches
BattlegroundPackets.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 "BattlegroundPackets.h"
19#include "PacketOperators.h"
20
22{
39
44
49
57
59{
60 for (std::size_t i = 0; i < 2; ++i)
61 {
62 data << int32(ratingData.Prematch[i]);
63 data << int32(ratingData.Postmatch[i]);
64 data << int32(ratingData.PrematchMMR[i]);
65 }
66
67 return data;
68}
69
71{
72 data << uint32(honorData.HonorKills);
73 data << uint32(honorData.Deaths);
74 data << uint32(honorData.ContributionPoints);
75
76 return data;
77}
78
80{
81 data << int32(pvpStat.PvpStatID);
82 data << int32(pvpStat.PvpStatValue);
83
84 return data;
85}
86
88{
89 data << playerData.PlayerGUID;
90 data << uint32(playerData.Kills);
91 data << int32(playerData.Faction);
92 data << uint32(playerData.DamageDone);
93 data << uint32(playerData.HealingDone);
94 data << Size<uint32>(playerData.Stats);
95 data << int32(playerData.PrimaryTalentTree);
96 data << int8(playerData.Sex);
97 data << int8(playerData.Race);
98 data << int8(playerData.Class);
99 data << int32(playerData.CreatureID);
100 data << int32(playerData.HonorLevel);
101 data << int32(playerData.Role);
102 for (PVPMatchStatistics::PVPMatchPlayerPVPStat const& pvpStat : playerData.Stats)
103 data << pvpStat;
104
105 data << Bits<1>(playerData.IsInWorld);
106 data << OptionalInit(playerData.Honor);
107 data << OptionalInit(playerData.PreMatchRating);
108 data << OptionalInit(playerData.RatingChange);
109 data << OptionalInit(playerData.PreMatchMMR);
110 data << OptionalInit(playerData.MmrChange);
111 data << OptionalInit(playerData.PostMatchMMR);
112 data.FlushBits();
113
114 if (playerData.Honor)
115 data << *playerData.Honor;
116
117 if (playerData.PreMatchRating)
118 data << uint32(*playerData.PreMatchRating);
119
120 if (playerData.RatingChange)
121 data << int32(*playerData.RatingChange);
122
123 if (playerData.PreMatchMMR)
124 data << uint32(*playerData.PreMatchMMR);
125
126 if (playerData.MmrChange)
127 data << int32(*playerData.MmrChange);
128
129 if (playerData.PostMatchMMR)
130 data << uint32(*playerData.PostMatchMMR);
131
132 return data;
133}
134
136{
137 data << OptionalInit(pvpLogData.Ratings);
138 data << Size<uint32>(pvpLogData.Statistics);
139 data.append(pvpLogData.PlayerCount.data(), pvpLogData.PlayerCount.size());
140
141 if (pvpLogData.Ratings)
142 data << *pvpLogData.Ratings;
143
144 for (PVPMatchStatistics::PVPMatchPlayerStatistics const& player : pvpLogData.Statistics)
145 data << player;
146
147 return data;
148}
149
158
160{
161 _worldPacket >> Size<uint32>(QueueIDs);
163 for (int32& blacklistMap : BlacklistMap)
164 _worldPacket >> blacklistMap;
165
166 for (uint64& queueId : QueueIDs)
167 _worldPacket >> queueId;
168}
169
175
177{
178 data << header.Ticket;
179 data << Size<uint32>(header.QueueID);
180 data << uint8(header.RangeMin);
181 data << uint8(header.RangeMax);
182 data << uint8(header.TeamSize);
183 data << uint32(header.InstanceID);
184 for (uint64 queueID : header.QueueID)
185 data << uint64(queueID);
186
187 data << Bits<1>(header.RegisteredMatch);
188 data << Bits<1>(header.TournamentRules);
189 data.FlushBits();
190
191 return data;
192}
193
195{
197
198 return &_worldPacket;
199}
200
210
212{
213 _worldPacket << Hdr;
218 _worldPacket << Bits<1>(LeftEarly);
219 _worldPacket << Bits<1>(Brawl);
221
222 return &_worldPacket;
223}
224
226{
227 _worldPacket << Hdr;
231 _worldPacket << Bits<1>(AsGroup);
232 _worldPacket << Bits<1>(EligibleForMatchmaking);
233 _worldPacket << Bits<1>(SuspendedQueue);
235
236 return &_worldPacket;
237}
238
248
250{
252 _worldPacket >> Bits<1>(AcceptedInvite);
253}
254
259
261{
266 _worldPacket << Size<uint32>(Battlefields);
267 if (!Battlefields.empty())
269
270 _worldPacket << Bits<1>(PvpAnywhere);
271 _worldPacket << Bits<1>(HasRandomWinToday);
273
274 return &_worldPacket;
275}
276
278{
279 _worldPacket << Bits<1>(RatedBattlegrounds);
280 _worldPacket << Bits<1>(PugBattlegrounds);
281 _worldPacket << Bits<1>(WargameBattlegrounds);
282 _worldPacket << Bits<1>(WargameArenas);
283 _worldPacket << Bits<1>(RatedArenas);
284 _worldPacket << Bits<1>(ArenaSkirmish);
285 _worldPacket << Bits<1>(SoloShuffle);
286 _worldPacket << Bits<1>(RatedSoloShuffle);
287 _worldPacket << Bits<1>(BattlegroundBlitz);
288 _worldPacket << Bits<1>(RatedBattlegroundBlitz);
290
291 return &_worldPacket;
292}
293
298
308
310{
311 data << playerPosition.Guid;
312 data << playerPosition.Pos;
313 data << int8(playerPosition.IconID);
314 data << int8(playerPosition.ArenaSlot);
315
316 return data;
317}
318
320{
321 _worldPacket << Size<uint32>(FlagCarriers);
323 _worldPacket << pos;
324
325 return &_worldPacket;
326}
327
334
336{
338
339 return &_worldPacket;
340}
341
343{
345
346 return &_worldPacket;
347}
348
350{
351 data << int32(bracketInfo.PersonalRating);
352 data << int32(bracketInfo.Ranking);
353 data << int32(bracketInfo.SeasonPlayed);
354 data << int32(bracketInfo.SeasonWon);
355 data << int32(bracketInfo.SeasonFactionPlayed);
356 data << int32(bracketInfo.SeasonFactionWon);
357 data << int32(bracketInfo.WeeklyPlayed);
358 data << int32(bracketInfo.WeeklyWon);
359 data << int32(bracketInfo.RoundsSeasonPlayed);
360 data << int32(bracketInfo.RoundsSeasonWon);
361 data << int32(bracketInfo.RoundsWeeklyPlayed);
362 data << int32(bracketInfo.RoundsWeeklyWon);
363 data << int32(bracketInfo.BestWeeklyRating);
364 data << int32(bracketInfo.LastWeeksBestRating);
365 data << int32(bracketInfo.BestSeasonRating);
366 data << int32(bracketInfo.PvpTierID);
367 data << int32(bracketInfo.SeasonPvpTier);
368 data << int32(bracketInfo.BestWeeklyPvpTier);
369 data << uint8(bracketInfo.BestSeasonPvpTierEnum);
370 data << Bits<1>(bracketInfo.Disqualified);
371 data.FlushBits();
372
373 return data;
374}
375
377{
378 for (BracketInfo const& bracket : Bracket)
379 _worldPacket << bracket;
380
381 return &_worldPacket;
382}
383
384ByteBuffer& operator<<(ByteBuffer& data, RatedMatchDeserterPenalty const& ratedMatchDeserterPenalty)
385{
386 data << int32(ratedMatchDeserterPenalty.PersonalRatingChange);
387 data << int32(ratedMatchDeserterPenalty.QueuePenaltySpellID);
388 data << ratedMatchDeserterPenalty.QueuePenaltyDuration;
389
390 return data;
391}
392
411
413{
415
416 return &_worldPacket;
417}
418
420{
424 _worldPacket << Bits<2>(SoloShuffleStatus);
426
427 if (LogData)
429
430 return &_worldPacket;
431}
432
433ByteBuffer& operator<<(ByteBuffer& data, BattlegroundCapturePointInfo const& battlegroundCapturePointInfo)
434{
435 data << battlegroundCapturePointInfo.Guid;
436 data << battlegroundCapturePointInfo.Pos;
437 data << int8(battlegroundCapturePointInfo.State);
438
439 if (battlegroundCapturePointInfo.State == BattlegroundCapturePointState::ContestedHorde || battlegroundCapturePointInfo.State == BattlegroundCapturePointState::ContestedAlliance)
440 {
441 data << battlegroundCapturePointInfo.CaptureTime;
442 data << battlegroundCapturePointInfo.CaptureTotalDuration;
443 }
444
445 return data;
446}
447
454
461}
uint8_t uint8
Definition Define.h:156
int8_t int8
Definition Define.h:152
int32_t int32
Definition Define.h:150
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
void reserve(size_t ressize)
Definition ByteBuffer.h:578
void append(T value)
Definition ByteBuffer.h:130
void FlushBits()
Definition ByteBuffer.h:141
std::vector< BattlegroundPlayerPosition > FlagCarriers
WorldPackets::Duration< Seconds > Duration
Optional< RatedMatchDeserterPenalty > DeserterPenalty
struct WorldPackets::Battleground::RatedPvpInfo::BracketInfo Bracket[9]
WorldPacket _worldPacket
Definition Packet.h:43
ByteBuffer & operator<<(ByteBuffer &data, PVPMatchStatistics::RatingData const &ratingData)
OptionalInitWriter< T > OptionalInit(Optional< T > const &value)
std::vector< PVPMatchPlayerStatistics > Statistics
WorldPackets::Duration< Milliseconds, int32 > QueuePenaltyDuration