当前位置: 首页>>代码示例>>C#>>正文


C# PacketIn.Skip方法代码示例

本文整理汇总了C#中FrameWork.PacketIn.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# PacketIn.Skip方法的具体用法?C# PacketIn.Skip怎么用?C# PacketIn.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FrameWork.PacketIn的用法示例。


在下文中一共展示了PacketIn.Skip方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: F_CONNECT

        static public void F_CONNECT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(8);
            UInt32 Tag = packet.GetUint32();
            string Token = packet.GetString(80);
            packet.Skip(21);
            string Username = packet.GetString(23);

            // TODO
            AuthResult Result = Program.AcctMgr.CheckToken(Username, Token);
            if (Result != AuthResult.AUTH_SUCCESS)
            {
                Log.Error("F_CONNECT", "Invalid Token =" + Username);
                cclient.Disconnect();
            }
            else
            {
                cclient._Account = Program.AcctMgr.GetAccount(Username);
                if (cclient._Account == null)
                {
                    Log.Error("F_CONNECT", "Invalid Account =" + Username);
                    cclient.Disconnect();
                }
                else
                {
                    //Log.Success("F_CONNECT", "MeId=" + cclient.Id);

                    GameClient Other = (cclient.Server as TCPServer).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                        Other.Disconnect();

                    {
                        PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED);
                        Out.WriteUInt32(0);
                        Out.WriteUInt32(Tag);
                        Out.WriteByte(Program.Rm.RealmId);
                        Out.WriteUInt32(1);
                        Out.WritePascalString(Username);
                        Out.WritePascalString(Program.Rm.Name);
                        Out.WriteByte(0);
                        Out.WriteUInt16(0);
                        cclient.SendPacket(Out);
                    }
                }
            }
        }
开发者ID:dzikun,项目名称:WarEmu,代码行数:48,代码来源:AuthentificationHandlers.cs

示例2: OnReceive

        protected override void OnReceive(byte[] Packet)
        {
            lock (this)
            {
                PacketIn packet = new PacketIn(Packet, 0, Packet.Length);
                long byteLeft = packet.Length;

                while (byteLeft > 0)
                {
                    if (!m_expectData)
                    {
                        long StartPos = packet.Position;
                        m_expectSize = packet.DecodeMythicSize();
                        long EndPos = packet.Position;

                        long Diff = EndPos - StartPos;
                        byteLeft -= Diff;
                        if (m_expectSize <= 0)
                        {
                            packet.Opcode = packet.GetUint8();
                            packet.Size = (ulong)m_expectSize;
                            _srvr.HandlePacket(this, packet);
                            return;
                        }

                        if (byteLeft <= 0)
                            return;

                        Opcode = packet.GetUint8();
                        byteLeft -= 1;

                        m_expectData = true;
                    }
                    else
                    {
                        m_expectData = false;
                        if (byteLeft >= m_expectSize)
                        {
                            long Pos = packet.Position;

                            packet.Opcode = Opcode;
                            packet.Size = (ulong)m_expectSize;

                            _srvr.HandlePacket(this, packet);

                            byteLeft -= m_expectSize;
                            packet.Position = Pos;
                            packet.Skip(m_expectSize);
                        }
                        else
                        {
                            Log.Error("OnReceive", "Data count incorrect :" + byteLeft + " != " + m_expectSize);
                        }
                    }
                }

                packet.Dispose();
            }
        }
开发者ID:dzikun,项目名称:WarEmu,代码行数:59,代码来源:Client.cs

示例3: HandlePacket

        public static void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;
            packet.Skip(24);
            string Email = packet.GetUnicodeString().ToUpper();

            Log.Notice("ASK_LOGIN", "Authentification de : " + Email);

            SendLoginResult(cclient, Email,Program.CharMgr.LoadAccount(Email));
        }
开发者ID:Novo,项目名称:apbprivateserver,代码行数:10,代码来源:ASK_LOGIN.cs

