Example #1
0
        private static void ConfirmFriends(Player player, ref MsgAction packet)
        {
            player.Send(packet);
            if (!player.Online)
            {
                return;
            }

            if (player.Friends == null)
            {
                player.Friends = new List <int>();
            }

            if (player.Enemies == null)
            {
                player.Enemies = new List <int>();
            }

            foreach (var friend in player.Friends)
            {
                if (GameWorld.Find(friend, out Player found))
                {
                    found.Send(MsgFriend.Create(player, MsgFriendActionType.FriendOnline, MsgFriendStatusType.Online));
                }
                player.Send(MsgFriend.Create(found, MsgFriendActionType.GetInfo, found.Online ? MsgFriendStatusType.Online : MsgFriendStatusType.Offline));
            }
            foreach (var enemy in player.Enemies)
            {
                if (GameWorld.Find(enemy, out Player found))
                {
                    player.Send(MsgFriend.Create(found, MsgFriendActionType.EnemyAdd, found.Online ? MsgFriendStatusType.Online : MsgFriendStatusType.Offline));
                }
            }
        }
Example #2
0
        private static void BreakFrienship(Player player, ref MsgFriend packet)
        {
            if (player.Friends.Contains(packet.UniqId))
            {
                player.Friends.Remove(packet.UniqId);
            }

            if (GameWorld.Find(packet.UniqId, out Player found))
            {
                if (found.Friends.Contains(player.UniqueId))
                {
                    found.Friends.Remove(player.UniqueId);
                }

                found.Send(Create(player, MsgFriendActionType.FriendBreak, MsgFriendStatusType.Offline));
            }
            player.Send(Create(found, MsgFriendActionType.FriendBreak, MsgFriendStatusType.Offline));
        }
Example #3
0
        public static byte[] Create(Player target, MsgFriendActionType action, MsgFriendStatusType status)
        {
            var packet = new MsgFriend
            {
                Size     = (ushort)sizeof(MsgFriend),
                Id       = 1019,
                Action   = action,
                IsOnline = status,
                Unknow1  = 0,
                Unknow2  = 0,
                UniqId   = target.UniqueId,
            };

            for (byte i = 0; i < target.Name.Length; i++)
            {
                packet.Name[i] = (byte)target.Name[i];
            }
            return(packet);
        }
Example #4
0
        private static void FriendApply(Player player, ref MsgFriend packet)
        {
            if (GameWorld.Find(packet.UniqId, out Player target))
            {
                if (target.FriendRequestTarget == player.UniqueId)
                {
                    player.ForceSend(BufferPool.Clone(packet), packet.Size);
                    target.ForceSend(packet, packet.Size);
                    player.Send(Create(target, MsgFriendActionType.FriendAccept, MsgFriendStatusType.Online));
                    target.Send(Create(player, MsgFriendActionType.FriendAccept, MsgFriendStatusType.Online));

                    if (player.Friends == null)
                    {
                        player.Friends = new List <int>();
                    }
                    if (target.Friends == null)
                    {
                        target.Friends = new List <int>();
                    }

                    if (!player.Friends.Contains(target.UniqueId))
                    {
                        player.Friends.Add(target.UniqueId);
                    }
                    if (!target.Friends.Contains(player.UniqueId))
                    {
                        target.Friends.Add(player.UniqueId);
                    }
                }
                else
                {
                    player.FriendRequestTarget = target.UniqueId;
                    target.ForceSend(packet, packet.Size);
                }
            }
        }
Example #5
0
 private static void GetInfo(Player player, ref MsgFriend packet)
 {
 }