1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
|
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "LFGMgr.h"
#include "ObjectMgr.h"
#include "Group.h"
#include "Player.h"
#include "Opcodes.h"
#include "WorldPacket.h"
#include "WorldSession.h"
void BuildPlayerLockDungeonBlock(WorldPacket& data, const LfgLockMap& lock)
{
data << uint32(lock.size()); // Size of lock dungeons
for (LfgLockMap::const_iterator it = lock.begin(); it != lock.end(); ++it)
{
data << uint32(it->first); // Dungeon entry (id + type)
data << uint32(it->second); // Lock status
}
}
void BuildPartyLockDungeonBlock(WorldPacket& data, const LfgLockPartyMap& lockMap)
{
data << uint8(lockMap.size());
for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it)
{
data << uint64(it->first); // Player guid
BuildPlayerLockDungeonBlock(data, it->second);
}
}
void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData)
{
if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER) ||
(GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID() &&
(GetPlayer()->GetGroup()->GetMembersCount() == MAXGROUPSIZE || !GetPlayer()->GetGroup()->isLFGGroup())))
{
recvData.rfinish();
return;
}
uint8 numDungeons;
uint32 dungeon;
uint32 roles;
recvData >> roles;
recvData.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0)
recvData >> numDungeons;
if (!numDungeons)
{
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN %s no dungeons selected", GetPlayerInfo().c_str());
recvData.rfinish();
return;
}
LfgDungeonSet newDungeons;
for (int8 i = 0; i < numDungeons; ++i)
{
recvData >> dungeon;
newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry
}
recvData.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) }
std::string comment;
recvData >> comment;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN %s roles: %u, Dungeons: %u, Comment: %s",
GetPlayerInfo().c_str(), roles, uint8(newDungeons.size()), comment.c_str());
sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment);
}
void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/)
{
Group* grp = GetPlayer()->GetGroup();
uint64 guid = GetPlayer()->GetGUID();
uint64 gguid = grp ? grp->GetGUID() : guid;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE %s in group: %u",
GetPlayerInfo().c_str(), grp ? 1 : 0);
// Check cheating - only leader can leave the queue
if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID())
sLFGMgr->LeaveLfg(gguid);
}
void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recvData)
{
uint32 lfgGroupID; // Internal lfgGroupID
bool accept; // Accept to join?
recvData >> lfgGroupID;
recvData >> accept;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PROPOSAL_RESULT %s proposal: %u accept: %u",
GetPlayerInfo().c_str(), lfgGroupID, accept ? 1 : 0);
sLFGMgr->UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept);
}
void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recvData)
{
uint8 roles;
recvData >> roles; // Player Group Roles
uint64 guid = GetPlayer()->GetGUID();
Group* grp = GetPlayer()->GetGroup();
if (!grp)
{
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES %s Not in group",
GetPlayerInfo().c_str());
return;
}
uint64 gguid = grp->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group %u, Player %s, Roles: %u",
GUID_LOPART(gguid), GetPlayerInfo().c_str(), roles);
sLFGMgr->UpdateRoleCheck(gguid, guid, roles);
}
void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recvData)
{
std::string comment;
recvData >> comment;
uint64 guid = GetPlayer()->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT %s comment: %s",
GetPlayerInfo().c_str(), comment.c_str());
sLFGMgr->SetComment(guid, comment);
}
void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recvData)
{
bool agree; // Agree to kick player
recvData >> agree;
uint64 guid = GetPlayer()->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE %s agree: %u",
GetPlayerInfo().c_str(), agree ? 1 : 0);
sLFGMgr->UpdateBoot(guid, agree);
}
void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recvData)
{
bool out;
recvData >> out;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_TELEPORT %s out: %u",
GetPlayerInfo().c_str(), out ? 1 : 0);
sLFGMgr->TeleportPlayer(GetPlayer(), out, true);
}
void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData*/)
{
uint64 guid = GetPlayer()->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST %s",
GetPlayerInfo().c_str());
// Get Random dungeons that can be done at a certain level and expansion
LfgDungeonSet randomDungeons;
uint8 level = GetPlayer()->getLevel();
uint8 expansion = GetPlayer()->GetSession()->Expansion();
LFGDungeonContainer& LfgDungeons = sLFGMgr->GetLFGDungeonMap();
for (LFGDungeonContainer::const_iterator itr = LfgDungeons.begin(); itr != LfgDungeons.end(); ++itr)
{
LFGDungeonData const& dungeon = itr->second;
if ((dungeon.type == LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id)))
&& dungeon.expansion <= expansion && dungeon.minlevel <= level && level <= dungeon.maxlevel)
randomDungeons.insert(dungeon.Entry());
}
// Get player locked Dungeons
LfgLockMap const& lock = sLFGMgr->GetLockedDungeons(guid);
uint32 rsize = uint32(randomDungeons.size());
uint32 lsize = uint32(lock.size());
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_INFO %s", GetPlayerInfo().c_str());
WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4));
data << uint8(randomDungeons.size()); // Random Dungeon count
for (LfgDungeonSet::const_iterator it = randomDungeons.begin(); it != randomDungeons.end(); ++it)
{
data << uint32(*it); // Dungeon Entry (id + type)
LfgReward const* reward = sLFGMgr->GetRandomDungeonReward(*it, level);
Quest const* quest = NULL;
uint8 done = 0;
if (reward)
{
quest = sObjectMgr->GetQuestTemplate(reward->reward[0].questId);
if (quest)
{
done = !GetPlayer()->CanRewardQuest(quest, false);
if (done)
quest = sObjectMgr->GetQuestTemplate(reward->reward[1].questId);
}
}
if (quest)
{
data << uint8(done);
data << uint32(quest->GetRewOrReqMoney());
data << uint32(quest->XPValue(GetPlayer()));
data << uint32(reward->reward[done].variableMoney);
data << uint32(reward->reward[done].variableXP);
data << uint8(quest->GetRewItemsCount());
if (quest->GetRewItemsCount())
{
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
if (uint32 itemId = quest->RewardItemId[i])
{
ItemTemplate const* item = sObjectMgr->GetItemTemplate(itemId);
data << uint32(itemId);
data << uint32(item ? item->DisplayInfoID : 0);
data << uint32(quest->RewardItemIdCount[i]);
}
}
}
else
{
data << uint8(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint8(0);
}
}
BuildPlayerLockDungeonBlock(data, lock);
SendPacket(&data);
}
void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData*/)
{
uint64 guid = GetPlayer()->GetGUID();
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST %s", GetPlayerInfo().c_str());
Group* grp = GetPlayer()->GetGroup();
if (!grp)
return;
// Get the locked dungeons of the other party members
LfgLockPartyMap lockMap;
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* plrg = itr->getSource();
if (!plrg)
continue;
uint64 pguid = plrg->GetGUID();
if (pguid == guid)
continue;
lockMap[pguid] = sLFGMgr->GetLockedDungeons(pguid);
}
uint32 size = 0;
for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it)
size += 8 + 4 + uint32(it->second.size()) * (4 + 4);
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PARTY_INFO %s", GetPlayerInfo().c_str());
WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size);
BuildPartyLockDungeonBlock(data, lockMap);
SendPacket(&data);
}
void WorldSession::HandleLfrJoinOpcode(WorldPacket& recvData)
{
uint32 entry; // Raid id to search
recvData >> entry;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_JOIN %s dungeon entry: %u",
GetPlayerInfo().c_str(), entry);
//SendLfrUpdateListOpcode(entry);
}
void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recvData)
{
uint32 dungeonId; // Raid id queue to leave
recvData >> dungeonId;
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_LEAVE %s dungeonId: %u",
GetPlayerInfo().c_str(), dungeonId);
//sLFGMgr->LeaveLfr(GetPlayer(), dungeonId);
}
void WorldSession::HandleLfgGetStatus(WorldPacket& /*recvData*/)
{
sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_GET_STATUS %s", GetPlayerInfo().c_str());
uint64 guid = GetPlayer()->GetGUID();
LfgUpdateData updateData = sLFGMgr->GetLfgStatus(guid);
if (GetPlayer()->GetGroup())
{
SendLfgUpdateParty(updateData);
updateData.dungeons.clear();
SendLfgUpdatePlayer(updateData);
}
else
{
SendLfgUpdatePlayer(updateData);
updateData.dungeons.clear();
SendLfgUpdateParty(updateData);
}
}
void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData)
{
bool queued = false;
uint8 size = uint8(updateData.dungeons.size());
switch (updateData.updateType)
{
case LFG_UPDATETYPE_JOIN_QUEUE:
case LFG_UPDATETYPE_ADDED_TO_QUEUE:
queued = true;
break;
case LFG_UPDATETYPE_UPDATE_STATUS:
queued = updateData.state == LFG_STATE_QUEUED;
break;
default:
break;
}
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PLAYER %s updatetype: %u",
GetPlayerInfo().c_str(), updateData.updateType);
WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (size > 0 ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length()));
data << uint8(updateData.updateType); // Lfg Update type
data << uint8(size > 0); // Extra info
if (size)
{
data << uint8(queued); // Join the queue
data << uint8(0); // unk - Always 0
data << uint8(0); // unk - Always 0
data << uint8(size);
for (LfgDungeonSet::const_iterator it = updateData.dungeons.begin(); it != updateData.dungeons.end(); ++it)
data << uint32(*it);
data << updateData.comment;
}
SendPacket(&data);
}
void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData)
{
bool join = false;
bool queued = false;
uint8 size = uint8(updateData.dungeons.size());
switch (updateData.updateType)
{
case LFG_UPDATETYPE_ADDED_TO_QUEUE: // Rolecheck Success
queued = true;
// no break on purpose
case LFG_UPDATETYPE_PROPOSAL_BEGIN:
join = true;
break;
case LFG_UPDATETYPE_UPDATE_STATUS:
join = updateData.state != LFG_STATE_ROLECHECK && updateData.state != LFG_STATE_NONE;
queued = updateData.state == LFG_STATE_QUEUED;
break;
default:
break;
}
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PARTY %s updatetype: %u",
GetPlayerInfo().c_str(), updateData.updateType);
WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (size > 0 ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length()));
data << uint8(updateData.updateType); // Lfg Update type
data << uint8(size > 0); // Extra info
if (size)
{
data << uint8(join); // LFG Join
data << uint8(queued); // Join the queue
data << uint8(0); // unk - Always 0
data << uint8(0); // unk - Always 0
for (uint8 i = 0; i < 3; ++i)
data << uint8(0); // unk - Always 0
data << uint8(size);
for (LfgDungeonSet::const_iterator it = updateData.dungeons.begin(); it != updateData.dungeons.end(); ++it)
data << uint32(*it);
data << updateData.comment;
}
SendPacket(&data);
}
void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles)
{
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHOSEN %s guid: %u roles: %u",
GetPlayerInfo().c_str(), GUID_LOPART(guid), roles);
WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4);
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
SendPacket(&data);
}
void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck)
{
LfgDungeonSet dungeons;
if (roleCheck.rDungeonId)
dungeons.insert(roleCheck.rDungeonId);
else
dungeons = roleCheck.dungeons;
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHECK_UPDATE %s", GetPlayerInfo().c_str());
WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1));
data << uint32(roleCheck.state); // Check result
data << uint8(roleCheck.state == LFG_ROLECHECK_INITIALITING);
data << uint8(dungeons.size()); // Number of dungeons
if (!dungeons.empty())
{
for (LfgDungeonSet::iterator it = dungeons.begin(); it != dungeons.end(); ++it)
{
LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(*it);
data << uint32(dungeon ? dungeon->Entry() : 0); // Dungeon
}
}
data << uint8(roleCheck.roles.size()); // Players in group
if (!roleCheck.roles.empty())
{
// Leader info MUST be sent 1st :S
uint64 guid = roleCheck.leader;
uint8 roles = roleCheck.roles.find(guid)->second;
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
Player* player = ObjectAccessor::FindPlayer(guid);
data << uint8(player ? player->getLevel() : 0); // Level
for (LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
{
if (it->first == roleCheck.leader)
continue;
guid = it->first;
roles = it->second;
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
player = ObjectAccessor::FindPlayer(guid);
data << uint8(player ? player->getLevel() : 0);// Level
}
}
SendPacket(&data);
}
void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData)
{
uint32 size = 0;
for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it)
size += 8 + 4 + uint32(it->second.size()) * (4 + 4);
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT %s checkResult: %u checkValue: %u",
GetPlayerInfo().c_str(), joinData.result, joinData.state);
WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size);
data << uint32(joinData.result); // Check Result
data << uint32(joinData.state); // Check Value
if (!joinData.lockmap.empty())
BuildPartyLockDungeonBlock(data, joinData.lockmap);
SendPacket(&data);
}
void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData)
{
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS %s dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u",
GetPlayerInfo().c_str(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps);
WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4);
data << uint32(queueData.dungeonId); // Dungeon
data << int32(queueData.waitTimeAvg); // Average Wait time
data << int32(queueData.waitTime); // Wait Time
data << int32(queueData.waitTimeTank); // Wait Tanks
data << int32(queueData.waitTimeHealer); // Wait Healers
data << int32(queueData.waitTimeDps); // Wait Dps
data << uint8(queueData.tanks); // Tanks needed
data << uint8(queueData.healers); // Healers needed
data << uint8(queueData.dps); // Dps needed
data << uint32(queueData.queuedTime); // Player wait time in queue
SendPacket(&data);
}
void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward* reward, const Quest* quest)
{
if (!rdungeonEntry || !sdungeonEntry || !quest)
return;
uint8 itemNum = uint8(quest ? quest->GetRewItemsCount() : 0);
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD %s rdungeonEntry: %u - sdungeonEntry: %u - done: %u",
GetPlayerInfo().c_str(), rdungeonEntry, sdungeonEntry, done);
WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4));
data << uint32(rdungeonEntry); // Random Dungeon Finished
data << uint32(sdungeonEntry); // Dungeon Finished
data << uint8(done);
data << uint32(1);
data << uint32(quest->GetRewOrReqMoney());
data << uint32(quest->XPValue(GetPlayer()));
data << uint32(reward->reward[done].variableMoney);
data << uint32(reward->reward[done].variableXP);
data << uint8(itemNum);
if (itemNum)
{
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
if (uint32 itemId = quest->RewardItemId[i])
{
ItemTemplate const* item = sObjectMgr->GetItemTemplate(itemId);
data << uint32(itemId);
data << uint32(item ? item->DisplayInfoID : 0);
data << uint32(quest->RewardItemIdCount[i]);
}
}
SendPacket(&data);
}
void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot)
{
uint64 guid = GetPlayer()->GetGUID();
LfgAnswer playerVote = boot.votes.find(guid)->second;
uint8 votesNum = 0;
uint8 agreeNum = 0;
uint32 secsleft = uint8((boot.cancelTime - time(NULL)) / 1000);
for (LfgAnswerContainer::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it)
{
if (it->second != LFG_ANSWER_PENDING)
{
++votesNum;
if (it->second == LFG_ANSWER_AGREE)
++agreeNum;
}
}
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_BOOT_PROPOSAL_UPDATE %s inProgress: %u - "
"didVote: %u - agree: %u - victim: %u votes: %u - agrees: %u - left: %u - "
"needed: %u - reason %s",
GetPlayerInfo().c_str(), uint8(boot.inProgress), uint8(playerVote != LFG_ANSWER_PENDING),
uint8(playerVote == LFG_ANSWER_AGREE), GUID_LOPART(boot.victim), votesNum, agreeNum,
secsleft, LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str());
WorldPacket data(SMSG_LFG_BOOT_PROPOSAL_UPDATE, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length());
data << uint8(boot.inProgress); // Vote in progress
data << uint8(playerVote != LFG_ANSWER_PENDING); // Did Vote
data << uint8(playerVote == LFG_ANSWER_AGREE); // Agree
data << uint64(boot.victim); // Victim GUID
data << uint32(votesNum); // Total Votes
data << uint32(agreeNum); // Agree Count
data << uint32(secsleft); // Time Left
data << uint32(LFG_GROUP_KICK_VOTES_NEEDED); // Needed Votes
data << boot.reason.c_str(); // Kick reason
SendPacket(&data);
}
void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& proposal)
{
uint64 guid = GetPlayer()->GetGUID();
uint64 gguid = proposal.players.find(guid)->second.group;
bool silent = !proposal.isNew && gguid == proposal.group;
uint32 dungeonEntry = proposal.dungeonId;
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE %s state: %u",
GetPlayerInfo().c_str(), proposal.state);
WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1));
// show random dungeon if player selected random dungeon and it's not lfg group
if (!silent)
{
LfgDungeonSet const& playerDungeons = sLFGMgr->GetSelectedDungeons(guid);
if (playerDungeons.find(proposal.dungeonId) == playerDungeons.end())
dungeonEntry = (*playerDungeons.begin());
}
if (LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(dungeonEntry))
dungeonEntry = dungeon->Entry();
data << uint32(dungeonEntry); // Dungeon
data << uint8(proposal.state); // Proposal state
data << uint32(proposalId); // Proposal ID
data << uint32(proposal.encounters); // encounters done
data << uint8(silent); // Show proposal window
data << uint8(proposal.players.size()); // Group size
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
{
LfgProposalPlayer const& player = it->second;
data << uint32(player.role); // Role
data << uint8(it->first == guid); // Self player
if (!player.group) // Player not it a group
{
data << uint8(0); // Not in dungeon
data << uint8(0); // Not same group
}
else
{
data << uint8(player.group == proposal.group); // In dungeon (silent)
data << uint8(player.group == gguid); // Same Group than player
}
data << uint8(player.accept != LFG_ANSWER_PENDING);// Answered
data << uint8(player.accept == LFG_ANSWER_AGREE); // Accepted
}
SendPacket(&data);
}
void WorldSession::SendLfgLfrList(bool update)
{
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_LFR_LIST %s update: %u",
GetPlayerInfo().c_str(), update ? 1 : 0);
WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1);
data << uint8(update); // In Lfg Queue?
SendPacket(&data);
}
void WorldSession::SendLfgDisabled()
{
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_DISABLED %s", GetPlayerInfo().c_str());
WorldPacket data(SMSG_LFG_DISABLED, 0);
SendPacket(&data);
}
void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry)
{
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_OFFER_CONTINUE %s dungeon entry: %u",
GetPlayerInfo().c_str(), dungeonEntry);
WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4);
data << uint32(dungeonEntry);
SendPacket(&data);
}
void WorldSession::SendLfgTeleportError(uint8 err)
{
sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_TELEPORT_DENIED %s reason: %u",
GetPlayerInfo().c_str(), err);
WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4);
data << uint32(err); // Error
SendPacket(&data);
}
/*
void WorldSession::SendLfrUpdateListOpcode(uint32 dungeonEntry)
{
sLog->outDebug(LOG_FILTER_PACKETIO, "SMSG_LFG_UPDATE_LIST %s dungeon entry: %u",
GetPlayerInfo().c_str(), dungeonEntry);
WorldPacket data(SMSG_LFG_UPDATE_LIST);
SendPacket(&data);
}
*/
|