示例4: F_SOCIAL_NETWORK

        static public void F_SOCIAL_NETWORK(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
                return;

            Player Plr = cclient.Plr;

            byte Type = packet.GetUint8();

            switch (Type)
            {
                case 11: // Inspection
                    {
                        Player Target = Plr.CbtInterface.GetTarget(GameData.TargetTypes.TARGETTYPES_TARGET_ALLY) as Player;
                        if (Target == null)
                            Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND);
                        else
                            Target.ItmInterface.SendInspect(Plr);
                    }
                    break;
                case 8:
                    {
                        packet.Skip(1);
                        byte NameSize = packet.GetUint8();
                        packet.Skip(1);
                        string Name = packet.GetString(NameSize);
                        byte GuildSize = packet.GetUint8();
                        packet.Skip(1);
                        string GuildName = packet.GetString(GuildSize);
                        packet.Skip(1);
                        UInt16 Career = packet.GetUint16();
                        packet.Skip(4);
                        UInt16 ZoneId = packet.GetUint16();

                        while (ZoneId > 256)
                            ZoneId -= 256;

                        while (packet.GetUint8() != 0xFF) ;

                        packet.Skip(2 + (ZoneId == 255 ? 0 : 1));

                        byte MinLevel = packet.GetUint8();
                        byte MaxLevel = packet.GetUint8();

                        Plr.SocInterface.SendPlayers(Player.GetPlayers(Name, GuildName, Career, ZoneId, MinLevel, MaxLevel));

                    } break;

            }
        }
开发者ID:dzikun,项目名称:WarEmu,代码行数:52,代码来源:SocialHandlers.cs

示例5: F_RENAME_CHARACTER

        static public void F_RENAME_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(3);

            string OldName = packet.GetString(24);
            string NewName = packet.GetString(24);

            Log.Success("F_RENAME_CHARACTER", "Renaming: '" + OldName + "' To: '" + NewName + "'");

            if (NewName.Length > 2 && !CharMgr.NameIsUsed(NewName))
            {
                Character Char = CharMgr.GetCharacter(OldName);

                if (Char == null || Char.AccountId != cclient._Account.AccountId)
                {
                    Log.Error("CharacterRename", "Hack: Tried to rename character which account dosen't own");
                    cclient.Disconnect();
                    return;
                }

                Char.Name = NewName;
                CharMgr.Database.SaveObject(Char);

                // Wrong response? Perhaps needs to send F_REQUEST_CHAR_RESPONSE again.
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
            else
            {
                // Wrong response?
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
        }
开发者ID:dzikun,项目名称:WarEmu,代码行数:38,代码来源:CharacterHandlers.cs

示例6: F_CREATE_CHARACTER

        static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            CreateInfo Info;

            Info.slot = packet.GetUint8();
            Info.race = packet.GetUint8();
            Info.career = packet.GetUint8();
            Info.sex = packet.GetUint8();
            Info.model = packet.GetUint8();
            Info.NameSize = packet.GetUint16();
            packet.Skip(2);

            byte[] Traits = new byte[8];
            packet.Read(Traits, 0, Traits.Length);
            packet.Skip(7);

            string Name = packet.GetString(Info.NameSize);

            if (Name.Length > 2 && !CharMgr.NameIsUsed(Name))
            {
                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                }
                else
                {

                    Log.Success("OnCreate", "New Character : " + Name);

                    Character Char = new Character();
                    Char.AccountId = cclient._Account.AccountId;
                    Char.bTraits = Traits;
                    Char.Career = Info.career;
                    Char.CareerLine = CharInfo.CareerLine;
                    Char.ModelId = Info.model;
                    Char.Name = Name;
                    Char.Race = Info.race;
                    Char.Realm = CharInfo.Realm;
                    Char.RealmId = Program.Rm.RealmId;
                    Char.Sex = Info.sex;
                    Char.FirstConnect = true;

                    if (!CharMgr.CreateChar(Char))
                    {
                        Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    }
                    else
                    {

                        Character_item Citm = null;
                        List < CharacterInfo_item > Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                        foreach (CharacterInfo_item Itm in Items)
                        {
                            if (Itm == null)
                                continue;

                            Citm = new Character_item();
                            Citm.Counts = Itm.Count;
                            Citm.CharacterId = Char.CharacterId;
                            Citm.Entry = Itm.Entry;
                            Citm.ModelId = Itm.ModelId;
                            Citm.SlotId = Itm.SlotId;
                            CharMgr.CreateItem(Citm);
                        }

                        Character_value CInfo = new Character_value();
                        CInfo.CharacterId = Char.CharacterId;
                        CInfo.Level = 1;
                        CInfo.Money = 0;
                        CInfo.Online = false;
                        CInfo.RallyPoint = CharInfo.RallyPt;
                        CInfo.RegionId = CharInfo.Region;
                        CInfo.Renown = 0;
                        CInfo.RenownRank = 1;
                        CInfo.RestXp = 0;
                        CInfo.Skills = CharInfo.Skills;
                        CInfo.Speed = 100;
                        CInfo.WorldO = CharInfo.WorldO;
                        CInfo.WorldX = CharInfo.WorldX;
                        CInfo.WorldY = CharInfo.WorldY;
                        CInfo.WorldZ = CharInfo.WorldZ;
                        CInfo.Xp = 0;
                        CInfo.ZoneId = CharInfo.ZoneId;

                        CharMgr.Database.AddObject(CInfo);
                        Program.AcctMgr.UpdateRealmCharacters(Program.Rm.RealmId, (uint)CharMgr.Database.GetObjectCount<Character>(" Realm=1"), (uint)CharMgr.Database.GetObjectCount<Character>(" Realm=2"));

                        Char.Value = CInfo;

                        PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                        Out.WritePascalString(cclient._Account.Username);
                        cclient.SendPacket(Out);
                    }
                }
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:dzikun,项目名称:WarEmu,代码行数:101,代码来源:CharacterHandlers.cs

示例7: F_PLAYER_INFO

        public static void F_PLAYER_INFO(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null)
                return;

            if (!cclient.Plr.IsInWorld())
                return;

            packet.Skip(2);
            UInt16 Oid = packet.GetUint16();
            packet.Skip(1);
            byte Faction = packet.GetUint8();

            cclient.Plr.CbtInterface.SetTarget(cclient.Plr.Region.GetObject(Oid) as Unit);
        }
