2525#include " MiscPackets.h"
2626#include " ObjectAccessor.h"
2727#include " ObjectMgr.h"
28+ #include " PartyPackets.h"
2829#include " Pet.h"
2930#include " Player.h"
3031#include " SocialMgr.h"
@@ -58,74 +59,70 @@ void WorldSession::SendPartyResult(PartyOperation operation, const std::string&
5859 SendPacket (&data);
5960}
6061
61- void WorldSession::HandleGroupInviteOpcode (WorldPacket& recvData )
62+ void WorldSession::HandleGroupInviteOpcode (WorldPackets::Party::PartyInviteClient& packet )
6263{
6364 TC_LOG_DEBUG (" network" , " WORLD: Received CMSG_GROUP_INVITE" );
6465
65- std::string membername;
66- recvData >> membername;
67- recvData.read_skip <uint32>();
68-
6966 // attempt add selected player
7067
7168 // cheating
72- if (!normalizePlayerName (membername ))
69+ if (!normalizePlayerName (packet. TargetName ))
7370 {
74- SendPartyResult (PARTY_OP_INVITE, membername , ERR_BAD_PLAYER_NAME_S);
71+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_BAD_PLAYER_NAME_S);
7572 return ;
7673 }
7774
7875 Player* invitingPlayer = GetPlayer ();
79- Player* invitedPlayer = ObjectAccessor::FindPlayerByName (membername );
76+ Player* invitedPlayer = ObjectAccessor::FindPlayerByName (packet. TargetName );
8077
8178 // no player
8279 if (!invitedPlayer)
8380 {
84- SendPartyResult (PARTY_OP_INVITE, membername , ERR_BAD_PLAYER_NAME_S);
81+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_BAD_PLAYER_NAME_S);
8582 return ;
8683 }
8784
8885 // player trying to invite himself (most likely cheating)
8986 if (invitedPlayer == invitingPlayer)
9087 {
91- SendPartyResult (PARTY_OP_INVITE, membername , ERR_BAD_PLAYER_NAME_S);
88+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_BAD_PLAYER_NAME_S);
9289 return ;
9390 }
9491
9592 // restrict invite to GMs
9693 if (!sWorld ->getBoolConfig (CONFIG_ALLOW_GM_GROUP) && !invitingPlayer->IsGameMaster () && invitedPlayer->IsGameMaster ())
9794 {
98- SendPartyResult (PARTY_OP_INVITE, membername , ERR_BAD_PLAYER_NAME_S);
95+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_BAD_PLAYER_NAME_S);
9996 return ;
10097 }
10198
10299 // can't group with
103100 if (!invitingPlayer->IsGameMaster () && !sWorld ->getBoolConfig (CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && invitingPlayer->GetTeam () != invitedPlayer->GetTeam ())
104101 {
105- SendPartyResult (PARTY_OP_INVITE, membername , ERR_PLAYER_WRONG_FACTION);
102+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_PLAYER_WRONG_FACTION);
106103 return ;
107104 }
108105 if (invitingPlayer->GetInstanceId () != 0 && invitedPlayer->GetInstanceId () != 0 && invitingPlayer->GetInstanceId () != invitedPlayer->GetInstanceId () && invitingPlayer->GetMapId () == invitedPlayer->GetMapId ())
109106 {
110- SendPartyResult (PARTY_OP_INVITE, membername , ERR_TARGET_NOT_IN_INSTANCE_S);
107+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_TARGET_NOT_IN_INSTANCE_S);
111108 return ;
112109 }
113110 // just ignore us
114111 if (invitedPlayer->GetInstanceId () != 0 && invitedPlayer->GetDungeonDifficulty () != invitingPlayer->GetDungeonDifficulty ())
115112 {
116- SendPartyResult (PARTY_OP_INVITE, membername , ERR_IGNORING_YOU_S);
113+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_IGNORING_YOU_S);
117114 return ;
118115 }
119116
120117 if (invitedPlayer->GetSocial ()->HasIgnore (invitingPlayer->GetGUID ()))
121118 {
122- SendPartyResult (PARTY_OP_INVITE, membername , ERR_IGNORING_YOU_S);
119+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_IGNORING_YOU_S);
123120 return ;
124121 }
125122
126123 if (!invitedPlayer->GetSocial ()->HasFriend (invitingPlayer->GetGUID ()) && invitingPlayer->GetLevel () < sWorld ->getIntConfig (CONFIG_PARTY_LEVEL_REQ))
127124 {
128- SendPartyResult (PARTY_OP_INVITE, membername , ERR_INVITE_RESTRICTED);
125+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_INVITE_RESTRICTED);
129126 return ;
130127 }
131128
@@ -141,18 +138,14 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
141138 // player already in another group or invited
142139 if (group2 || invitedPlayer->GetGroupInvite ())
143140 {
144- SendPartyResult (PARTY_OP_INVITE, membername , ERR_ALREADY_IN_GROUP_S);
141+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_ALREADY_IN_GROUP_S);
145142
146143 if (group2)
147144 {
148145 // tell the player that they were invited but it failed as they were already in a group
149- WorldPacket data (SMSG_GROUP_INVITE, 10 ); // guess size
150- data << uint8 (0 ); // invited/already in group flag
151- data << invitingPlayer->GetName (); // max len 48
152- data << uint32 (0 ); // unk
153- data << uint8 (0 ); // count
154- data << uint32 (0 ); // unk
155- invitedPlayer->SendDirectMessage (&data);
146+ WorldPackets::Party::PartyInvite partyInvite;
147+ partyInvite.Initialize (invitingPlayer, packet.ProposedRoles , false );
148+ invitedPlayer->SendDirectMessage (partyInvite.Write ());
156149 }
157150
158151 return ;
@@ -203,16 +196,11 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
203196 }
204197 }
205198
206- // ok, we do it
207- WorldPacket data (SMSG_GROUP_INVITE, 10 ); // guess size
208- data << uint8 (1 ); // invited/already in group flag
209- data << invitingPlayer->GetName (); // max len 48
210- data << uint32 (0 ); // unk
211- data << uint8 (0 ); // count
212- data << uint32 (0 ); // unk
213- invitedPlayer->SendDirectMessage (&data);
199+ WorldPackets::Party::PartyInvite partyInvite;
200+ partyInvite.Initialize (invitingPlayer, packet.ProposedRoles , true );
201+ invitedPlayer->SendDirectMessage (partyInvite.Write ());
214202
215- SendPartyResult (PARTY_OP_INVITE, membername , ERR_PARTY_RESULT_OK);
203+ SendPartyResult (PARTY_OP_INVITE, packet. TargetName , ERR_PARTY_RESULT_OK);
216204}
217205
218206void WorldSession::HandleGroupAcceptOpcode (WorldPacket& recvData)
0 commit comments