예제 #1
0
bool PlayerSocial::AddToSocialList(ObjectGuid const& friend_guid, bool ignore)
{
    // check client limits
    if(ignore)
    {
        if(GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED) >= SOCIALMGR_IGNORE_LIMIT)
            return false;
    }
    else
    {
        if(GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND) >= SOCIALMGR_FRIEND_LIMIT)
            return false;
    }

    FriendInfo& fi = m_playerSocialMap[friend_guid];

    fi.Flags |= (ignore ? SOCIAL_FLAG_IGNORED : SOCIAL_FLAG_FRIEND);
    fi.Flags &= ~(ignore ? SOCIAL_FLAG_FRIEND  : SOCIAL_FLAG_IGNORED);

    // FIXME - need make this asynchronows, like all other DB save methods
    CharacterDatabase.BeginTransaction();
    SaveFriendInfo(friend_guid, fi);
    CharacterDatabase.CommitTransaction();

    return true;
}
예제 #2
0
bool PlayerSocial::AddToSocialList(uint32 friendGuid, bool ignore)
{
    // check client limits
    if (ignore)
    {
        if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED) >= SOCIALMGR_IGNORE_LIMIT)
            return false;
    }
    else
    {
        if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND) >= SOCIALMGR_FRIEND_LIMIT)
            return false;
    }

    uint8 flag = SOCIAL_FLAG_FRIEND;
    if (ignore)
        flag = SOCIAL_FLAG_IGNORED;

    PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid);
    if (itr != m_playerSocialMap.end())
    {
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_CHARACTER_SOCIAL_FLAGS);

        stmt->setUInt8(0, flag);
        stmt->setUInt32(1, GetPlayerGUID());
        stmt->setUInt32(2, friendGuid);

        CharacterDatabase.Execute(stmt);

        m_playerSocialMap[friendGuid].Flags |= flag;
    }
    else
    {
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SOCIAL);

        stmt->setUInt32(0, GetPlayerGUID());
        stmt->setUInt32(1, friendGuid);
        stmt->setUInt8(2, flag);

        CharacterDatabase.Execute(stmt);

        FriendInfo fi;
        fi.Flags |= flag;
        m_playerSocialMap[friendGuid] = fi;
    }

    return true;
}
예제 #3
0
bool PlayerSocial::AddToSocialList(ObjectGuid const& friendGuid, SocialFlag flag)
{
    // check client limits
    if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SOCIAL_FLAG_FRIEND) != 0) ? SOCIALMGR_FRIEND_LIMIT : SOCIALMGR_IGNORE_LIMIT))
        return false;

    PlayerSocialMap::iterator itr = _playerSocialMap.find(friendGuid);
    if (itr != _playerSocialMap.end())
    {
        itr->second.Flags |= flag;

        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_SOCIAL_FLAGS);

        stmt->setUInt8(0, itr->second.Flags);
        stmt->setUInt64(1, GetPlayerGUID().GetCounter());
        stmt->setUInt64(2, friendGuid.GetCounter());

        CharacterDatabase.Execute(stmt);
    }
    else
    {
        _playerSocialMap[friendGuid].Flags |= flag;

        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SOCIAL);

        stmt->setUInt64(0, GetPlayerGUID().GetCounter());
        stmt->setUInt64(1, friendGuid.GetCounter());
        stmt->setUInt8(2, flag);

        CharacterDatabase.Execute(stmt);
    }

    return true;
}
예제 #4
0
void PlayerSocial::SendFriendList()
{
    Player* plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid));
    if (!plr)
        return;

    uint32 size = GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND);

    WorldPacket data(SMSG_FRIEND_LIST, (1 + size * 25)); // just can guess size
    data << uint8(size);                                   // friends count

    for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
    {
        if (itr->second.Flags & SOCIAL_FLAG_FRIEND)         // if IsFriend()
        {
            sSocialMgr.GetFriendInfo(plr, itr->first, itr->second);

            data << ObjectGuid(HIGHGUID_PLAYER, itr->first);// player guid
            data << uint8(itr->second.Status);              // online/offline/etc?
            if (itr->second.Status)                         // if online
            {
                data << uint32(itr->second.Area);           // player area
                data << uint32(itr->second.Level);          // player level
                data << uint32(itr->second.Class);          // player class
            }
        }
    }

    plr->GetSession()->SendPacket(&data);
    DEBUG_LOG("WORLD: Sent SMSG_FRIEND_LIST");
}
예제 #5
0
void PlayerSocial::SendIgnoreList()
{
    /* Make sure the player ID is actually valid */
    Player* plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid));

    /* The ID is NOT valid, so just return */
    if (!plr)
    {
        return;
    }

    /* Returns number of people the player is ignoring */
    uint32 size = GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED);

    WorldPacket data(SMSG_IGNORE_LIST, (1 +          // 1 byte for ignore list size
                                        size * 8));  // 8 bytes per person ignored (object guid)
    data << uint8(size);                                    // friends count

    for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
    {
        if (itr->second.Flags & SOCIAL_FLAG_IGNORED)
        {
            data << ObjectGuid(HIGHGUID_PLAYER, itr->first);// player guid
        }
    }

    plr->GetSession()->SendPacket(&data);
    DEBUG_LOG("WORLD: Sent SMSG_IGNORE_LIST");
}
예제 #6
0
bool PlayerSocial::AddToSocialList(ObjectGuid friend_guid, bool ignore)
{
    // check client limits
    if (ignore)
    {
        if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED) >= SOCIALMGR_IGNORE_LIMIT)
        {
            return false;
        }
    }
    else
    {
        if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND) >= SOCIALMGR_FRIEND_LIMIT)
        {
            return false;
        }
    }

    uint32 flag = SOCIAL_FLAG_FRIEND;
    if (ignore)
    {
        flag = SOCIAL_FLAG_IGNORED;
    }

    PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter());
    if (itr != m_playerSocialMap.end())
    {
        CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags | %u) WHERE guid = '%u' AND friend = '%u'", flag, m_playerLowGuid, friend_guid.GetCounter());
        m_playerSocialMap[friend_guid.GetCounter()].Flags |= flag;
    }
    else
    {
        CharacterDatabase.PExecute("INSERT INTO character_social (guid, friend, flags) VALUES ('%u', '%u', '%u')", m_playerLowGuid, friend_guid.GetCounter(), flag);
        FriendInfo fi;
        fi.Flags |= flag;
        m_playerSocialMap[friend_guid.GetCounter()] = fi;
    }
    return true;
}
예제 #7
0
파일: SocialMgr.cpp 프로젝트: Maduse/server
void PlayerSocial::SendIgnoreList()
{
    MasterPlayer* plr = GetMasterPlayer();
    ASSERT(plr);

    uint32 size = GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED);

    WorldPacket data(SMSG_IGNORE_LIST, (1 + size * 8));     // just can guess size
    data << uint8(size);                                    // friends count

    for (PlayerSocialMap::const_iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
        if (itr->second.Flags & SOCIAL_FLAG_IGNORED)
            data << ObjectGuid(HIGHGUID_PLAYER, itr->first);// player guid


    plr->GetSession()->SendPacket(&data);
    DEBUG_LOG("WORLD: Sent SMSG_IGNORE_LIST");
}
예제 #8
0
void PlayerSocial::SendIgnoreList()
{
    Player* plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid));
    if (!plr)
        return;

    uint32 size = GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED);

    WorldPacket data(SMSG_IGNORE_LIST, (1 + size * 8));     // just can guess size
    data << uint8(size);                                    // friends count

    for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
    {
        if (itr->second.Flags & SOCIAL_FLAG_IGNORED)
        {
            data << ObjectGuid(HIGHGUID_PLAYER, itr->first);// player guid
        }
    }

    plr->GetSession()->SendPacket(&data);
    DEBUG_LOG("WORLD: Sent SMSG_IGNORE_LIST");
}
예제 #9
0
/* Called by WorldSession::HandlePlayerLogin */
void PlayerSocial::SendFriendList()
{
    /* Make sure the player ID is actually valid */
    Player* plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid));

    /* The ID is NOT valid, so just return */
    if (!plr)
    {
        return;
    }

    uint32 packet_size = 0;

    /* * * * * * * * * * * * * * * * *
     * * START OF PACKET STRUCTURE * *
     * * * * * * * * * * * * * * * * */

    /* Returns the number of friends on the player's social map */
    uint32 size = GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND);
    std::vector<friend_> friends_to_send;
    /* * * * * * * * * * * * * * * * *
     * *  END OF PACKET STRUCTURE  * *
     * * * * * * * * * * * * * * * * */

    /* for each person on the player's social map */
    for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
    {
        /* If the person is a friend */
        if (itr->second.Flags & SOCIAL_FLAG_FRIEND)
        {
            /* Get information about them and store it in itr */
            sSocialMgr.GetFriendInfo(plr, itr->first, itr->second);

            friend_ my_friend;

            my_friend.guid = ObjectGuid(HIGHGUID_PLAYER, itr->first); // GUID
            my_friend.status = uint8(itr->second.Status);             // Status (Offline, Online, AFK, DND)

            /* used to calculate packet size */
            packet_size += 9;

            /* If friend is online, we have more data to send */
            if (itr->second.Status != FRIEND_STATUS_OFFLINE)
            {
                /* we have more data to send */
                packet_size += 12;
                my_friend.area   = uint32(itr->second.Area);  // Player area
                my_friend.level  = uint32(itr->second.Level); // Player level
                my_friend.class_ = uint32(itr->second.Class); // Player class
            }

            /* Queue up packet */
            friends_to_send.push_back(my_friend);
        }
    }

    WorldPacket data(SMSG_FRIEND_LIST, (1 +            // Number of friends
                                        packet_size)); // 9 bytes if offline, 21 if online
    // uint64 guid
    // uint8 isOnline
    // uint32 area
    // uint32 level
    // uint32 class

    data << uint8(size);                                   // friends count
    for (int i = 0; i < friends_to_send.size(); ++i)
    {
        data << friends_to_send[i].guid;
        data << friends_to_send[i].status;
        if (friends_to_send[i].status != FRIEND_STATUS_OFFLINE)
        {
            data << friends_to_send[i].area;
            data << friends_to_send[i].level;
            data << friends_to_send[i].class_;
        }
    }
    plr->GetSession()->SendPacket(&data);
    DEBUG_LOG("WORLD: Sent SMSG_FRIEND_LIST");
}