开发者ID:Necrosummon,项目名称:WarEmu,代码行数:17,代码来源:CombatHandlers.cs

示例8: BuildMail

        public void BuildMail(PacketIn packet)
        {
            Player Plr = GetPlayer();
            if (Plr == null)
                return;

            if (nextSend >= TCPServer.GetTimeStamp())
            {
                SendResult(GameData.MailResult.TEXT_MAIL_RESULT6);
                return;
            }

            // Recipient read
            packet.Skip(1);
            byte NameSize = packet.GetUint8();
            string Name = packet.GetString(NameSize);

            Character Receiver = CharMgr.GetCharacter(Name);

            if (Receiver == null)
            {
                SendResult(GameData.MailResult.TEXT_MAIL_RESULT7);
                return;
            }

            if (Receiver.Name == Plr.Name) // You cannot mail yourself
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEXT_PLAYER_CANT_MAIL_YOURSELF);
                return;
            }

            // Subject
            byte SubjectSize = packet.GetUint8();
            packet.Skip(1);
            string Subject = packet.GetString(SubjectSize);

            // Message
            byte MessageSize = packet.GetUint8();
            packet.Skip(1);
            string Message = packet.GetString(MessageSize);

            // Money
            UInt32 money = ByteOperations.ByteSwap.Swap(packet.GetUint32());

            // COD?
            byte cr = packet.GetUint8();

            // Item
            byte itemcounts = packet.GetUint8();

            if (!Plr.RemoveMoney((cr == 0 ? money : 0) + MAIL_PRICE))
            {
                SendResult(MailResult.TEXT_MAIL_RESULT8);
                return;
            }

            // Make a Mail
            Character_mail CMail = new Character_mail();
            CMail.Guid = CharMgr.GenerateMailGUID();
            CMail.CharacterId = Receiver.CharacterId;
            CMail.CharacterIdSender = Plr._Info.CharacterId;
            CMail.SenderName = Plr._Info.Name;
            CMail.ReceiverName = Name;
            CMail.Title = Subject;
            CMail.Content = Message;
            CMail.Money = money;
            CMail.Cr = true;
            CMail.Opened = false;

            Log.Debug("Mail", "Itemcount: " + itemcounts + "");

            for (byte i = 0; i < itemcounts; ++i)
            {
                UInt16 itmslot = ByteOperations.ByteSwap.Swap(packet.GetUint16());
                packet.Skip(2);

                ByteOperations.ByteSwap.Swap(itmslot);

                Item itm = Plr.ItmInterface.GetItemInSlot(itmslot);
                if (itm != null)
                {
                    CMail.ItemsReqInfo.Add(itm.CharItem);
                    Plr.ItmInterface.DeleteItem(itmslot, itm.CharItem.Counts, false);
                    itm.Owner = null;
                }

            }

            SendResult(MailResult.TEXT_MAIL_RESULT4);
            CharMgr.Database.AddObject(CMail);

            //If player exists let them know they have mail.
            Player mailToPlayer = Player.GetPlayer(Name);
            if (mailToPlayer != null)
                mailToPlayer.MlInterface.AddMail(CMail);

            nextSend = (uint)TCPServer.GetTimeStamp() + 5;
        }
