OregonCore  revision 3611e8a-git
Your Favourite TBC server
GroupHandler.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore 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 "Common.h"
19 #include "Database/DatabaseEnv.h"
20 #include "Opcodes.h"
21 #include "Log.h"
22 #include "WorldPacket.h"
23 #include "WorldSession.h"
24 #include "World.h"
25 #include "ObjectMgr.h"
26 #include "Player.h"
27 #include "Group.h"
28 #include "ObjectAccessor.h"
29 #include "MapManager.h"
30 #include "SocialMgr.h"
31 #include "Util.h"
32 
33 /* differeces from off:
34  -you can uninvite yourself - is is useful
35  -you can accept invitation even if leader went offline
36 */
37 /* @todo
38  -group_destroyed msg is sent but not shown
39  -reduce xp gaining when in raid group
40  -quest sharing has to be corrected
41  -FIX sending PartyMemberStats
42 */
43 
44 void WorldSession::SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res)
45 {
46  WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (4 + member.size() + 1 + 4));
47  data << (uint32)operation;
48  data << member;
49  data << (uint32)res;
50 
51  SendPacket(&data);
52 }
53 
55 {
56  std::string membername;
57  recv_data >> membername;
58 
59  // attempt add selected player
60 
61  // cheating
62  if (!normalizePlayerName(membername))
63  {
65  return;
66  }
67 
68  if (GetPlayer()->InBattleground())
69  {
71  return;
72  }
73 
74  Player* player = sObjectMgr.GetPlayer(membername.c_str(), true);
75 
76  // no player
77  if (!player)
78  {
80  return;
81  }
82 
83  // player trying to invite himself (most likely cheating)
84  if (player == GetPlayer())
85  {
87  return;
88  }
89 
90  // restrict invite to GMs
91  if (!sWorld.getConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster())
92  {
94  return;
95  }
96 
97  // can't group with
98  if (!GetPlayer()->IsGameMaster() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam())
99  {
101  return;
102  }
103  // different instances
104  if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId())
105  {
107  return;
108  }
109  // different difficulties
110  if (player->GetInstanceId() != 0 && player->GetDifficulty() != GetPlayer()->GetDifficulty())
111  {
113  return;
114  }
115  // just ignore us
116  if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
117  {
119  return;
120  }
121 
122  Group* group = GetPlayer()->GetGroup();
123  if (group && group->isBGGroup())
124  group = GetPlayer()->GetOriginalGroup();
125 
126  Group* group2 = player->GetGroup();
127  if (group2 && group2->isBGGroup())
128  group2 = player->GetOriginalGroup();
129 
130  // player already in another group or invited
131  if (group2 || player->GetGroupInvite())
132  {
134  return;
135  }
136 
137  if (group)
138  {
139  // not have permissions for invite
140  if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
141  {
143  return;
144  }
145  // not have place
146  if (group->IsFull())
147  {
149  return;
150  }
151  }
152 
153  if (!group)
154  if ((group = GetPlayer()->GetGroupInvite()))
155  if (group && !group->IsCreated() && !group->IsLeader(GetPlayer()->GetGUID()))
156  group = NULL;
157 
158  // ok, but group not exist, start a new group
159  // but don't create and save the group to the DB until
160  // at least one person joins
161  if (!group)
162  {
163  group = new Group;
164  // new group: if can't add then delete
165  if (!group->AddLeaderInvite(GetPlayer()))
166  {
167  delete group;
168  return;
169  }
170  if (!group->AddInvite(player, false))
171  {
172  group->RemoveAllInvites();
173  delete group;
174  return;
175  }
176  }
177  else
178  {
179  // already existed group: if can't add then just leave
180  if (!group->AddInvite(player, false))
181  return;
182  }
183 
184  // ok, we do it
185  WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size
186  data << GetPlayer()->GetName();
187  player->GetSession()->SendPacket(&data);
188 
190 }
191 
193 {
194  Group* group = GetPlayer()->GetGroupInvite();
195  if (!group) return;
196 
197  if (GetPlayer()->GetGroup())
198  {
200  return;
201  }
202 
203  if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
204  {
205  sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
206  return;
207  }
208 
209  // remove in from ivites in any case
210  group->RemoveInvite(GetPlayer());
211 
213  /********************/
214 
215  // not have place
216  if (group->IsFull())
217  {
219  return;
220  }
221 
222  Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGUID());
223 
224  // forming a new group, create it
225  if (!group->IsCreated())
226  {
227  if (leader)
228  group->RemoveInvite(leader);
229  group->Create(group->GetLeaderGUID(), group->GetLeaderName());
230  sObjectMgr.AddGroup(group);
231  }
232 
233  // everything's fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
234  if (!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
235  return;
236 
237  group->BroadcastGroupUpdate();
238 }
239 
241 {
242  Group* group = GetPlayer()->GetGroupInvite();
243  if (!group) return;
244 
245  // Remember leader if online (group pointer will be invalid if group gets disbanded)
246  Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGUID(), true);
247 
248  // uninvite, group can be deleted
250 
251  if (!leader || !leader->GetSession())
252  return;
253 
254  // report
255  WorldPacket data(SMSG_GROUP_DECLINE, 10); // guess size
256  data << GetPlayer()->GetName();
257  leader->GetSession()->SendPacket(&data);
258 }
259 
261 {
262  uint64 guid;
263  recv_data >> guid;
264 
265  //can't uninvite yourself
266  if (guid == GetPlayer()->GetGUID())
267  {
268  sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
269  return;
270  }
271 
273  if (res != PARTY_RESULT_OK)
274  {
276  return;
277  }
278 
279  Group* grp = GetPlayer()->GetGroup();
280  if (!grp)
281  return;
282 
283  if (grp->IsLeader(guid))
284  {
286  return;
287  }
288 
289  if (grp->IsMember(guid))
290  {
292  return;
293  }
294 
295  if (Player* plr = grp->GetInvited(guid))
296  {
297  plr->UninviteFromGroup();
298  return;
299  }
300 
302 }
303 
305 {
306  std::string membername;
307  recv_data >> membername;
308 
309  // player not found
310  if (!normalizePlayerName(membername))
311  return;
312 
313  // can't uninvite yourself
314  if (GetPlayer()->GetName() == membername)
315  {
316  sLog.outError("WorldSession::HandleGroupUninviteNameOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
317  return;
318  }
319 
321  if (res != PARTY_RESULT_OK)
322  {
324  return;
325  }
326 
327  Group* grp = GetPlayer()->GetGroup();
328  if (!grp)
329  return;
330 
331  if (uint64 guid = grp->GetMemberGUID(membername))
332  {
333  if (grp->IsLeader(guid))
334  {
336  return;
337  }
338 
340  return;
341  }
342 
343  if (Player* plr = grp->GetInvited(membername))
344  {
345  plr->UninviteFromGroup();
346  return;
347  }
348 
350 }
351 
353 {
354  Group* group = GetPlayer()->GetGroup();
355  if (!group)
356  return;
357 
358  uint64 guid;
359  recv_data >> guid;
360 
361  Player* player = sObjectMgr.GetPlayer(guid, true);
362 
364  if (!player || !group->IsLeader(GetPlayer()->GetGUID()) || player->GetGroup() != group)
365  return;
366  /********************/
367 
368  // everything's fine, do it
369  group->ChangeLeader(guid);
370 }
371 
373 {
374  if (!GetPlayer()->GetGroup())
375  return;
376 
377  if (_player->InBattleground())
378  {
380  return;
381  }
382 
384  /********************/
385 
386  // everything's fine, do it
388 
390 }
391 
393 {
394  uint32 lootMethod;
395  uint64 lootMaster;
396  uint32 lootThreshold;
397  recv_data >> lootMethod >> lootMaster >> lootThreshold;
398 
400  Group* group = GetPlayer()->GetGroup();
401  if (!group)
402  return;
403 
404  if (!group->IsLeader(GetPlayer()->GetGUID()))
405  return;
406 
407  if (lootMethod > NEED_BEFORE_GREED)
408  return;
409 
410  if (lootThreshold < ITEM_QUALITY_UNCOMMON || lootThreshold > ITEM_QUALITY_ARTIFACT)
411  return;
412 
413  if (lootMethod == MASTER_LOOT && !group->IsMember(lootMaster))
414  return;
415  /********************/
416 
417  // everything's fine, do it
418  group->SetLootMethod((LootMethod)lootMethod);
419  group->SetMasterLooterGuid(lootMaster);
420  group->SetLootThreshold((ItemQualities)lootThreshold);
421  group->SendUpdate();
422 }
423 
425 {
426  if (!GetPlayer()->GetGroup())
427  return;
428 
429  uint64 Guid;
430  uint32 NumberOfPlayers;
431  uint8 Choice;
432  recv_data >> Guid; //guid of the item rolled
433  recv_data >> NumberOfPlayers;
434  recv_data >> Choice; //0: pass, 1: need, 2: greed
435 
436  //sLog.outDebug("WORLD RECIEVE CMSG_LOOT_ROLL, From:%u, Numberofplayers:%u, Choice:%u", (uint32)Guid, NumberOfPlayers, Choise);
437 
438  Group* group = GetPlayer()->GetGroup();
439  if (!group)
440  return;
441 
442  // everything's fine, do it
443  group->CountRollVote(GetPlayer()->GetGUID(), Guid, NumberOfPlayers, Choice);
444 }
445 
447 {
448  if (!GetPlayer()->GetGroup())
449  return;
450 
451  float x, y;
452  recv_data >> x;
453  recv_data >> y;
454 
455  //sLog.outDebug("Received opcode MSG_MINIMAP_PING X: %f, Y: %f", x, y);
456 
458  /********************/
459 
460  // everything's fine, do it
461  WorldPacket data(MSG_MINIMAP_PING, (8 + 4 + 4));
462  data << GetPlayer()->GetGUID();
463  data << x;
464  data << y;
465  GetPlayer()->GetGroup()->BroadcastPacket(&data, true, -1, GetPlayer()->GetGUID());
466 }
467 
469 {
470  uint32 minimum, maximum, roll;
471  recv_data >> minimum;
472  recv_data >> maximum;
473 
475  if (minimum > maximum || maximum > 10000) // < 32768 for urand call
476  return;
477  /********************/
478 
479  // everything's fine, do it
480  roll = urand(minimum, maximum);
481 
482  //sLog.outDebug("ROLL: MIN: %u, MAX: %u, ROLL: %u", minimum, maximum, roll);
483 
484  WorldPacket data(MSG_RANDOM_ROLL, 4 + 4 + 4 + 8);
485  data << minimum;
486  data << maximum;
487  data << roll;
488  data << GetPlayer()->GetGUID();
489  if (GetPlayer()->GetGroup())
490  GetPlayer()->GetGroup()->BroadcastPacket(&data, false);
491  else
492  SendPacket(&data);
493 }
494 
496 {
497  Group* group = GetPlayer()->GetGroup();
498  if (!group)
499  return;
500 
501  uint8 x;
502  recv_data >> x;
503 
505  /********************/
506 
507  // everything's fine, do it
508  if (x == 0xFF) // target icon request
509  group->SendTargetIconList(this);
510  else // target icon update
511  {
512  if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
513  return;
514 
515  uint64 guid;
516  recv_data >> guid;
517  group->SetTargetIcon(x, guid);
518  }
519 }
520 
522 {
523  Group* group = GetPlayer()->GetGroup();
524  if (!group)
525  return;
526 
527  if (_player->InBattleground())
528  return;
529 
531  if (!group->IsLeader(GetPlayer()->GetGUID()) || group->GetMembersCount() < 2)
532  return;
533  /********************/
534 
535  // everything's fine, do it (is it 0 (PARTY_OP_INVITE) correct code)
537  group->ConvertToRaid();
538 }
539 
541 {
542  // we will get correct pointer for group here, so we don't have to check if group is BG raid
543  Group* group = GetPlayer()->GetGroup();
544  if (!group)
545  return;
546 
547  std::string name;
548  uint8 groupNr;
549  recv_data >> name;
550  recv_data >> groupNr;
551 
553  if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
554  return;
555 
556  if (!group->HasFreeSlotSubGroup(groupNr))
557  return;
558  /********************/
559 
560  // everything's fine, do it
561  if (Player* player = sObjectMgr.GetPlayer(name.c_str()))
562  group->ChangeMembersGroup(player, groupNr);
563  else
564  group->ChangeMembersGroup(sObjectMgr.GetPlayerGUIDByName(name.c_str()), groupNr);
565 }
566 
568 {
569  Group* group = GetPlayer()->GetGroup();
570  if (!group)
571  return;
572 
573  uint64 guid;
574  uint8 flag;
575  recv_data >> guid;
576  recv_data >> flag;
577 
579  if (!group->IsLeader(GetPlayer()->GetGUID()))
580  return;
581  /********************/
582 
583  // everything's fine, do it
584  group->SetAssistant(guid, (flag == 0 ? false : true));
585 }
586 
588 {
589  Group* group = GetPlayer()->GetGroup();
590  if (!group)
591  return;
592 
593  uint8 role;
594  uint8 apply;
595  uint64 guid;
596  recv_data >> role >> apply; // role 0 = Main Tank, 1 = Main Assistant
597  recv_data >> guid;
598 
600  if (!group->IsLeader(GetPlayer()->GetGUID()))
601  return;
602  /********************/
603 
604  // everything's fine, do it
605  if (apply)
606  {
607  switch (role)
608  {
609  case 0: group->SetMainTank(guid); break;
610  case 1: group->SetMainAssistant(guid); break;
611  default: break;
612  }
613  }
614 }
615 
617 {
618  Group* group = GetPlayer()->GetGroup();
619  if (!group)
620  return;
621 
622  if (recv_data.empty()) // request
623  {
625  if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
626  return;
627  /********************/
628 
629  // everything's fine, do it
631  data << GetPlayer()->GetGUID();
632  group->BroadcastPacket(&data, false, -1);
633 
634  group->OfflineReadyCheck();
635  }
636  else // answer
637  {
638  uint8 state;
639  recv_data >> state;
640 
641  // everything's fine, do it
643  data << GetPlayer()->GetGUID();
644  data << state;
645  group->BroadcastReadyCheck(&data);
646  }
647 }
648 
650 {
651  //Group* group = GetPlayer()->GetGroup();
652  //if (!group)
653  // return;
654 
655  //if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
656  // return;
657 
658  // Is any reaction need?
659 }
660 
662 {
663  uint32 mask = player->GetGroupUpdateFlag();
664 
665  if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) // if update power type, update current/max power also
667 
668  if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) // same for pets
670 
671  uint32 byteCount = 0;
672  for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
673  if (mask & (1 << i))
674  byteCount += GroupUpdateLength[i];
675 
676  data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
677  *data << player->GetPackGUID();
678  *data << uint32(mask);
679 
680  if (mask & GROUP_UPDATE_FLAG_STATUS)
681  {
682  if (player)
683  {
684  uint16 flag;
685  if (player->IsPvP())
687  else
689 
690  if (sObjectMgr.GetRAFLinkStatus(_player, player) != RAF_LINK_NONE)
691  flag |= MEMBER_STATUS_RAF_BUDDY;
692 
693  *data << flag;
694  }
695  }
696 
697  if (mask & GROUP_UPDATE_FLAG_CUR_HP)
698  *data << (uint16) player->GetHealth();
699 
700  if (mask & GROUP_UPDATE_FLAG_MAX_HP)
701  *data << (uint16) player->GetMaxHealth();
702 
703  Powers powerType = player->getPowerType();
704  if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
705  *data << (uint8) powerType;
706 
707  if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
708  *data << (uint16) player->GetPower(powerType);
709 
710  if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
711  *data << (uint16) player->GetMaxPower(powerType);
712 
713  if (mask & GROUP_UPDATE_FLAG_LEVEL)
714  *data << (uint16) player->getLevel();
715 
716  if (mask & GROUP_UPDATE_FLAG_ZONE)
717  *data << (uint16) player->GetZoneId();
718 
719  if (mask & GROUP_UPDATE_FLAG_POSITION)
720  *data << (uint16) player->GetPositionX() << (uint16) player->GetPositionY();
721 
722  if (mask & GROUP_UPDATE_FLAG_AURAS)
723  {
724  uint64 auramask = player->GetAuraUpdateMask();
725  *data << uint64(auramask);
726  for (uint32 i = 0; i < MAX_AURAS; ++i)
727  {
728  if (auramask & (uint64(1) << i))
729  {
730  *data << uint16(player->GetUInt32Value(UNIT_FIELD_AURA + i));
731  *data << uint8(1);
732  }
733  }
734  }
735 
736  Pet* pet = player->GetPet();
737  if (mask & GROUP_UPDATE_FLAG_PET_GUID)
738  *data << uint64(pet ? pet->GetGUID() : 0);
739 
740  if (mask & GROUP_UPDATE_FLAG_PET_NAME)
741  {
742  if (pet)
743  *data << pet->GetName();
744  else
745  *data << (uint8) 0;
746  }
747 
749  {
750  if (pet)
751  *data << (uint16) pet->GetDisplayId();
752  else
753  *data << (uint16) 0;
754  }
755 
756  if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
757  {
758  if (pet)
759  *data << (uint16) pet->GetHealth();
760  else
761  *data << (uint16) 0;
762  }
763 
764  if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP)
765  {
766  if (pet)
767  *data << (uint16) pet->GetMaxHealth();
768  else
769  *data << (uint16) 0;
770  }
771 
772  if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE)
773  {
774  if (pet)
775  *data << (uint8) pet->getPowerType();
776  else
777  *data << (uint8) 0;
778  }
779 
781  {
782  if (pet)
783  *data << (uint16) pet->GetPower(pet->getPowerType());
784  else
785  *data << (uint16) 0;
786  }
787 
789  {
790  if (pet)
791  *data << (uint16) pet->GetMaxPower(pet->getPowerType());
792  else
793  *data << (uint16) 0;
794  }
795 
796  if (mask & GROUP_UPDATE_FLAG_PET_AURAS)
797  {
798  if (pet)
799  {
800  uint64 auramask = pet->GetAuraUpdateMask();
801  *data << uint64(auramask);
802  for (uint32 i = 0; i < MAX_AURAS; ++i)
803  {
804  if (auramask & (uint64(1) << i))
805  {
806  *data << uint16(pet->GetUInt32Value(UNIT_FIELD_AURA + i));
807  *data << uint8(1);
808  }
809  }
810  }
811  else
812  *data << (uint64) 0;
813  }
814 }
815 
816 /*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
818 {
819  sLog.outDebug("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
820  uint64 Guid;
821  recv_data >> Guid;
822 
823  Player* player = HashMapHolder<Player>::Find(Guid);
824  if (!player)
825  {
826  WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3 + 4 + 2);
827  data.appendPackGUID(Guid);
829  data << (uint16) MEMBER_STATUS_OFFLINE;
830  SendPacket(&data);
831  return;
832  }
833 
834  Pet* pet = player->GetPet();
835 
836  WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4 + 2 + 2 + 2 + 1 + 2 * 6 + 8 + 1 + 8);
837  data << player->GetPackGUID();
838 
839  uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
840  if (pet)
841  mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
842 
844  if (sObjectMgr.GetRAFLinkStatus(_player, player) != RAF_LINK_NONE)
845  flag |= MEMBER_STATUS_RAF_BUDDY;
846 
847  Powers powerType = player->getPowerType();
848  data << (uint32) mask1; // group update mask
849  data << (uint16) flag; // member's online status
850  data << (uint16) player->GetHealth(); // GROUP_UPDATE_FLAG_CUR_HP
851  data << (uint16) player->GetMaxHealth(); // GROUP_UPDATE_FLAG_MAX_HP
852  data << (uint8) powerType; // GROUP_UPDATE_FLAG_POWER_TYPE
853  data << (uint16) player->GetPower(powerType); // GROUP_UPDATE_FLAG_CUR_POWER
854  data << (uint16) player->GetMaxPower(powerType); // GROUP_UPDATE_FLAG_MAX_POWER
855  data << (uint16) player->getLevel(); // GROUP_UPDATE_FLAG_LEVEL
856 
857  // Validate location information
858  uint16 zoneId = 0;
859  uint16 locX = 0;
860  uint16 locY = 0;
861 
862  if (player->IsInWorld())
863  {
864  zoneId = player->GetZoneId();
865  locX = player->GetPositionX();
866  locY = player->GetPositionY();
867  }
868  else if (player->IsBeingTeleported()) // Player is in teleportation
869  {
870  WorldLocation& loc = player->GetTeleportDest(); // So take teleportation destination
872  locX = loc.m_positionX;
873  locY = loc.m_positionY;
874  }
875  else
876  {
877  // unknown player status.
878  }
879 
880  data << uint16(zoneId); // GROUP_UPDATE_FLAG_ZONE
881  data << uint16(locX); // GROUP_UPDATE_FLAG_POSITION
882  data << uint16(locY); // GROUP_UPDATE_FLAG_POSITION
883 
884  uint64 auramask = 0;
885  size_t maskPos = data.wpos();
886  data << (uint64) auramask; // placeholder
887  for (uint8 i = 0; i < MAX_AURAS; ++i)
888  {
889  if (uint32 aura = player->GetUInt32Value(UNIT_FIELD_AURA + i))
890  {
891  auramask |= (uint64(1) << i);
892  data << uint16(aura);
893  data << uint8(1);
894  }
895  }
896  data.put<uint64>(maskPos, auramask); // GROUP_UPDATE_FLAG_AURAS
897 
898  if (pet)
899  {
900  Powers petpowertype = pet->getPowerType();
901  data << (uint64) pet->GetGUID(); // GROUP_UPDATE_FLAG_PET_GUID
902  data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
903  data << (uint16) pet->GetDisplayId(); // GROUP_UPDATE_FLAG_PET_MODEL_ID
904  data << (uint16) pet->GetHealth(); // GROUP_UPDATE_FLAG_PET_CUR_HP
905  data << (uint16) pet->GetMaxHealth(); // GROUP_UPDATE_FLAG_PET_MAX_HP
906  data << (uint8) petpowertype; // GROUP_UPDATE_FLAG_PET_POWER_TYPE
907  data << (uint16) pet->GetPower(petpowertype); // GROUP_UPDATE_FLAG_PET_CUR_POWER
908  data << (uint16) pet->GetMaxPower(petpowertype); // GROUP_UPDATE_FLAG_PET_MAX_POWER
909 
910  uint64 petauramask = 0;
911  size_t petMaskPos = data.wpos();
912  data << (uint64) petauramask; // placeholder
913  for (uint8 i = 0; i < MAX_AURAS; ++i)
914  {
915  if (uint32 petaura = pet->GetUInt32Value(UNIT_FIELD_AURA + i))
916  {
917  petauramask |= (uint64(1) << i);
918  data << (uint16) petaura;
919  data << (uint8) 1;
920  }
921  }
922  data.put<uint64>(petMaskPos, petauramask); // GROUP_UPDATE_FLAG_PET_AURAS
923  }
924  else
925  {
926  data << (uint8) 0; // GROUP_UPDATE_FLAG_PET_NAME
927  data << (uint64) 0; // GROUP_UPDATE_FLAG_PET_AURAS
928  }
929 
930  SendPacket(&data);
931 
932  WorldPacket packet;
933  BuildPartyMemberStatsChangedPacket(player, &packet);
934  SendPacket(&packet);
935 }
936 
938 {
939  // every time the player checks the character screen
941 }
942 
943 /*void WorldSession::HandleGroupCancelOpcode(WorldPacket & recv_data)
944 {
945  sLog.outDebug("WORLD: got CMSG_GROUP_CANCEL.");
946 }*/
947 
949 {
950  sLog.outDebug("WORLD: Received CMSG_GROUP_PASS_ON_LOOT");
951 
952  uint32 passOnLoot;
953  recv_data >> passOnLoot; // 1 always pass, 0 do not pass
954 
955  // ignore if player not loaded
956  if (!GetPlayer()) // needed because STATUS_AUTHED
957  {
958  if (passOnLoot != 0)
959  sLog.outError("CMSG_OPT_OUT_OF_LOOT value<>0 for not-loaded character!");
960  return;
961  }
962 
963  GetPlayer()->SetPassOnGroupLoot(passOnLoot);
964 }
965 
void HandleGroupInviteOpcode(WorldPacket &recvPacket)
Group * GetGroup()
Definition: Player.h:2589
s is already in group.
Definition: WorldSession.h:56
Your party is full.
Definition: WorldSession.h:55
void SetTargetIcon(uint8 id, uint64 guid)
Definition: Group.cpp:884
void SetLootThreshold(ItemQualities threshold)
Definition: Group.h:199
void HandleGroupPromoteOpcode(WorldPacket &recv_data)
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:228
void SendRaidInfo()
Definition: Player.cpp:15918
uint32 GetMaxHealth() const
Definition: Unit.h:1052
uint32 GetZoneId(uint32 mapid, float x, float y, float z)
Definition: MapManager.h:56
void BroadcastReadyCheck(WorldPacket *packet)
Definition: Group.cpp:1040
float m_positionY
Definition: Position.h:51
void RemoveAllInvites()
Definition: Group.cpp:254
void BroadcastGroupUpdate(void)
Definition: Group.cpp:1681
You are not the party leader.
Definition: WorldSession.h:58
bool HasIgnore(uint32 ignore_guid)
Definition: SocialMgr.cpp:162
bool IsPvP() const
Definition: Unit.h:1140
uint32 GetGroupUpdateFlag()
Definition: Player.h:2606
uint32 GetZoneId() const
Definition: Object.cpp:1176
void BroadcastPacket(WorldPacket *packet, bool ignorePlayersInBGRaid, int group=-1, uint64 ignore=0)
Definition: Group.cpp:1027
void SetLootMethod(LootMethod method)
Definition: Group.h:189
is not in your instance.
Definition: WorldSession.h:54
#define sLog
Log class singleton.
Definition: Log.h:187
void ChangeLeader(const uint64 &guid)
Definition: Group.cpp:363
void HandleRaidConvertOpcode(WorldPacket &recv_data)
static T * Find(uint64 guid)
bool IsAssistant(uint64 guid) const
Definition: Group.h:264
void ChangeMembersGroup(const uint64 &guid, const uint8 &group)
Definition: Group.cpp:1333
bool IsMember(const uint64 &guid) const
Definition: Group.h:247
float m_positionX
Definition: Position.h:50
void HandleGroupUninviteGuidOpcode(WorldPacket &recvPacket)
void Initialize(uint16 opcode, size_t newres=200)
Definition: WorldPacket.h:37
void HandleRandomRollOpcode(WorldPacket &recv_data)
bool IsGameMaster() const
Definition: Player.h:1009
Player * GetPlayer() const
Definition: WorldSession.h:104
static void RemoveFromGroup(Group *group, uint64 guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker=0, const char *reason=NULL)
Definition: Player.cpp:2419
const char * GetLeaderName() const
Definition: Group.h:226
DungeonDifficulty GetDifficulty()
Definition: Player.h:1884
void apply(T *val)
Definition: ByteConverter.h:41
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
void HandleLootMethodOpcode(WorldPacket &recvPacket)
uint32 GetPower(Powers power) const
Definition: Unit.h:1076
bool IsBeingTeleported() const
Definition: Player.h:2050
bool AddMember(const uint64 &guid, const char *name)
Definition: Group.cpp:282
s is not in your party.
Definition: WorldSession.h:53
void BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
bool IsFull() const
Definition: Group.h:206
Powers getPowerType() const
Definition: Unit.h:1071
size_t wpos() const
Definition: ByteBuffer.h:264
uint32 m_mapId
Definition: Object.h:590
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:225
void HandleRequestPartyMemberStatsOpcode(WorldPacket &recv_data)
bool IsCreated() const
Definition: Group.h:218
void CountRollVote(const uint64 &playerGUID, const uint64 &Guid, uint32 NumberOfPlayers, uint8 Choise)
Definition: Group.cpp:719
ACE_UINT8 uint8
Definition: Define.h:73
Powers
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1080
uint32 GetDisplayId()
Definition: Unit.h:1891
PlayerSocial * GetSocial()
Definition: Player.h:985
void HandleGroupAcceptOpcode(WorldPacket &recvPacket)
const bool & IsInWorld() const
Definition: Object.h:129
bool IsLeader(const uint64 &guid) const
Definition: Group.h:251
void HandleGroupDeclineOpcode(WorldPacket &recvPacket)
Target is unfriendly.
Definition: WorldSession.h:59
void SetMainAssistant(uint64 guid)
Definition: Group.h:350
Group * GetGroupInvite()
Definition: Player.h:2581
void SendPartyResult(PartyOperation operation, const std::string &member, PartyResult res)
bool empty() const
Definition: ByteBuffer.h:340
uint64 GetAuraUpdateMask()
Definition: Pet.h:268
void HandleMinimapPingOpcode(WorldPacket &recv_data)
float GetPositionY() const
Definition: Position.h:98
void HandleGroupChangeSubGroupOpcode(WorldPacket &recv_data)
void put(size_t pos, T value)
Definition: ByteBuffer.h:79
void OfflineReadyCheck()
Definition: Group.cpp:1051
uint32 GetInstanceId() const
Definition: Object.h:682
void HandleGroupPassOnLootOpcode(WorldPacket &recv_data)
uint64 GetMemberGUID(const std::string &name)
Definition: Group.h:255
bool isBGGroup() const
Definition: Group.h:214
void SendTargetIconList(WorldSession *session)
Definition: Group.cpp:929
PackedGuid const & GetPackGUID() const
Definition: Object.h:172
void SetPassOnGroupLoot(bool bPassOnGroupLoot)
Definition: Player.h:2646
uint32 GetMapId() const
Definition: Object.h:585
float m_positionZ
Definition: Position.h:52
void HandleRaidReadyCheckOpcode(WorldPacket &recv_data)
void HandleRequestRaidInfoOpcode(WorldPacket &recv_data)
bool HasFreeSlotSubGroup(uint8 subgroup) const
Definition: Group.h:293
void SetAssistant(uint64 guid, const bool &state)
Definition: Group.h:335
uint32 RemoveInvite(Player *player)
Definition: Group.cpp:246
#define GROUP_UPDATE_FLAGS_COUNT
Definition: Group.h:106
void appendPackGUID(uint64 guid)
Definition: ByteBuffer.h:402
const char * GetName() const
Definition: Object.h:692
ACE_UINT64 uint64
Definition: Define.h:70
ItemQualities
bool InBattleground() const
Definition: Player.h:2207
const uint64 & GetLeaderGUID() const
Definition: Group.h:222
Group * GetOriginalGroup()
Definition: Player.h:2632
Player * _player
Definition: WorldSession.h:729
Cannot find player "%s".
Definition: WorldSession.h:52
bool Create(const uint64 &guid, const char *name)
Definition: Group.cpp:82
uint32 GetMembersCount() const
Definition: Group.h:309
void SetMainTank(uint64 guid)
Definition: Group.h:342
void HandleGroupLeaveOpcode(WorldPacket &recvPacket)
ok, silent
Definition: WorldSession.h:51
Player * GetInvited(const uint64 &guid) const
Definition: Group.cpp:262
PartyResult
Definition: WorldSession.h:49
LootMethod
Definition: LootMgr.h:34
PartyResult CanUninviteFromGroup() const
Definition: Player.cpp:20162
uint64 GetAuraUpdateMask()
Definition: Player.h:2614
uint32 GetTeam() const
Definition: Player.h:2075
Trial accounts cannot invite characters into groups.
Definition: WorldSession.h:62
void HandleRaidReadyCheckFinishOpcode(WorldPacket &recv_data)
void HandleLootRoll(WorldPacket &recv_data)
PartyOperation
Definition: WorldSession.h:43
void ConvertToRaid()
Definition: Group.cpp:203
WorldSession * GetSession() const
Definition: Player.h:1959
void HandleGroupSetLeaderOpcode(WorldPacket &recvPacket)
#define sWorld
Definition: World.h:860
void HandleGroupUninviteNameOpcode(WorldPacket &recvPacket)
void HandleRaidIconTargetOpcode(WorldPacket &recv_data)
ACE_UINT16 uint16
Definition: Define.h:72
bool AddLeaderInvite(Player *player)
Definition: Group.cpp:236
ACE_UINT32 uint32
Definition: Define.h:71
#define MAX_AURAS
float GetPositionX() const
Definition: Position.h:97
uint32 GetHealth() const
Definition: Unit.h:1051
Pet * GetPet() const
Definition: Player.cpp:17104
WorldLocation & GetTeleportDest()
Definition: Player.h:2046
void UninviteFromGroup()
Definition: Player.cpp:2397
uint32 getLevel() const
Definition: Unit.h:1029
bool AddInvite(Player *player, bool leader)
Definition: Group.cpp:214
Definition: Player.h:922
void SendUpdate()
Definition: Group.cpp:949
Definition: Pet.h:146
void HandleGroupAssistantOpcode(WorldPacket &recv_data)
Definition: Group.h:154
uint32 urand(uint32 min, uint32 max)
Definition: Util.cpp:71
void SetMasterLooterGuid(uint64 guid)
Definition: Group.h:197
const uint64 & GetGUID() const
Definition: Object.h:156