Exemplo n.º 1
0
uint32 LfgGroup::RemoveMember(const uint64 &guid, const uint8 &method)
{
    member_witerator slot = _getMemberWSlot(guid);
    if (slot != m_memberSlots.end())
    {
        m_memberSlots.erase(slot);
        UpdateItemLevelValues();
    }

    sLfgMgr.LfgLog("Remove member %u , guid %u", GetId(), guid);
    if (Player *player = sObjectMgr.GetPlayer(guid))
    {
        player->m_lookingForGroup.groups.erase(GetDungeonInfo(true)->ID);
        if (method == 1)
        {
            WorldPacket data(SMSG_GROUP_UNINVITE, 0);
            player->GetSession()->SendPacket( &data );
            player->SetGroup(NULL);
            _removeRolls(guid);
            _homebindIfInstance(player);
        }
        if(IsInDungeon() && IsMixed())
            player->m_lookingForGroup.SetMixedDungeon(0, false);
    }
    //Remove from any role
    if (m_tank == guid)
        m_tank = 0;
    else if (m_heal == guid)
        m_heal = 0;
    else if (dps.find(guid) != dps.end())
        dps.erase(guid);
    CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid='%u'", GUID_LOPART(guid));
    return 0;
}
Exemplo n.º 2
0
bool LfgGroup::AddMember(const uint64 &guid, const char* name)
{
    Player *player = sObjectMgr.GetPlayer(guid);
    if (!player)
        return false;
    
    if (GetMembersCount() == 0)
        m_baseLevel = player->getLevel();
    sLfgMgr.LfgLog("Add member %u , guid %u", GetId(), guid);
    member_witerator slot = _getMemberWSlot(guid);
    if (slot != m_memberSlots.end())
    {
        sLfgMgr.LfgLog("Player already in group, aborting!");
        return true;
    }
    MemberSlot member;
    member.guid      = guid;
    member.name      = name;
    member.group     = 0;
    member.assistant = false;
    m_memberSlots.push_back(member);
    UpdateItemLevelValues();

    if (!GetDungeonInfo(true))
         SetOriginalDungeonInfo(GetDungeonInfo());

    player->m_lookingForGroup.groups.insert(std::pair<uint32, uint32>(GetDungeonInfo(true)->ID,GetId()));
    return true;
}
Exemplo n.º 3
0
bool Group::_setAssistantFlag(ObjectGuid guid, const bool& state)
{
    member_witerator slot = _getMemberWSlot(guid);
    if (slot == m_memberSlots.end())
        return false;

    slot->assistant = state;
    if (!isBGGroup())
        CharacterDatabase.PExecute("UPDATE group_member SET assistant='%u' WHERE memberGuid='%u'", (state == true) ? 1 : 0, guid.GetCounter());
    return true;
}
Exemplo n.º 4
0
bool Group::SetPlayerMap(ObjectGuid guid, uint32 mapid)
{
    member_witerator slot = _getMemberWSlot(guid);
    if (slot != m_memberSlots.end())
    {
        slot->lastMap = mapid;
        DEBUG_LOG("Group::SetPlayerMap> map is updated");
        return true;
    }
    return false;
}
Exemplo n.º 5
0
bool Group::_setMembersGroup(ObjectGuid guid, uint8 group)
{
    member_witerator slot = _getMemberWSlot(guid);
    if (slot == m_memberSlots.end())
        return false;

    slot->group = group;

    SubGroupCounterIncrease(group);

    if (!isBGGroup())
        CharacterDatabase.PExecute("UPDATE group_member SET subgroup='%u' WHERE memberGuid='%u'", group, guid.GetCounter());

    return true;
}
Exemplo n.º 6
0
bool Group::_removeMember(ObjectGuid guid)
{
    Player* player = sObjectMgr.GetPlayer(guid);
    if (player)
    {
        // if we are removing player from battleground raid
        if (isBGGroup())
            player->RemoveFromBattleGroundRaid();
        else
        {
            // we can remove player who is in battleground from his original group
            if (player->GetOriginalGroup() == this)
                player->SetOriginalGroup(nullptr);
            else
                player->SetGroup(nullptr);
        }
    }

    member_witerator slot = _getMemberWSlot(guid);
    if (slot != m_memberSlots.end())
    {
        SubGroupCounterDecrease(slot->group);

        m_memberSlots.erase(slot);
    }

    if (!isBGGroup())
        CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid='%u'", guid.GetCounter());

    if (m_leaderGuid == guid)                               // leader was removed
    {
        _updateLeaderFlag(true);
        if (GetMembersCount() > 0)
            _setLeader(m_memberSlots.front().guid);
        return true;
    }

    return false;
}
Exemplo n.º 7
0
bool Group::_setMainAssistant(ObjectGuid guid)
{
    if (m_mainAssistantGuid == guid)
        return false;

    if (guid)
    {
        member_witerator slot = _getMemberWSlot(guid);
        if (slot == m_memberSlots.end())
            return false;

        if (m_mainTankGuid == guid)
            _setMainTank(ObjectGuid());
    }

    m_mainAssistantGuid = guid;

    if (!isBGGroup())
        CharacterDatabase.PExecute("UPDATE groups SET mainAssistant='%u' WHERE groupId='%u'",
                                   m_mainAssistantGuid.GetCounter(), m_Id);

    return true;
}