[9581] Fixed apply damage reduction to melee/ranged damage.
[getmangos.git] / src / game / GroupHandler.cpp
blobe52a8559098388a0217a54b34d58e727287ec90f
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Common.h"
20 #include "Database/DatabaseEnv.h"
21 #include "Opcodes.h"
22 #include "Log.h"
23 #include "WorldPacket.h"
24 #include "WorldSession.h"
25 #include "World.h"
26 #include "ObjectMgr.h"
27 #include "Player.h"
28 #include "Group.h"
29 #include "SocialMgr.h"
30 #include "Util.h"
32 /* differeces from off:
33 -you can uninvite yourself - is is useful
34 -you can accept invitation even if leader went offline
36 /* todo:
37 -group_destroyed msg is sent but not shown
38 -reduce xp gaining when in raid group
39 -quest sharing has to be corrected
40 -FIX sending PartyMemberStats
43 void WorldSession::SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res)
45 WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (8+member.size()+1));
46 data << (uint32)operation;
47 data << member;
48 data << (uint32)res;
50 SendPacket( &data );
53 void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
55 std::string membername;
56 recv_data >> membername;
57 recv_data.read_skip<uint32>(); // 0 for all known invite ways
59 // attempt add selected player
61 // cheating
62 if(!normalizePlayerName(membername))
64 SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET);
65 return;
68 Player *player = sObjectMgr.GetPlayer(membername.c_str());
70 // no player
71 if(!player)
73 SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET);
74 return;
77 // can't group with
78 if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam())
80 SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_UNFRIENDLY);
81 return;
83 if(GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId())
85 SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_NOT_IN_YOUR_INSTANCE);
86 return;
88 // just ignore us
89 if(player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
91 SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_IGNORE_YOU);
92 return;
95 Group *group = GetPlayer()->GetGroup();
96 if( group && group->isBGGroup() )
97 group = GetPlayer()->GetOriginalGroup();
99 Group *group2 = player->GetGroup();
100 if( group2 && group2->isBGGroup() )
101 group2 = player->GetOriginalGroup();
102 // player already in another group or invited
103 if( group2 || player->GetGroupInvite() )
105 SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_ALREADY_IN_GROUP);
106 return;
109 if(group)
111 // not have permissions for invite
112 if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
114 SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_YOU_NOT_LEADER);
115 return;
117 // not have place
118 if(group->IsFull())
120 SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL);
121 return;
125 // ok, but group not exist, start a new group
126 // but don't create and save the group to the DB until
127 // at least one person joins
128 if(!group)
130 group = new Group;
131 // new group: if can't add then delete
132 if(!group->AddLeaderInvite(GetPlayer()))
134 delete group;
135 return;
137 if(!group->AddInvite(player))
139 delete group;
140 return;
143 else
145 // already existed group: if can't add then just leave
146 if(!group->AddInvite(player))
148 return;
152 // ok, we do it
153 WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size
154 data << uint8(1); // ok
155 data << GetPlayer()->GetName();
156 player->GetSession()->SendPacket(&data);
158 SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_OK);
161 void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
163 recv_data.read_skip<uint32>(); // value received in WorldSession::HandleGroupInviteOpcode and also skipeed currently?
165 Group *group = GetPlayer()->GetGroupInvite();
166 if (!group) return;
168 if(group->GetLeaderGUID() == GetPlayer()->GetGUID())
170 sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
171 return;
174 // remove in from ivites in any case
175 group->RemoveInvite(GetPlayer());
177 /** error handling **/
178 /********************/
180 // not have place
181 if(group->IsFull())
183 SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL);
184 return;
187 Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGUID());
189 // forming a new group, create it
190 if(!group->IsCreated())
192 if (leader)
193 group->RemoveInvite(leader);
194 if (group->Create(group->GetLeaderGUID(), group->GetLeaderName()))
195 sObjectMgr.AddGroup(group);
196 else
197 return;
200 // everything's fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
201 if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
202 return;
206 void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ )
208 Group *group = GetPlayer()->GetGroupInvite();
209 if (!group)
210 return;
212 // remember leader if online
213 Player *leader = sObjectMgr.GetPlayer(group->GetLeaderGUID());
215 // uninvite, group can be deleted
216 GetPlayer()->UninviteFromGroup();
218 if(!leader || !leader->GetSession())
219 return;
221 // report
222 WorldPacket data( SMSG_GROUP_DECLINE, 10 ); // guess size
223 data << GetPlayer()->GetName();
224 leader->GetSession()->SendPacket( &data );
227 void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data)
229 uint64 guid;
230 recv_data >> guid;
232 //can't uninvite yourself
233 if(guid == GetPlayer()->GetGUID())
235 sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
236 return;
239 PartyResult res = GetPlayer()->CanUninviteFromGroup();
240 if(res != PARTY_RESULT_OK)
242 SendPartyResult(PARTY_OP_LEAVE, "", res);
243 return;
246 Group* grp = GetPlayer()->GetGroup();
247 if(!grp)
248 return;
250 if(grp->IsMember(guid))
252 Player::RemoveFromGroup(grp,guid);
253 return;
256 if(Player* plr = grp->GetInvited(guid))
258 plr->UninviteFromGroup();
259 return;
262 SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_NOT_IN_YOUR_PARTY);
265 void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data)
267 std::string membername;
268 recv_data >> membername;
270 // player not found
271 if(!normalizePlayerName(membername))
272 return;
274 // can't uninvite yourself
275 if(GetPlayer()->GetName() == membername)
277 sLog.outError("WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
278 return;
281 PartyResult res = GetPlayer()->CanUninviteFromGroup();
282 if(res != PARTY_RESULT_OK)
284 SendPartyResult(PARTY_OP_LEAVE, "", res);
285 return;
288 Group* grp = GetPlayer()->GetGroup();
289 if(!grp)
290 return;
292 if(uint64 guid = grp->GetMemberGUID(membername))
294 Player::RemoveFromGroup(grp,guid);
295 return;
298 if(Player* plr = grp->GetInvited(membername))
300 plr->UninviteFromGroup();
301 return;
304 SendPartyResult(PARTY_OP_LEAVE, membername, PARTY_RESULT_NOT_IN_YOUR_PARTY);
307 void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data )
309 uint64 guid;
310 recv_data >> guid;
312 Group *group = GetPlayer()->GetGroup();
313 if(!group)
314 return;
316 Player *player = sObjectMgr.GetPlayer(guid);
318 /** error handling **/
319 if (!player || !group->IsLeader(GetPlayer()->GetGUID()) || player->GetGroup() != group)
320 return;
321 /********************/
323 // everything's fine, do it
324 group->ChangeLeader(guid);
327 void WorldSession::HandleGroupDisbandOpcode( WorldPacket & /*recv_data*/ )
329 if(!GetPlayer()->GetGroup())
330 return;
332 if(_player->InBattleGround())
334 SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED);
335 return;
338 /** error handling **/
339 /********************/
341 // everything's fine, do it
342 SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), PARTY_RESULT_OK);
344 GetPlayer()->RemoveFromGroup();
347 void WorldSession::HandleLootMethodOpcode( WorldPacket & recv_data )
349 uint32 lootMethod;
350 uint64 lootMaster;
351 uint32 lootThreshold;
352 recv_data >> lootMethod >> lootMaster >> lootThreshold;
354 Group *group = GetPlayer()->GetGroup();
355 if(!group)
356 return;
358 /** error handling **/
359 if(!group->IsLeader(GetPlayer()->GetGUID()))
360 return;
361 /********************/
363 // everything's fine, do it
364 group->SetLootMethod((LootMethod)lootMethod);
365 group->SetLooterGuid(lootMaster);
366 group->SetLootThreshold((ItemQualities)lootThreshold);
367 group->SendUpdate();
370 void WorldSession::HandleLootRoll( WorldPacket &recv_data )
372 uint64 Guid;
373 uint32 NumberOfPlayers;
374 uint8 rollType;
375 recv_data >> Guid; //guid of the item rolled
376 recv_data >> NumberOfPlayers;
377 recv_data >> rollType;
379 //sLog.outDebug("WORLD RECIEVE CMSG_LOOT_ROLL, From:%u, Numberofplayers:%u, rollType:%u", (uint32)Guid, NumberOfPlayers, rollType);
381 Group* group = GetPlayer()->GetGroup();
382 if(!group)
383 return;
385 // everything's fine, do it
386 group->CountRollVote(GetPlayer()->GetGUID(), Guid, NumberOfPlayers, rollType);
388 switch (rollType)
390 case ROLL_NEED:
391 GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED, 1);
392 break;
393 case ROLL_GREED:
394 GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED, 1);
395 break;
399 void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data)
401 float x, y;
402 recv_data >> x;
403 recv_data >> y;
405 if(!GetPlayer()->GetGroup())
406 return;
408 //sLog.outDebug("Received opcode MSG_MINIMAP_PING X: %f, Y: %f", x, y);
410 /** error handling **/
411 /********************/
413 // everything is fine, do it
414 WorldPacket data(MSG_MINIMAP_PING, (8+4+4));
415 data << uint64(GetPlayer()->GetGUID());
416 data << float(x);
417 data << float(y);
418 GetPlayer()->GetGroup()->BroadcastPacket(&data, true, -1, GetPlayer()->GetGUID());
421 void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data)
423 uint32 minimum, maximum, roll;
424 recv_data >> minimum;
425 recv_data >> maximum;
427 /** error handling **/
428 if(minimum > maximum || maximum > 10000) // < 32768 for urand call
429 return;
430 /********************/
432 // everything's fine, do it
433 roll = urand(minimum, maximum);
435 //sLog.outDebug("ROLL: MIN: %u, MAX: %u, ROLL: %u", minimum, maximum, roll);
437 WorldPacket data(MSG_RANDOM_ROLL, 4+4+4+8);
438 data << uint32(minimum);
439 data << uint32(maximum);
440 data << uint32(roll);
441 data << uint64(GetPlayer()->GetGUID());
442 if(GetPlayer()->GetGroup())
443 GetPlayer()->GetGroup()->BroadcastPacket(&data, false);
444 else
445 SendPacket(&data);
448 void WorldSession::HandleRaidTargetUpdateOpcode( WorldPacket & recv_data )
450 uint8 x;
451 recv_data >> x;
453 Group *group = GetPlayer()->GetGroup();
454 if(!group)
455 return;
457 /** error handling **/
458 /********************/
460 // everything's fine, do it
461 if(x == 0xFF) // target icon request
463 group->SendTargetIconList(this);
465 else // target icon update
467 if(group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
468 return;
470 uint64 guid;
471 recv_data >> guid;
472 group->SetTargetIcon(x, _player->GetGUID(), guid);
476 void WorldSession::HandleGroupRaidConvertOpcode( WorldPacket & /*recv_data*/ )
478 Group *group = GetPlayer()->GetGroup();
479 if(!group)
480 return;
482 if(_player->InBattleGround())
483 return;
485 /** error handling **/
486 if(!group->IsLeader(GetPlayer()->GetGUID()) || group->GetMembersCount() < 2)
487 return;
488 /********************/
490 // everything's fine, do it (is it 0 (PARTY_OP_INVITE) correct code)
491 SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_OK);
492 group->ConvertToRaid();
495 void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data )
497 std::string name;
498 uint8 groupNr;
499 recv_data >> name;
501 recv_data >> groupNr;
503 // we will get correct pointer for group here, so we don't have to check if group is BG raid
504 Group *group = GetPlayer()->GetGroup();
505 if(!group)
506 return;
508 /** error handling **/
509 if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
510 return;
512 if (!group->HasFreeSlotSubGroup(groupNr))
513 return;
514 /********************/
516 // everything's fine, do it
517 group->ChangeMembersGroup(sObjectMgr.GetPlayer(name.c_str()), groupNr);
520 void WorldSession::HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data )
522 uint64 guid;
523 uint8 flag;
524 recv_data >> guid;
525 recv_data >> flag;
527 Group *group = GetPlayer()->GetGroup();
528 if(!group)
529 return;
531 /** error handling **/
532 if(!group->IsLeader(GetPlayer()->GetGUID()))
533 return;
534 /********************/
536 // everything's fine, do it
537 group->SetAssistant(guid, (flag==0?false:true));
540 void WorldSession::HandlePartyAssignmentOpcode( WorldPacket & recv_data )
542 uint8 flag1, flag2;
543 uint64 guid;
544 recv_data >> flag1 >> flag2;
545 recv_data >> guid;
547 sLog.outDebug("MSG_PARTY_ASSIGNMENT");
549 Group *group = GetPlayer()->GetGroup();
550 if(!group)
551 return;
553 // if(flag1) Main Assist
554 // 0x4
555 // if(flag2) Main Tank
556 // 0x2
558 /** error handling **/
559 if(!group->IsLeader(GetPlayer()->GetGUID()))
560 return;
561 /********************/
563 // everything's fine, do it
564 if(flag1 == 1)
565 group->SetMainAssistant(guid);
566 if(flag2 == 1)
567 group->SetMainTank(guid);
570 void WorldSession::HandleRaidReadyCheckOpcode( WorldPacket & recv_data )
572 if(recv_data.empty()) // request
574 Group *group = GetPlayer()->GetGroup();
575 if(!group)
576 return;
578 /** error handling **/
579 if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
580 return;
581 /********************/
583 // everything's fine, do it
584 WorldPacket data(MSG_RAID_READY_CHECK, 8);
585 data << GetPlayer()->GetGUID();
586 group->BroadcastPacket(&data, false, -1);
588 group->OfflineReadyCheck();
590 else // answer
592 uint8 state;
593 recv_data >> state;
595 Group *group = GetPlayer()->GetGroup();
596 if(!group)
597 return;
599 // everything's fine, do it
600 WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9);
601 data << GetPlayer()->GetGUID();
602 data << state;
603 group->BroadcastReadyCheck(&data);
607 void WorldSession::HandleRaidReadyCheckFinishedOpcode( WorldPacket & /*recv_data*/ )
609 //Group* group = GetPlayer()->GetGroup();
610 //if(!group)
611 // return;
613 //if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
614 // return;
616 // Is any reaction need?
619 void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
621 uint32 mask = player->GetGroupUpdateFlag();
623 if (mask == GROUP_UPDATE_FLAG_NONE)
624 return;
626 if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) // if update power type, update current/max power also
627 mask |= (GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER);
629 if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) // same for pets
630 mask |= (GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER);
632 uint32 byteCount = 0;
633 for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
634 if (mask & (1 << i))
635 byteCount += GroupUpdateLength[i];
637 data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
638 *data << player->GetPackGUID();
639 *data << (uint32) mask;
641 if (mask & GROUP_UPDATE_FLAG_STATUS)
643 if (player)
645 if (player->IsPvP())
646 *data << (uint16) (MEMBER_STATUS_ONLINE | MEMBER_STATUS_PVP);
647 else
648 *data << (uint16) MEMBER_STATUS_ONLINE;
650 else
651 *data << (uint16) MEMBER_STATUS_OFFLINE;
654 if (mask & GROUP_UPDATE_FLAG_CUR_HP)
655 *data << (uint32) player->GetHealth();
657 if (mask & GROUP_UPDATE_FLAG_MAX_HP)
658 *data << (uint32) player->GetMaxHealth();
660 Powers powerType = player->getPowerType();
661 if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
662 *data << (uint8) powerType;
664 if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
665 *data << (uint16) player->GetPower(powerType);
667 if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
668 *data << (uint16) player->GetMaxPower(powerType);
670 if (mask & GROUP_UPDATE_FLAG_LEVEL)
671 *data << (uint16) player->getLevel();
673 if (mask & GROUP_UPDATE_FLAG_ZONE)
674 *data << (uint16) player->GetZoneId();
676 if (mask & GROUP_UPDATE_FLAG_POSITION)
677 *data << (uint16) player->GetPositionX() << (uint16) player->GetPositionY();
679 if (mask & GROUP_UPDATE_FLAG_AURAS)
681 const uint64& auramask = player->GetAuraUpdateMask();
682 *data << uint64(auramask);
683 for(uint32 i = 0; i < MAX_AURAS; ++i)
685 if(auramask & (uint64(1) << i))
687 *data << uint32(player->GetVisibleAura(i));
688 *data << uint8(1);
693 Pet *pet = player->GetPet();
694 if (mask & GROUP_UPDATE_FLAG_PET_GUID)
696 if(pet)
697 *data << (uint64) pet->GetGUID();
698 else
699 *data << (uint64) 0;
702 if (mask & GROUP_UPDATE_FLAG_PET_NAME)
704 if(pet)
705 *data << pet->GetName();
706 else
707 *data << (uint8) 0;
710 if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
712 if(pet)
713 *data << (uint16) pet->GetDisplayId();
714 else
715 *data << (uint16) 0;
718 if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
720 if(pet)
721 *data << (uint32) pet->GetHealth();
722 else
723 *data << (uint32) 0;
726 if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP)
728 if(pet)
729 *data << (uint32) pet->GetMaxHealth();
730 else
731 *data << (uint32) 0;
734 if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE)
736 if(pet)
737 *data << (uint8) pet->getPowerType();
738 else
739 *data << (uint8) 0;
742 if (mask & GROUP_UPDATE_FLAG_PET_CUR_POWER)
744 if(pet)
745 *data << (uint16) pet->GetPower(pet->getPowerType());
746 else
747 *data << (uint16) 0;
750 if (mask & GROUP_UPDATE_FLAG_PET_MAX_POWER)
752 if(pet)
753 *data << (uint16) pet->GetMaxPower(pet->getPowerType());
754 else
755 *data << (uint16) 0;
758 if (mask & GROUP_UPDATE_FLAG_PET_AURAS)
760 if(pet)
762 const uint64& auramask = pet->GetAuraUpdateMask();
763 *data << uint64(auramask);
764 for(uint32 i = 0; i < MAX_AURAS; ++i)
766 if(auramask & (uint64(1) << i))
768 *data << uint32(pet->GetVisibleAura(i));
769 *data << uint8(1);
773 else
774 *data << (uint64) 0;
778 /*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
779 void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
781 sLog.outDebug("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
782 uint64 Guid;
783 recv_data >> Guid;
785 Player *player = sObjectMgr.GetPlayer(Guid);
786 if(!player)
788 WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
789 data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
790 data.appendPackGUID(Guid);
791 data << (uint32) GROUP_UPDATE_FLAG_STATUS;
792 data << (uint16) MEMBER_STATUS_OFFLINE;
793 SendPacket(&data);
794 return;
797 Pet *pet = player->GetPet();
799 WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
800 data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
801 data << player->GetPackGUID();
803 uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
804 if(pet)
805 mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
807 Powers powerType = player->getPowerType();
808 data << (uint32) mask1; // group update mask
809 data << (uint16) MEMBER_STATUS_ONLINE; // member's online status
810 data << (uint32) player->GetHealth(); // GROUP_UPDATE_FLAG_CUR_HP
811 data << (uint32) player->GetMaxHealth(); // GROUP_UPDATE_FLAG_MAX_HP
812 data << (uint8) powerType; // GROUP_UPDATE_FLAG_POWER_TYPE
813 data << (uint16) player->GetPower(powerType); // GROUP_UPDATE_FLAG_CUR_POWER
814 data << (uint16) player->GetMaxPower(powerType); // GROUP_UPDATE_FLAG_MAX_POWER
815 data << (uint16) player->getLevel(); // GROUP_UPDATE_FLAG_LEVEL
816 data << (uint16) player->GetZoneId(); // GROUP_UPDATE_FLAG_ZONE
817 data << (uint16) player->GetPositionX(); // GROUP_UPDATE_FLAG_POSITION
818 data << (uint16) player->GetPositionY(); // GROUP_UPDATE_FLAG_POSITION
820 uint64 auramask = 0;
821 size_t maskPos = data.wpos();
822 data << (uint64) auramask; // placeholder
823 for(uint8 i = 0; i < MAX_AURAS; ++i)
825 if(uint32 aura = player->GetVisibleAura(i))
827 auramask |= (uint64(1) << i);
828 data << (uint32) aura;
829 data << (uint8) 1;
832 data.put<uint64>(maskPos,auramask); // GROUP_UPDATE_FLAG_AURAS
834 if(pet)
836 Powers petpowertype = pet->getPowerType();
837 data << (uint64) pet->GetGUID(); // GROUP_UPDATE_FLAG_PET_GUID
838 data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
839 data << (uint16) pet->GetDisplayId(); // GROUP_UPDATE_FLAG_PET_MODEL_ID
840 data << (uint32) pet->GetHealth(); // GROUP_UPDATE_FLAG_PET_CUR_HP
841 data << (uint32) pet->GetMaxHealth(); // GROUP_UPDATE_FLAG_PET_MAX_HP
842 data << (uint8) petpowertype; // GROUP_UPDATE_FLAG_PET_POWER_TYPE
843 data << (uint16) pet->GetPower(petpowertype); // GROUP_UPDATE_FLAG_PET_CUR_POWER
844 data << (uint16) pet->GetMaxPower(petpowertype); // GROUP_UPDATE_FLAG_PET_MAX_POWER
846 uint64 petauramask = 0;
847 size_t petMaskPos = data.wpos();
848 data << (uint64) petauramask; // placeholder
849 for(uint8 i = 0; i < MAX_AURAS; ++i)
851 if(uint32 petaura = pet->GetVisibleAura(i))
853 petauramask |= (uint64(1) << i);
854 data << (uint32) petaura;
855 data << (uint8) 1;
858 data.put<uint64>(petMaskPos,petauramask); // GROUP_UPDATE_FLAG_PET_AURAS
860 else
862 data << (uint8) 0; // GROUP_UPDATE_FLAG_PET_NAME
863 data << (uint64) 0; // GROUP_UPDATE_FLAG_PET_AURAS
866 SendPacket(&data);
869 /*!*/void WorldSession::HandleRequestRaidInfoOpcode( WorldPacket & /*recv_data*/ )
871 // every time the player checks the character screen
872 _player->SendRaidInfo();
875 void WorldSession::HandleOptOutOfLootOpcode( WorldPacket & recv_data )
877 sLog.outDebug("WORLD: Received CMSG_OPT_OUT_OF_LOOT");
879 uint32 unkn;
880 recv_data >> unkn;
882 // ignore if player not loaded
883 if(!GetPlayer()) // needed because STATUS_AUTHED
885 if(unkn!=0)
886 sLog.outError("CMSG_GROUP_PASS_ON_LOOT value<>0 for not-loaded character!");
887 return;
890 if(unkn!=0)
891 sLog.outError("CMSG_GROUP_PASS_ON_LOOT: activation not implemented!");