示例#1
0
文件: MsgFriend.cs 项目: Pircs/Yi
        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));
        }
示例#2
0
        public static void Handle(Player player, byte[] buffer)
        {
            try
            {
                fixed(byte *p = buffer)
                {
                    var packet = *(MsgSynMemberInfo *)p;

                    BufferPool.RecycleBuffer(buffer);

                    var name = Encoding.UTF8.GetString(packet.Name, 16);

                    if (GameWorld.Find(name.TrimEnd('\0'), out Player found))
                    {
                        var msg = Create(found);
                        player.Send(msg);
                    }
                }
            }
            catch (Exception e)
            {
                Output.WriteLine(e);
            }
        }
示例#3
0
文件: MsgFriend.cs 项目: Pircs/Yi
        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);
                }
            }
        }
示例#4
0
        public static void Handle(Player player, byte[] buffer)
        {
            try
            {
                fixed(byte *p = buffer)
                {
                    var packet = *(MsgName *)p;

                    BufferPool.RecycleBuffer(buffer);

                    switch (packet.Type)
                    {
                    case MsgNameType.None:
                        break;

                    case MsgNameType.Fireworks:
                        break;

                    case MsgNameType.CreateSyn:
                        break;

                    case MsgNameType.Syndicate:
                        break;

                    case MsgNameType.ChangeTitle:
                        break;

                    case MsgNameType.DelRole:
                        break;

                    case MsgNameType.Spouse:
                        break;

                    case MsgNameType.QueryNpc:
                        break;

                    case MsgNameType.Wanted:
                        break;

                    case MsgNameType.MapEffect:
                        break;

                    case MsgNameType.RoleEffect:
                        break;

                    case MsgNameType.MemberList:
                        if (player.Guild != null)
                        {
                            var list = player.Guild.GetMemberList();
                            if (packet.Data == int.MaxValue)
                            {
                                packet.Data = 0;
                            }

                            var amount = list.Length - packet.Data * 10;
                            if (amount > 10)
                            {
                                amount = 10;
                            }

                            var tempList = new string[amount];

                            Array.Copy(list, (int)(packet.Data * 10), tempList, 0, (int)amount);

                            player.Send(Create((int)(packet.Data + 1), tempList, MsgNameType.MemberList));
                        }
                        break;

                    case MsgNameType.KickOutSynMem:
                        break;

                    case MsgNameType.QueryWanted:
                        break;

                    case MsgNameType.QueryPoliceWanted:
                        break;

                    case MsgNameType.PoliceWanted:
                        break;

                    case MsgNameType.QuerySpouse:     //View equips?
                    {
                        //foreach (var item in player.Equipment.Items)
                        //{
                        //    var ItemInfo = new MsgItemInfoEx(item.Value, item.Key, ItemExType.OtherPlayer_Equipement);
                        //    player.ForceSend(ItemInfo, ItemInfo.Size);
                        //}
                        player.Send(Create(packet.Data + 1, player.Partner, (int)MsgNameType.QuerySpouse));
                    }
                    break;

                    case MsgNameType.AddDicePlayer:
                        break;

                    case MsgNameType.DelDicePlayer:
                        break;

                    case MsgNameType.DiceBonus:
                        break;

                    case MsgNameType.Sound:
                        break;

                    case MsgNameType.SynEnemie:
                        break;

                    case MsgNameType.SynAlly:
                        break;

                    case MsgNameType.Bavarder:
                        var data = Encoding.UTF8.GetString(packet.Params, 255).Trim('\0').Trim('\u0006').Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        if (data.Length > 0)
                        {
                            if (GameWorld.Find(data[0], out Player found))
                            {
                                var synName = "No~Guild";
                                if (found.Guild != null)
                                {
                                    synName = found.Guild.Name;
                                }

                                var targetInfo =
                                    found.UniqueId + " " +
                                    found.Level + " " +
                                    0 /*found.Potency*/ + " #" +
                                    synName + " #" +
                                    "YiOnline" + " " +
                                    found.Partner + " " +
                                    0 /*found.Nobility.Rank*/ + " " +
                                    (found.Look % 1000 == 3 ? 1 : 0);

                                player.Send(Create(0, new[] { found.Name.Trim('\0'), targetInfo }, MsgNameType.Bavarder));
                            }
                        }
                        break;

                    default:
                        Output.WriteLine(((byte[])packet).HexDump());
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Output.WriteLine(e);
            }
        }