Пример #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
void PlayerSocial::SetFriendNote(ObjectGuid const& friend_guid, std::string note)
{
    PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid);
    if(itr == m_playerSocialMap.end())                      // not exist
        return;

    utf8truncate(note,48);                                  // DB and client size limitation
    CharacterDatabase.escape_string(note);
    m_playerSocialMap[friend_guid].Note = note;

    // FIXME - need make this asynchronows, like all other DB save methods
    CharacterDatabase.BeginTransaction();
    SaveFriendInfo(friend_guid, m_playerSocialMap[friend_guid]);
    CharacterDatabase.CommitTransaction();
}
Пример #3
0
void PlayerSocial::RemoveFromSocialList(ObjectGuid const& friend_guid, bool ignore)
{
    PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_guid);
    if(itr == m_playerSocialMap.end())                      // not exist
        return;

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

    itr->second.Flags &= ~flag;

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

    if (itr->second.Flags == SOCIAL_FLAG_NONE)
        m_playerSocialMap.erase(itr);
}