示例#1
0
        void HandleAddFriendCallBack(string friendNote, SQLResult result)
        {
            if (!GetPlayer())
            {
                return;
            }

            ObjectGuid    friendGuid   = ObjectGuid.Empty;
            FriendsResult friendResult = FriendsResult.NotFound;

            if (!result.IsEmpty())
            {
                ulong lowGuid = result.Read <ulong>(0);
                if (lowGuid != 0)
                {
                    friendGuid = ObjectGuid.Create(HighGuid.Player, lowGuid);
                    Team team            = Player.TeamForRace((Race)result.Read <byte>(1));
                    uint friendAccountId = result.Read <uint>(2);

                    if (HasPermission(RBACPermissions.AllowGmFriend) || Global.AccountMgr.IsPlayerAccount(Global.AccountMgr.GetSecurity(friendAccountId, (int)Global.WorldMgr.GetRealm().Id.Realm)))
                    {
                        if (friendGuid == GetPlayer().GetGUID())
                        {
                            friendResult = FriendsResult.Self;
                        }
                        else if (GetPlayer().GetTeam() != team && !HasPermission(RBACPermissions.TwoSideAddFriend))
                        {
                            friendResult = FriendsResult.Enemy;
                        }
                        else if (GetPlayer().GetSocial().HasFriend(friendGuid))
                        {
                            friendResult = FriendsResult.Already;
                        }
                        else
                        {
                            Player playerFriend = Global.ObjAccessor.FindPlayer(friendGuid);
                            if (playerFriend && playerFriend.IsVisibleGloballyFor(GetPlayer()))
                            {
                                friendResult = FriendsResult.AddedOnline;
                            }
                            else
                            {
                                friendResult = FriendsResult.AddedOffline;
                            }

                            if (GetPlayer().GetSocial().AddToSocialList(friendGuid, SocialFlag.Friend))
                            {
                                GetPlayer().GetSocial().SetFriendNote(friendGuid, friendNote);
                            }
                            else
                            {
                                friendResult = FriendsResult.ListFull;
                            }
                        }
                    }
                }
            }

            Global.SocialMgr.SendFriendStatus(GetPlayer(), friendResult, friendGuid);
        }
示例#2
0
        void HandleAddIgnore(AddIgnore packet)
        {
            if (!ObjectManager.NormalizePlayerName(ref packet.Name))
            {
                return;
            }

            ObjectGuid    IgnoreGuid   = Global.CharacterCacheStorage.GetCharacterGuidByName(packet.Name);
            FriendsResult ignoreResult = FriendsResult.IgnoreNotFound;

            if (IgnoreGuid.IsEmpty())
            {
                if (IgnoreGuid == GetPlayer().GetGUID())              //not add yourself
                {
                    ignoreResult = FriendsResult.IgnoreSelf;
                }
                else if (GetPlayer().GetSocial().HasIgnore(IgnoreGuid))
                {
                    ignoreResult = FriendsResult.IgnoreAlready;
                }
                else
                {
                    ignoreResult = FriendsResult.IgnoreAdded;

                    // ignore list full
                    if (!GetPlayer().GetSocial().AddToSocialList(IgnoreGuid, SocialFlag.Ignored))
                    {
                        ignoreResult = FriendsResult.IgnoreFull;
                    }
                }
            }

            Global.SocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, IgnoreGuid);
        }