开发者ID:JeFawk,项目名称:WarEmu,代码行数:98,代码来源:MailInterface.cs

示例9: F_MAIL

        public static void F_MAIL(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
                return;

            Player Plr = cclient.Plr;

            byte Type = packet.GetUint8();

            switch (Type)
            {
                case 0: // Mailbox closed
                    {

                    } break;
                case 1: // Mail sent
                    {
                        Plr.MlInterface.BuildMail(packet);
                    } break;
                case 2: // Open mail
                case 3: // Return mail
                case 4: // Delete mail
                case 5: // Mark as read/unread
                case 7: // Take Item
                case 8: // Take money
                    {
                        byte Page = packet.GetUint8();
                        UInt32 Guid = ByteOperations.ByteSwap.Swap(packet.GetUint32());

                        Character_mail Mail = Plr.MlInterface.GetMail(Guid);

                        switch (Type)
                        {
                            case 2:
                                if (!Mail.Opened)
                                {
                                    Mail.Opened = true;
                                    CharMgr.SaveMail(Mail);
                                    Plr.MlInterface.SendMailCounts();
                                    Plr.MlInterface.SendMailBox();
                                }
                                Plr.MlInterface.SendMail(Mail);
                                break;
                            case 3:
                                //TODO
                                Plr.MlInterface.SendResult(GameData.MailResult.TEXT_MAIL_RESULT11);
                                break;
                            case 4:
                                Plr.MlInterface.RemoveMail(Mail);
                                Plr.MlInterface.SendMailCounts();
                                Plr.MlInterface.SendMailBox();
                                break;
                            case 5:
                                packet.Skip(4);
                                Mail.Opened = (packet.GetUint8() == 1);
                                CharMgr.SaveMail(Mail);
                                Plr.MlInterface.SendMailCounts();
                                Plr.MlInterface.SendMailBox();
                                break;
                            case 7:
                                packet.Skip(4);
                                byte itemnum = packet.GetUint8();
                                if (Mail.ItemsReqInfo.Count < itemnum + 1)
                                    return;

                                UInt16 FreeSlot = Plr.ItmInterface.GetFreeInventorySlot();
                                if (FreeSlot == 0)
                                {
                                    Plr.SendLocalizeString("", GameData.Localized_text.TEXT_OVERAGE_CANT_TAKE_ATTACHMENTS);
                                    return;
                                }

                                Character_items item = Mail.ItemsReqInfo.ElementAt(itemnum);
                                Plr.ItmInterface.CreateItem(item.Entry, item.Counts);
                                Mail.ItemsReqInfo.Remove(item);

                                CharMgr.SaveMail(Mail);
                                Plr.MlInterface.SendMailUpdate(Mail);
                                Plr.MlInterface.SendMail(Mail);
                                break;
                            case 8:
                                if (Mail.Money > 0)
                                {
                                    Plr.AddMoney(Mail.Money);
                                    Mail.Money = 0;
                                }
                                // Take as many items as you can before inventory is full
                                foreach (Character_items curritem in Mail.ItemsReqInfo.ToArray())
                                {
                                    UInt16 Slot = Plr.ItmInterface.GetFreeInventorySlot();
                                    if (Slot == 0)
                                    {
                                        Plr.SendLocalizeString("", GameData.Localized_text.TEXT_OVERAGE_CANT_TAKE_ATTACHMENTS);
                                        break;
                                    }
                                    Plr.ItmInterface.CreateItem(curritem.Entry, curritem.Counts);
                                    Mail.ItemsReqInfo.Remove(curritem);
                                }
//.........这里部分代码省略.........
开发者ID:JeFawk,项目名称:WarEmu,代码行数:101,代码来源:MailHandlers.cs

示例10: F_PLAYER_ENTER_FULL

        public static void F_PLAYER_ENTER_FULL(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            UInt16 SID;
            byte unk1, serverID, characterSlot;

            SID = packet.GetUint16();
            unk1 = packet.GetUint8();
            serverID = packet.GetUint8();
            string CharName = packet.GetString(24);
            packet.Skip(2);
            string Language = packet.GetString(2);
            packet.Skip(4);
            characterSlot = packet.GetUint8();

            Log.Debug("F_PLAYER_ENTER_FULL", "Entrer en jeu de : " + CharName + ",Slot=" + characterSlot);

            if (Program.Rm.RealmId != serverID)
                cclient.Disconnect();
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.S_PID_ASSIGN);
                Out.WriteUInt16R((ushort)cclient.Id);
                cclient.SendPacket(Out);
            }
        }
开发者ID:nalgol,项目名称:WarEmu,代码行数:27,代码来源:MovementHandlers.cs

示例11: F_CREATE_CHARACTER

        public static void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            CreateInfo Info;

            Info.slot = packet.GetUint8();
            Info.race = packet.GetUint8();
            Info.career = packet.GetUint8();
            Info.sex = packet.GetUint8();
            Info.model = packet.GetUint8();
            Info.NameSize = packet.GetUint16();
            packet.Skip(2);

            byte[] Traits = new byte[8];
            packet.Read(Traits, 0, Traits.Length);
            packet.Skip(7);

            string Name = packet.GetString(Info.NameSize);

            if (!CharMgr.NameIsUsed(Name))
            {

                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                    return;
                }

                Log.Success("OnCreate", "Creating new Character : " + Name);

                Character Char = new Character();
                Char.AccountId = cclient._Account.AccountId;
                Char.bTraits = Traits;
                Char.Career = Info.career;
                Char.CareerLine = CharInfo.CareerLine;
                Char.ModelId = Info.model;
                Char.Name = Name;
                Char.Race = Info.race;
                Char.Realm = CharInfo.Realm;
                Char.RealmId = Program.Rm.RealmId;
                Char.Sex = Info.sex;

                if (!CharMgr.CreateChar(Char))
                {
                    Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    return;
                }

                Character_items Citm = null;
                CharacterInfo_item[] Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                for (int i = 0; i < Items.Length; ++i)
                {
                    if (Items[i] == null)
                        continue;

                    Citm = new Character_items();
                    Citm.Counts = Items[i].Count;
                    Citm.CharacterId = Char.CharacterId;
                    Citm.Entry = Items[i].Entry;
                    Citm.ModelId = Items[i].ModelId;
                    Citm.SlotId = Items[i].SlotId;
                    CharMgr.CreateItem(Citm);
                }

                Character_value CInfo = new Character_value();
                CInfo.CharacterId = Char.CharacterId;
                CInfo.Level = 1;
                CInfo.Money = 0;
                CInfo.Online = false;
                CInfo.RallyPoint = CharInfo.RallyPt;
                CInfo.RegionId = CharInfo.Region;
                CInfo.Renown = 0;
                CInfo.RenownRank = 1;
                CInfo.RestXp = 0;
                CInfo.Skills = CharInfo.Skills;
                CInfo.Speed = 100;
                CInfo.WorldO = CharInfo.WorldO;
                CInfo.WorldX = CharInfo.WorldX;
                CInfo.WorldY = CharInfo.WorldY;
                CInfo.WorldZ = CharInfo.WorldZ;
                CInfo.Xp = 0;
                CInfo.ZoneId = CharInfo.ZoneId;

                CharMgr.Database.AddObject(CInfo);

                Char.Value = new Character_value[1] { CInfo };
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
            Out.WritePascalString(cclient._Account.Username);
            cclient.SendTCP(Out);
        }
开发者ID:Necrosummon,项目名称:WarEmu,代码行数:94,代码来源:CharacterHandlers.cs


注:本文中的FrameWork.PacketIn.Skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。