mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-28 21:02:14 +01:00
Modify group invite behavior while creating group to be blizzlike:
- Leader can invite multiple people before the first invite is accepted - Leader can cancel group formation by sending CMSG_GROUP_DISBAND (using /run LeaveParty() or similar)
This commit is contained in:
@@ -105,54 +105,55 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
Player* player = ObjectAccessor::FindPlayerByName(memberName);
|
||||
Player* invitingPlayer = GetPlayer();
|
||||
Player* invitedPlayer = ObjectAccessor::FindPlayerByName(membername);
|
||||
|
||||
// no player
|
||||
if (!player)
|
||||
if (!invitedPlayer)
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S);
|
||||
return;
|
||||
}
|
||||
|
||||
// player trying to invite himself (most likely cheating)
|
||||
if (player == GetPlayer())
|
||||
if (invitedPlayer == invitingPlayer)
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S);
|
||||
return;
|
||||
}
|
||||
|
||||
// restrict invite to GMs
|
||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster())
|
||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !invitingPlayer->IsGameMaster() && invitedPlayer->IsGameMaster())
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_BAD_PLAYER_NAME_S);
|
||||
return;
|
||||
}
|
||||
|
||||
// can't group with
|
||||
if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam())
|
||||
if (!invitingPlayer->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && invitingPlayer->GetTeam() != invitedPlayer->GetTeam())
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PLAYER_WRONG_FACTION);
|
||||
return;
|
||||
}
|
||||
if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId())
|
||||
if (invitingPlayer->GetInstanceId() != 0 && invitedPlayer->GetInstanceId() != 0 && invitingPlayer->GetInstanceId() != invitedPlayer->GetInstanceId() && invitingPlayer->GetMapId() == invitedPlayer->GetMapId())
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_TARGET_NOT_IN_INSTANCE_S);
|
||||
return;
|
||||
}
|
||||
// just ignore us
|
||||
if (player->GetInstanceId() != 0 && player->GetDungeonDifficulty() != GetPlayer()->GetDungeonDifficulty())
|
||||
if (invitedPlayer->GetInstanceId() != 0 && invitedPlayer->GetDungeonDifficulty() != invitingPlayer->GetDungeonDifficulty())
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID()))
|
||||
if (invitedPlayer->GetSocial()->HasIgnore(invitingPlayer->GetGUID()))
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_IGNORING_YOU_S);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player->GetSocial()->HasFriend(GetPlayer()->GetGUID()) && GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_PARTY_LEVEL_REQ))
|
||||
if (!invitedPlayer->GetSocial()->HasFriend(invitingPlayer->GetGUID()) && invitingPlayer->getLevel() < sWorld->getIntConfig(CONFIG_PARTY_LEVEL_REQ))
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_INVITE_RESTRICTED);
|
||||
return;
|
||||
@@ -160,15 +161,17 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
|
||||
ObjectGuid invitedGuid = player->GetGUID();
|
||||
|
||||
Group* group = GetPlayer()->GetGroup();
|
||||
Group* group = invitingPlayer->GetGroup();
|
||||
if (group && group->isBGGroup())
|
||||
group = GetPlayer()->GetOriginalGroup();
|
||||
group = invitingPlayer->GetOriginalGroup();
|
||||
if (!group)
|
||||
group = invitingPlayer->GetGroupInvite();
|
||||
|
||||
Group* group2 = player->GetGroup();
|
||||
Group* group2 = invitedPlayer->GetGroup();
|
||||
if (group2 && group2->isBGGroup())
|
||||
group2 = player->GetOriginalGroup();
|
||||
group2 = invitedPlayer->GetOriginalGroup();
|
||||
// player already in another group or invited
|
||||
if (group2 || player->GetGroupInvite())
|
||||
if (group2 || invitedPlayer->GetGroupInvite())
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_ALREADY_IN_GROUP_S);
|
||||
|
||||
@@ -192,7 +195,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
|
||||
data.WriteBit(invitedGuid[4]);
|
||||
|
||||
data.WriteBits(GetPlayer()->GetName().size(), 7); // Inviter name length
|
||||
data.WriteBits(invitingPlayer->GetName().size(), 7); // Inviter name length
|
||||
|
||||
data.WriteBits(0, 24); // Count 2
|
||||
|
||||
@@ -227,7 +230,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
|
||||
data << int32(0);
|
||||
|
||||
player->GetSession()->SendPacket(&data);
|
||||
invitedPlayer->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -236,9 +239,10 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
if (group)
|
||||
{
|
||||
// not have permissions for invite
|
||||
if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
|
||||
if (!group->IsLeader(invitingPlayer->GetGUID()) && !group->IsAssistant(invitingPlayer->GetGUID()))
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER);
|
||||
if (group->IsCreated())
|
||||
SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER);
|
||||
return;
|
||||
}
|
||||
// not have place
|
||||
@@ -254,14 +258,14 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
// at least one person joins
|
||||
if (!group)
|
||||
{
|
||||
group = new Group;
|
||||
group = new Group();
|
||||
// new group: if can't add then delete
|
||||
if (!group->AddLeaderInvite(GetPlayer()))
|
||||
if (!group->AddLeaderInvite(invitingPlayer))
|
||||
{
|
||||
delete group;
|
||||
return;
|
||||
}
|
||||
if (!group->AddInvite(player))
|
||||
if (!group->AddInvite(invitedPlayer))
|
||||
{
|
||||
group->RemoveAllInvites();
|
||||
delete group;
|
||||
@@ -271,7 +275,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
else
|
||||
{
|
||||
// already existed group: if can't add then just leave
|
||||
if (!group->AddInvite(player))
|
||||
if (!group->AddInvite(invitedPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -295,7 +299,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
|
||||
data.WriteBit(invitedGuid[4]);
|
||||
|
||||
data.WriteBits(GetPlayer()->GetName().size(), 7); // Inviter name length
|
||||
data.WriteBits(invitingPlayer->GetName().size(), 7); // Inviter name length
|
||||
|
||||
data.WriteBits(0, 24); // Count 2
|
||||
|
||||
@@ -330,7 +334,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
|
||||
data << int32(0);
|
||||
|
||||
player->GetSession()->SendPacket(&data);
|
||||
invitedPlayer->GetSession()->SendPacket(&data);
|
||||
|
||||
SendPartyResult(PARTY_OP_INVITE, memberName, ERR_PARTY_RESULT_OK);
|
||||
}
|
||||
@@ -619,7 +623,8 @@ void WorldSession::HandleGroupDisbandOpcode(WorldPacket& /*recvData*/)
|
||||
TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_DISBAND");
|
||||
|
||||
Group* grp = GetPlayer()->GetGroup();
|
||||
if (!grp)
|
||||
Group* grpInvite = GetPlayer()->GetGroupInvite();
|
||||
if (!grp && !grpInvite)
|
||||
return;
|
||||
|
||||
if (_player->InBattleground())
|
||||
@@ -632,9 +637,16 @@ void WorldSession::HandleGroupDisbandOpcode(WorldPacket& /*recvData*/)
|
||||
/********************/
|
||||
|
||||
// everything's fine, do it
|
||||
SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
|
||||
|
||||
GetPlayer()->RemoveFromGroup(GROUP_REMOVEMETHOD_LEAVE);
|
||||
if (grp)
|
||||
{
|
||||
SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
|
||||
GetPlayer()->RemoveFromGroup(GROUP_REMOVEMETHOD_LEAVE);
|
||||
}
|
||||
else if (grpInvite && grpInvite->GetLeaderGUID() == GetPlayer()->GetGUID())
|
||||
{ // pending group creation being cancelled
|
||||
SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
|
||||
grpInvite->Disband();
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData)
|
||||
|
||||
Reference in New Issue
Block a user