示例#1
0
        public bool AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
        {
            // check client limits
            if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SocialFlag.Friend) != 0) ? SocialManager.FriendLimit : SocialManager.IgnoreLimit))
            {
                return(false);
            }

            var friendInfo = _playerSocialMap.LookupByKey(friendGuid);

            if (friendInfo != null)
            {
                friendInfo.Flags |= flag;

                PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_CHARACTER_SOCIAL_FLAGS);
                stmt.AddValue(0, friendInfo.Flags);
                stmt.AddValue(1, GetPlayerGUID().GetCounter());
                stmt.AddValue(2, friendGuid.GetCounter());
                DB.Characters.Execute(stmt);
            }
            else
            {
                FriendInfo fi = new FriendInfo();
                fi.Flags |= flag;
                _playerSocialMap[friendGuid] = fi;

                PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHARACTER_SOCIAL);
                stmt.AddValue(0, GetPlayerGUID().GetCounter());
                stmt.AddValue(1, friendGuid.GetCounter());
                stmt.AddValue(2, flag);
                DB.Characters.Execute(stmt);
            }
            return(true);
        }
示例#2
0
        public void SendFriendStatus(Player player, FriendsResult result, ObjectGuid friendGuid, bool broadcast = false)
        {
            FriendInfo fi = new FriendInfo();

            GetFriendInfo(player, friendGuid, fi);

            FriendStatusPkt friendStatus = new FriendStatusPkt();

            friendStatus.Initialize(friendGuid, result, fi);

            if (broadcast)
            {
                BroadcastToFriendListers(player, friendStatus);
            }
            else
            {
                player.SendPacket(friendStatus);
            }
        }
示例#3
0
        public void GetFriendInfo(Player player, ObjectGuid friendGUID, FriendInfo friendInfo)
        {
            if (!player)
            {
                return;
            }

            friendInfo.Status = FriendStatus.Offline;
            friendInfo.Area   = 0;
            friendInfo.Level  = 0;
            friendInfo.Class  = 0;

            Player target = Global.ObjAccessor.FindPlayer(friendGUID);

            if (!target)
            {
                return;
            }

            var playerFriendInfo = player.GetSocial()._playerSocialMap.LookupByKey(friendGUID);

            if (playerFriendInfo != null)
            {
                friendInfo.Note = playerFriendInfo.Note;
            }

            // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
            // MODERATOR, GAME MASTER, ADMINISTRATOR can see all

            if (!player.GetSession().HasPermission(RBACPermissions.WhoSeeAllSecLevels) &&
                target.GetSession().GetSecurity() > (AccountTypes)WorldConfig.GetIntValue(WorldCfg.GmLevelInWhoList))
            {
                return;
            }

            // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
            if (target.GetTeam() != player.GetTeam() && !player.GetSession().HasPermission(RBACPermissions.TwoSideWhoList))
            {
                return;
            }

            if (target.IsVisibleGloballyFor(player))
            {
                if (target.isDND())
                {
                    friendInfo.Status = FriendStatus.DND;
                }
                else if (target.isAFK())
                {
                    friendInfo.Status = FriendStatus.AFK;
                }
                else
                {
                    friendInfo.Status = FriendStatus.Online;
                }

                friendInfo.Area  = target.GetZoneId();
                friendInfo.Level = target.getLevel();
                friendInfo.Class = target.GetClass();
            }
        }