Example #1
0
void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data)
{
    std::string membername;
    recv_data >> membername;

    // player not found
    if (!normalizePlayerName(membername))
        return;

    // can't uninvite yourself
    if (GetPlayer()->GetName() == membername)
    {
        ERROR_LOG("WorldSession::HandleGroupUninviteOpcode: leader %s tried to uninvite himself from the group.", GetPlayer()->GetGuidStr().c_str());
        return;
    }

    Group* grp = GetPlayer()->GetGroup();
    if (!grp)
        return;

    ObjectGuid guid = grp->GetMemberGuid(membername);

    PartyResult res = GetPlayer()->CanUninviteFromGroup();
    if (res != ERR_PARTY_RESULT_OK)
    {
        SendPartyResult(PARTY_OP_UNINVITE, "", res);
        return;
    }


    if (ObjectGuid guid = grp->GetMemberGuid(membername))
    {
        if (grp->GetLeaderGuid() == guid)
            return;
        Player::RemoveFromGroup(grp, guid);

        return;
    }

    if (Player* plr = grp->GetInvited(membername))
    {
        if (grp->GetLeaderGuid() == plr->GetObjectGuid())
            return;
        plr->UninviteFromGroup();
        return;
    }

    SendPartyResult(PARTY_OP_UNINVITE, membername, ERR_TARGET_NOT_IN_GROUP_S);
}
Example #2
0
void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data)
{
    std::string membername;
    recv_data >> membername;

    // player not found
    if (!normalizePlayerName(membername))
        return;

    // can't uninvite yourself
    if (GetPlayer()->GetName() == membername)
    {
        sLog.outError("WorldSession::HandleGroupUninviteOpcode: leader %s tried to uninvite himself from the group.", GetPlayer()->GetGuidStr().c_str());
        return;
    }

    Group* grp = GetPlayer()->GetGroup();
    if (!grp)
        return;

    ObjectGuid guid = grp->GetMemberGuid(membername);

    if (grp->IsMember(guid) && grp->isLFGGroup())
    {
        sLFGMgr.InitBoot(GetPlayer(), guid, "");
        return;
    }

    PartyResult res = GetPlayer()->CanUninviteFromGroup();
    if (res != ERR_PARTY_RESULT_OK)
    {
        SendPartyResult(PARTY_OP_LEAVE, "", res);
        return;
    }

    if (!guid.IsEmpty())
    {
        Player::RemoveFromGroup(grp, guid);
        return;
    }

    if (Player* plr = grp->GetInvited(membername))
    {
        plr->UninviteFromGroup();
        return;
    }

    SendPartyResult(PARTY_OP_LEAVE, membername, ERR_TARGET_NOT_IN_GROUP_S);
}