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


C# PacketReader.ReadUInt16方法代码示例

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


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

示例1: Read

        /// <summary>
        /// The read.
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <param name="packet">
        /// </param>
        public static void Read(Client client, byte[] packet)
        {
            // TODO: Fix this mess.
            ushort data_length = BitConverter.ToUInt16(new[] { packet[3], packet[2] }, 0);
            byte[] sender_ID = BitConverter.GetBytes(client.Character.characterId);
            Array.Reverse(sender_ID);
            MemoryStream m_stream = new MemoryStream();
            m_stream.Write(packet, 0, 9);
            m_stream.Write(sender_ID, 0, 4);
            m_stream.Write(packet, 9, packet.Length - 9);
            m_stream.Capacity = (int)m_stream.Length;
            byte[] message = m_stream.GetBuffer();
            byte[] new_length = BitConverter.GetBytes(message.Length - 4);
            message[2] = new_length[1];
            message[3] = new_length[0];
            m_stream.Close();
            m_stream.Dispose();

            foreach (Client m_client in client.Server.Clients)
            {
                if (!m_client.KnownClients.Contains(client.Character.characterId))
                {
                    byte[] pname = PlayerName.New(client, client.Character.characterId);
                    m_client.Send(pname);
                    m_client.KnownClients.Add(client.Character.characterId);
                }

                m_client.Send(message);
            }

            PacketReader reader = new PacketReader(ref packet);
            reader.ReadUInt16();
            reader.ReadUInt16();
            reader.ReadUInt16();
            reader.ReadUInt16();
            reader.ReadByte();
            string text = reader.ReadString();
            string channelName = ChatChannels.GetChannel(packet).Name;
            ChatLogger.WriteString(channelName, text, client.Character.characterName);
        }
开发者ID:gordonc64,项目名称:CellAO-Archived-Obsolete,代码行数:47,代码来源:ChannelMessage.cs

示例2: OnHuedEffect

 private static void OnHuedEffect(PacketReader p, PacketHandlerEventArgs args)
 {
     byte type = p.ReadByte();
     Serial src = p.ReadUInt32();
     Serial dest = p.ReadUInt32();
     ItemID itemID = p.ReadUInt16();
     p.Seek(10, SeekOrigin.Current);
     byte speed = p.ReadByte();
     byte count = p.ReadByte();
     p.ReadUInt32();
     uint hue = p.ReadUInt32();
     uint mode = p.ReadUInt32();
     Handle(huedEffect, args, type, src, dest, itemID, speed, count, hue, mode);
 }
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:14,代码来源:Event.Others.cs

示例3: EquipmentUpdate

        private static void EquipmentUpdate( PacketReader p )
        {
            Serial serial = p.ReadUInt32();

            Item i = World.FindItem( serial );
            if ( i == null )
            {
                World.AddItem( i=new Item( serial ) );
                Item.UpdateContainers();
            }

            if ( World.Player != null && World.Player.Holding == i )
                World.Player.Holding = null;

            ushort iid = p.ReadUInt16();
            i.ItemID = (ushort)(iid + p.ReadSByte()); // signed, itemID offset
            i.Layer = p.ReadByte();
            Serial ser = p.ReadUInt32();// cont must be set after hue (for counters)
            i.Hue = p.ReadUInt16();

            i.Container = ser;
        }
开发者ID:herculesjr,项目名称:razor,代码行数:22,代码来源:Handlers.cs