示例#3
0
        void HandleAddFriend(AddFriend packet)
        {
            if (!ObjectManager.NormalizePlayerName(ref packet.Name))
            {
                return;
            }

            FriendsResult friendResult = FriendsResult.NotFound;
            ObjectGuid    friendGuid   = Global.CharacterCacheStorage.GetCharacterGuidByName(packet.Name);

            if (!friendGuid.IsEmpty())
            {
                CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(friendGuid);
                if (characterInfo != null)
                {
                    Team team            = Player.TeamForRace(characterInfo.RaceId);
                    uint friendAccountId = characterInfo.AccountId;

                    if (HasPermission(RBACPermissions.AllowGmFriend) || Global.AccountMgr.IsPlayerAccount(Global.AccountMgr.GetSecurity(friendAccountId, (int)Global.WorldMgr.GetRealm().Id.Realm)))
                    {
                        if (friendGuid == GetPlayer().GetGUID())
                        {
                            friendResult = FriendsResult.Self;
                        }
                        else if (GetPlayer().GetTeam() != team && !HasPermission(RBACPermissions.TwoSideAddFriend))
                        {
                            friendResult = FriendsResult.Enemy;
                        }
                        else if (GetPlayer().GetSocial().HasFriend(friendGuid))
                        {
                            friendResult = FriendsResult.Already;
                        }
                        else
                        {
                            Player playerFriend = Global.ObjAccessor.FindPlayer(friendGuid);
                            if (playerFriend && playerFriend.IsVisibleGloballyFor(GetPlayer()))
                            {
                                friendResult = FriendsResult.AddedOnline;
                            }
                            else
                            {
                                friendResult = FriendsResult.AddedOffline;
                            }

                            if (GetPlayer().GetSocial().AddToSocialList(friendGuid, SocialFlag.Friend))
                            {
                                GetPlayer().GetSocial().SetFriendNote(friendGuid, packet.Notes);
                            }
                            else
                            {
                                friendResult = FriendsResult.ListFull;
                            }
                        }
                    }
                }
            }

            Global.SocialMgr.SendFriendStatus(GetPlayer(), friendResult, friendGuid);
        }
示例#4
0
 public void Initialize(ObjectGuid guid, FriendsResult result, FriendInfo friendInfo)
 {
     VirtualRealmAddress = Global.WorldMgr.GetVirtualRealmAddress();
     Notes          = friendInfo.Note;
     ClassID        = friendInfo.Class;
     Status         = friendInfo.Status;
     Guid           = guid;
     WowAccountGuid = friendInfo.WowAccountGuid;
     Level          = friendInfo.Level;
     AreaID         = friendInfo.Area;
     FriendResult   = result;
 }
示例#5
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);
            }
        }
示例#6
0
        void HandleAddIgnoreCallBack(SQLResult result)
        {
            if (!GetPlayer())
            {
                return;
            }

            ObjectGuid    IgnoreGuid   = ObjectGuid.Empty;
            FriendsResult ignoreResult = FriendsResult.IgnoreNotFound;

            if (result.IsEmpty())
            {
                ulong lowGuid = result.Read <ulong>(0);
                if (lowGuid != 0)
                {
                    IgnoreGuid = ObjectGuid.Create(HighGuid.Player, lowGuid);

                    if (IgnoreGuid == GetPlayer().GetGUID())              //not add yourself
                    {
                        ignoreResult = FriendsResult.IgnoreSelf;
                    }
                    else if (GetPlayer().GetSocial().HasIgnore(IgnoreGuid))
                    {
                        ignoreResult = FriendsResult.IgnoreAlready;
                    }
                    else
                    {
                        ignoreResult = FriendsResult.IgnoreAdded;

                        // ignore list full
                        if (!GetPlayer().GetSocial().AddToSocialList(IgnoreGuid, SocialFlag.Ignored))
                        {
                            ignoreResult = FriendsResult.IgnoreFull;
                        }
                    }
                }
            }

            Global.SocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, IgnoreGuid);
        }
示例#7
0
        void HandleAddIgnore(AddIgnore packet)
        {
            if (!ObjectManager.NormalizePlayerName(ref packet.Name))
            {
                return;
            }

            ObjectGuid    ignoreGuid;
            FriendsResult ignoreResult = FriendsResult.IgnoreNotFound;

            CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByName(packet.Name);

            if (characterInfo != null)
            {
                ignoreGuid = characterInfo.Guid;
                ObjectGuid ignoreAccountGuid = ObjectGuid.Create(HighGuid.WowAccount, characterInfo.AccountId);
                if (ignoreGuid == GetPlayer().GetGUID())              //not add yourself
                {
                    ignoreResult = FriendsResult.IgnoreSelf;
                }
                else if (GetPlayer().GetSocial().HasIgnore(ignoreGuid, ignoreAccountGuid))
                {
                    ignoreResult = FriendsResult.IgnoreAlready;
                }
                else
                {
                    ignoreResult = FriendsResult.IgnoreAdded;

                    // ignore list full
                    if (!GetPlayer().GetSocial().AddToSocialList(ignoreGuid, ignoreAccountGuid, SocialFlag.Ignored))
                    {
                        ignoreResult = FriendsResult.IgnoreFull;
                    }
                }
            }

            Global.SocialMgr.SendFriendStatus(GetPlayer(), ignoreResult, ObjectGuid.Empty);
        }