示例4: WorldItem

        private static void WorldItem( PacketReader p )
        {
            Item item;
            uint serial = p.ReadUInt32();
            item = World.FindItem( serial&0x7FFFFFFF );
            if ( item == null )
            {
                World.AddItem( item=new Item( serial&0x7FFFFFFF ) );
            }

            item.Container = null;
            if ( World.Player.Holding == item )
                World.Player.Holding = null;

            ushort itemID = p.ReadUInt16();
            item.ItemID = (ushort)(itemID&0x7FFF);

            if ( (serial & 0x80000000) != 0 )
                item.Amount = p.ReadUInt16();
            else
                item.Amount = 0;

            if ( (itemID & 0x8000) != 0 )
                item.ItemID = (ushort)(item.ItemID + p.ReadSByte());

            ushort x = p.ReadUInt16();
            ushort y = p.ReadUInt16();

            if ( (x & 0x8000) != 0 )
                item.Direction = p.ReadByte();
            else
                item.Direction = 0;

            short z = p.ReadSByte();

            item.Position = new Point3D( x&0x3FFF, y&0x3FFF, z );

            if ( ( y & 0x8000 ) != 0 )
                item.Hue = p.ReadUInt16();
            else
                item.Hue = 0;

            byte flags = 0;
            if ( ( y & 0x4000 ) != 0 )
                flags = p.ReadByte();

            item.ProcessPacketFlags( flags );

            Item.UpdateContainers();
        }
开发者ID:herculesjr,项目名称:razor,代码行数:50,代码来源:Handlers.cs

示例5: ClientGumpResponse

        private static void ClientGumpResponse( PacketReader p, PacketHandlerEventArgs args )
        {
            if ( World.Player == null )
                return;

            Serial ser = p.ReadUInt32();
            uint tid = p.ReadUInt32();
            int bid = p.ReadInt32();

            World.Player.HasGump = false;

            int sc = p.ReadInt32();
            if ( sc < 0 || sc > 2000 )
                return;
            int[] switches = new int[sc];
            for(int i=0;i<sc;i++)
                switches[i] = p.ReadInt32();

            int ec = p.ReadInt32();
            if ( ec < 0 || ec > 2000 )
                return;
            GumpTextEntry[] entries = new GumpTextEntry[ec];
            for(int i=0;i<ec;i++)
            {
                ushort id = p.ReadUInt16();
                ushort len = p.ReadUInt16();
                if ( len >= 240 )
                    return;
                string text = p.ReadUnicodeStringSafe( len );
                entries[i] = new GumpTextEntry( id, text );
            }

            if ( Macros.MacroManager.AcceptActions )
                MacroManager.Action( new GumpResponseAction( bid, switches, entries ) );
        }
开发者ID:herculesjr,项目名称:razor,代码行数:35,代码来源:Handlers.cs

示例6: WorldItem

        private static void WorldItem( PacketReader p, PacketHandlerEventArgs args )
        {
            Item item;
            uint serial = p.ReadUInt32();
            item = World.FindItem( serial&0x7FFFFFFF );
            bool isNew = false;
            if ( item == null )
            {
                World.AddItem( item=new Item( serial&0x7FFFFFFF ) );
                isNew = true;
            }
            else
            {
                item.CancelRemove();
            }

            if ( !DragDropManager.EndHolding( serial ) )
                return;

            item.Container = null;
            Counter.Uncount( item );

            ushort itemID = p.ReadUInt16();
            item.ItemID = (ushort)(itemID&0x7FFF);

            if ( (serial & 0x80000000) != 0 )
                item.Amount = p.ReadUInt16();
            else
                item.Amount = 1;

            if ( (itemID & 0x8000) != 0 )
                item.ItemID = (ushort)(item.ItemID + p.ReadSByte());

            ushort x = p.ReadUInt16();
            ushort y = p.ReadUInt16();

            if ( (x & 0x8000) != 0 )
                item.Direction = p.ReadByte();
            else
                item.Direction = 0;

            short z = p.ReadSByte();

            item.Position = new Point3D( x&0x7FFF, y&0x3FFF, z );

            if ( ( y & 0x8000 ) != 0 )
                item.Hue = p.ReadUInt16();
            else
                item.Hue = 0;

            byte flags = 0;
            if ( ( y & 0x4000 ) != 0 )
                flags = p.ReadByte();

            item.ProcessPacketFlags( flags );

            if ( isNew && World.Player != null )
            {
                if ( item.ItemID == 0x2006 )// corpse itemid = 0x2006
                {
                    if ( Config.GetBool( "ShowCorpseNames" ) )
                        ClientCommunication.SendToServer( new SingleClick( item ) );
                    if ( Config.GetBool( "AutoOpenCorpses" ) && Utility.InRange( item.Position, World.Player.Position, Config.GetInt( "CorpseRange" ) ) && World.Player != null && World.Player.Visible )
                        PlayerData.DoubleClick( item ) ;
                }
                else if ( item.IsMulti )
                {
                    ClientCommunication.PostAddMulti( item.ItemID, item.Position );
                }
                else
                {
                    ScavengerAgent s = ScavengerAgent.Instance;
                    int dist = Utility.Distance( item.GetWorldPosition(), World.Player.Position );
                    if ( !World.Player.IsGhost && World.Player.Visible && dist <= 2 && s.Enabled && item.Movable )
                        s.Scavenge( item );
                }
            }

            Item.UpdateContainers();
        }
开发者ID:herculesjr,项目名称:razor,代码行数:80,代码来源:Handlers.cs

示例7: Skills

        private static void Skills( PacketReader p, PacketHandlerEventArgs args )
        {
            if ( World.Player == null || World.Player.Skills == null || Engine.MainWindow == null )
                return;

            byte type = p.ReadByte();

            switch ( type )
            {
                case 0x02://list (with caps, 3.0.8 and up)
                {
                    int i;
                    while ( (i = p.ReadUInt16()) > 0 )
                    {
                        if ( i>0 && i <= Skill.Count )
                        {
                            Skill skill = World.Player.Skills[i-1];

                            if ( skill == null )
                                continue;

                            skill.FixedValue = p.ReadUInt16();
                            skill.FixedBase = p.ReadUInt16();
                            skill.Lock = (LockType)p.ReadByte();
                            skill.FixedCap = p.ReadUInt16();
                            if ( !World.Player.SkillsSent )
                                skill.Delta = 0;
                            ClientCommunication.PostSkillUpdate( i-1, skill.FixedBase );
                        }
                        else
                        {
                            p.Seek( 7, SeekOrigin.Current );
                        }
                    }

                    World.Player.SkillsSent = true;
                    Engine.MainWindow.RedrawSkills();
                    break;
                }

                case 0x00: // list (without caps, older clients)
                {
                    int i;
                    while ( (i = p.ReadUInt16()) > 0 )
                    {
                        if ( i>0 && i <= Skill.Count )
                        {
                            Skill skill = World.Player.Skills[i-1];

                            if ( skill == null )
                                continue;

                            skill.FixedValue = p.ReadUInt16();
                            skill.FixedBase = p.ReadUInt16();
                            skill.Lock = (LockType)p.ReadByte();
                            skill.FixedCap = 100;//p.ReadUInt16();
                            if ( !World.Player.SkillsSent )
                                skill.Delta = 0;

                            ClientCommunication.PostSkillUpdate( i-1, skill.FixedBase );
                        }
                        else
                        {
                            p.Seek( 5, SeekOrigin.Current );
                        }
                    }

                    World.Player.SkillsSent = true;
                    Engine.MainWindow.RedrawSkills();
                    break;
                }

                case 0xDF: //change (with cap, new clients)
                {
                    int i = p.ReadUInt16();

                    if ( i >= 0 && i < Skill.Count )
                    {
                        Skill skill = World.Player.Skills[i];

                        if ( skill == null )
                            break;

                        ushort old = skill.FixedBase;
                        skill.FixedValue = p.ReadUInt16();
                        skill.FixedBase = p.ReadUInt16();
                        skill.Lock = (LockType)p.ReadByte();
                        skill.FixedCap = p.ReadUInt16();
                        Engine.MainWindow.UpdateSkill( skill );

                        if ( Config.GetBool( "DisplaySkillChanges" ) && skill.FixedBase != old )
                            World.Player.SendMessage( MsgLevel.Force, LocString.SkillChanged, (SkillName)i, skill.Delta > 0 ? "+" : "", skill.Delta, skill.Value, skill.FixedBase - old > 0 ? "+" : "", ((double)( skill.FixedBase - old )) / 10.0 );
                        ClientCommunication.PostSkillUpdate( i, skill.FixedBase );
                    }
                    break;
                }

                case 0xFF: //change (without cap, older clients)
                {
                    int i = p.ReadUInt16();
//.........这里部分代码省略.........
开发者ID:herculesjr,项目名称:razor,代码行数:101,代码来源:Handlers.cs

示例8: ServerList

        private static void ServerList( PacketReader p, PacketHandlerEventArgs args )
        {
            p.ReadByte(); //unknown
            ushort numServers = p.ReadUInt16();

            for ( int i = 0; i < numServers; ++i )
            {
                ushort num = p.ReadUInt16();
                World.Servers[num] = p.ReadString( 32 );
                p.ReadByte(); // full %
                p.ReadSByte(); // time zone
                p.ReadUInt32(); // ip
            }
        }
开发者ID:herculesjr,项目名称:razor,代码行数:14,代码来源:Handlers.cs

示例9: SendMenu

        private static void SendMenu( PacketReader p, PacketHandlerEventArgs args )
        {
            if ( World.Player == null )
                return;

            World.Player.CurrentMenuS = p.ReadUInt32();
            World.Player.CurrentMenuI = p.ReadUInt16();
            World.Player.HasMenu = true;
            if ( MacroManager.AcceptActions && MacroManager.Action( new WaitForMenuAction( World.Player.CurrentMenuI ) ) )
                args.Block = true;
        }
开发者ID:herculesjr,项目名称:razor,代码行数:11,代码来源:Handlers.cs

示例10: PlayServer

        private static void PlayServer( PacketReader p, PacketHandlerEventArgs args )
        {
            ushort index = p.ReadUInt16();

            World.ShardName = World.Servers[index] as string;
            if ( World.ShardName == null )
                World.ShardName = "[Unknown]";
        }
开发者ID:herculesjr,项目名称:razor,代码行数:8,代码来源:Handlers.cs

示例11: Features

 private static void Features( PacketReader p, PacketHandlerEventArgs args )
 {
     if ( World.Player != null )
         World.Player.Features = p.ReadUInt16();
 }
开发者ID:herculesjr,项目名称:razor,代码行数:5,代码来源:Handlers.cs

示例12: Recv


//.........这里部分代码省略.........
                }

                if (incoming_buffers_tmp.Count > 0)
                {
                    foreach (TransferBuffer buffer in incoming_buffers_tmp)
                    {
                        bool packet_encrypted = false;

                        int packet_size = buffer.Buffer[1] << 8 | buffer.Buffer[0];
                        if ((packet_size & 0x8000) > 0)
                        {
                            if (m_security_flags.blowfish == 1)
                            {
                                packet_size &= 0x7FFF;
                                packet_encrypted = true;
                            }
                            else
                            {
                                packet_size &= 0x7FFF;
                            }
                        }

                        if (packet_encrypted)
                        {
                            byte[] decrypted = m_blowfish.Decode(buffer.Buffer, 2, buffer.Size - 2);
                            byte[] new_buffer = new byte[6 + packet_size];
                            Buffer.BlockCopy(BitConverter.GetBytes((ushort)packet_size), 0, new_buffer, 0, 2);
                            Buffer.BlockCopy(decrypted, 0, new_buffer, 2, 4 + packet_size);
                            buffer.Buffer = null;
                            buffer.Buffer = new_buffer;
                        }

                        PacketReader packet_data = new PacketReader(buffer.Buffer);
                        packet_size = packet_data.ReadUInt16();
                        ushort packet_opcode = packet_data.ReadUInt16();
                        byte packet_security_count = packet_data.ReadByte();
                        byte packet_security_crc = packet_data.ReadByte();

                        // Client object whose bytes the server might need to verify
                        if (m_client_security)
                        {
                            if (m_security_flags.security_bytes == 1)
                            {
                                byte expected_count = GenerateCountByte(true);
                                if (packet_security_count != expected_count)
                                {
                                    //throw (new Exception("[SecurityAPI::Recv] Count byte mismatch on {packet_opcode.ToString("X4")}."));
                                    StaticLogger.Instance.Warn($"[SecurityAPI::Recv] Count byte mismatch on {packet_opcode.ToString("X4")}. (Expected: {expected_count}, Packet: {packet_security_count})");
                                }

                                if (packet_encrypted || (m_security_flags.security_bytes == 1 && m_security_flags.blowfish == 0))
                                {
                                    if (packet_encrypted || m_enc_opcodes.Contains(packet_opcode))
                                    {
                                        packet_size |= 0x8000;
                                        Buffer.BlockCopy(BitConverter.GetBytes((ushort)packet_size), 0, buffer.Buffer, 0, 2);
                                    }
                                }

                                buffer.Buffer[5] = 0;

                                byte expected_crc = GenerateCheckByte(buffer.Buffer);
                                if (packet_security_crc != expected_crc)
                                {
                                    //throw (new Exception("[SecurityAPI::Recv] CRC byte mismatch."));
                                    StaticLogger.Instance.Warn($"[SecurityAPI::Recv] CRC byte mismatch on {packet_opcode.ToString("X4")}. (Expected: {expected_crc}, Packet: {packet_security_crc})");
开发者ID:GoneUp,项目名称:ModuleFilter,代码行数:67,代码来源:SecurityManager.cs

示例13: LiftRequest

 private static void LiftRequest(PacketReader p, PacketHandlerEventArgs args)
 {
     Serial serial = p.ReadUInt32();
     if (items.ContainsKey(serial))
     {
         lifting = p.ReadUInt16();
         args.Block = true;
         WorldEx.SendToClient(new RemoveObject(serial));
     }
     else
         args.Block = PacketHandler.ProcessViewers(liftRequest, p);
 }
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:12,代码来源:PotionStack.cs

示例14: FromPacketBin

        internal static PSOObject FromPacketBin(byte[] v)
        {
            PacketReader reader = new PacketReader(v);
            PSOObject obj = new PSOObject();
            reader.ReadStruct<PacketHeader>(); //Skip over header
            obj.Header = reader.ReadStruct<ObjectHeader>();
            obj.Position = reader.ReadEntityPosition();
            reader.ReadUInt16(); // Seek 2
            obj.Name = reader.ReadFixedLengthAscii(0x34);
            obj.ThingFlag = reader.ReadUInt32();
            uint thingCount = reader.ReadUInt32();
            obj.Things = new PSOObjectThing[thingCount];
            for (int i = 0; i < thingCount; i++)
            {
                obj.Things[i] = reader.ReadStruct<PSOObjectThing>();
            }

            return obj;
        }
开发者ID:ChowZenki,项目名称:PolarisServer,代码行数:19,代码来源:PSOObject.cs

示例15: ExtendedPacket

        private static void ExtendedPacket( PacketReader p )
        {
            ushort type = p.ReadUInt16();

            switch ( type )
            {
                case 0x04: // close gump
                {
                    // int serial, int tid
                    World.Player.HasGump = false;
                    break;
                }
                case 0x08: // map change
                {
                    if ( World.Player != null )
                        World.Player.Map = p.ReadByte();
                    break;
                }
                case 0x10: // object property list info
                {
                    //args.Block = true;
                    //ClientCommunication.SendToServer( new OPLInfoPacket( p.ReadUInt32(), p.ReadInt32() ) );
                    break;
                }
                case 0x18: // map patches
                {
                    int count = p.ReadInt32() * 2;
                    for(int i=0;i<count;i++)
                        World.Player.MapPatches[i] = p.ReadInt32();
                    break;
                }
                case 0x19: //  stat locks
                {
                    if ( p.ReadByte() == 0x02 )
                    {
                        Mobile m = World.FindMobile( p.ReadUInt32() );
                        if ( World.Player == m && m != null )
                        {
                            p.ReadByte();// 0?

                            byte locks = p.ReadByte();

                            World.Player.StrLock = (LockType)((locks>>4) & 3);
                            World.Player.DexLock = (LockType)((locks>>2) & 3);
                            World.Player.IntLock = (LockType)(locks & 3);
                        }
                    }
                    break;
                }
            }
        }
开发者ID:herculesjr,项目名称:razor,代码行数:51,代码来源:Handlers.cs


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