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


C# PacketReader.ReadInt16方法代码示例

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


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

示例1: ExtendedPacket

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

            switch ( type )
            {
                case 0x04: // close gump
                {
                    // int serial, int tid
                    if ( World.Player != null )
                        World.Player.HasGump = false;
                    break;
                }
                case 0x06: // party messages
                {
                    OnPartyMessage( p, args );
                    break;
                }
                case 0x08: // map change
                {
                    if ( World.Player != null )
                        World.Player.Map = p.ReadByte();
                    break;
                }
                case 0x14: // context menu
                {
                    p.ReadInt16(); // 0x01
                    UOEntity ent = null;
                    Serial ser = p.ReadUInt32();
                    if ( ser.IsMobile )
                        ent = World.FindMobile( ser );
                    else if ( ser.IsItem )
                        ent = World.FindItem( ser );

                    if ( ent != null )
                    {
                        byte count = p.ReadByte();

                        try
                        {
                            ent.ContextMenu.Clear();

                            for(int i=0;i<count;i++)
                            {
                                ushort idx = p.ReadUInt16();
                                ushort num = p.ReadUInt16();
                                ushort flags = p.ReadUInt16();
                                ushort color = 0;

                                if ( (flags&0x02) != 0 )
                                    color = p.ReadUInt16();

                                ent.ContextMenu.Add( idx, num );
                            }
                        }
                        catch
                        {
                        }
                    }
                    break;
                }
                case 0x18: // map patches
                {
                    if ( World.Player != null )
                    {
                        int count = p.ReadInt32() * 2;
                        try
                        {
                            World.Player.MapPatches = new int[count];
                            for(int i=0;i<count;i++)
                                World.Player.MapPatches[i] = p.ReadInt32();
                        }
                        catch
                        {
                        }
                    }
                    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;
                }
                case 0x1D: // Custom House "General Info"
                {
                    Item i = World.FindItem( p.ReadUInt32() );
                    if ( i != null )
//.........这里部分代码省略.........
开发者ID:herculesjr,项目名称:razor,代码行数:101,代码来源:Handlers.cs

示例2: ServerChange

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

示例3: DropRequest

        private static void DropRequest( PacketReader p, PacketHandlerEventArgs args )
        {
            Serial iser = p.ReadUInt32();
            int x = p.ReadInt16();
            int y = p.ReadInt16();
            int z = p.ReadSByte();
            if ( Engine.UsePostKRPackets )
                /* grid num */p.ReadByte();
            Point3D newPos = new Point3D( x, y, z );
            Serial dser = p.ReadUInt32();

            if ( Macros.MacroManager.AcceptActions )
                MacroManager.Action( new DropAction( dser, newPos ) );

            Item i = World.FindItem( iser );
            if ( i == null )
                return;

            Item dest = World.FindItem( dser );
            if ( dest != null && dest.IsContainer && World.Player != null && ( dest.IsChildOf( World.Player.Backpack ) || dest.IsChildOf( World.Player.Quiver ) ) )
                i.IsNew = true;

            if ( Config.GetBool( "QueueActions" ) )
                args.Block = DragDropManager.Drop( i, dser, newPos );
        }
开发者ID:herculesjr,项目名称:razor,代码行数:25,代码来源:Handlers.cs

示例4: MobileStatus

        private static void MobileStatus( PacketReader p, PacketHandlerEventArgs args )
        {
            Serial serial = p.ReadUInt32();
            Mobile m = World.FindMobile( serial );
            if ( m == null )
                World.AddMobile( m = new Mobile( serial ) );

            m.Name = p.ReadString( 30 );

            m.Hits = p.ReadUInt16();
            m.HitsMax = p.ReadUInt16();

            p.ReadBoolean();//CanBeRenamed

            byte type = p.ReadByte();

            if ( m == World.Player && type != 0x00 )
            {
                PlayerData player = (PlayerData)m;

                player.Female = p.ReadBoolean();

                int oStr = player.Str, oDex = player.Dex, oInt = player.Int;

                player.Str = p.ReadUInt16();
                player.Dex = p.ReadUInt16();
                player.Int = p.ReadUInt16();

                if ( player.Str != oStr && oStr != 0 && Config.GetBool( "DisplaySkillChanges" ) )
                    World.Player.SendMessage( MsgLevel.Force, LocString.StrChanged, player.Str - oStr > 0 ? "+" : "", player.Str - oStr, player.Str );

                if ( player.Dex != oDex && oDex != 0 && Config.GetBool( "DisplaySkillChanges" ) )
                    World.Player.SendMessage( MsgLevel.Force, LocString.DexChanged, player.Dex - oDex > 0 ? "+" : "", player.Dex - oDex, player.Dex );

                if ( player.Int != oInt && oInt != 0 && Config.GetBool( "DisplaySkillChanges" ) )
                    World.Player.SendMessage( MsgLevel.Force, LocString.IntChanged, player.Int - oInt > 0 ? "+" : "", player.Int - oInt, player.Int );

                player.Stam = p.ReadUInt16();
                player.StamMax = p.ReadUInt16();
                player.Mana = p.ReadUInt16();
                player.ManaMax = p.ReadUInt16();

                player.Gold = p.ReadUInt32();
                player.AR = p.ReadUInt16(); // ar / physical resist
                player.Weight = p.ReadUInt16();

                if ( type >= 0x03 )
                {
                    if ( type > 0x04 )
                    {
                        player.MaxWeight = p.ReadUInt16();

                        p.ReadByte(); // race?
                    }

                    player.StatCap = p.ReadUInt16();

                    if ( type > 0x03 )
                    {
                        player.Followers = p.ReadByte();
                        player.FollowersMax = p.ReadByte();

                        player.FireResistance = p.ReadInt16();
                        player.ColdResistance = p.ReadInt16();
                        player.PoisonResistance = p.ReadInt16();
                        player.EnergyResistance = p.ReadInt16();

                        player.Luck = p.ReadInt16();

                        player.DamageMin = p.ReadUInt16();
                        player.DamageMax = p.ReadUInt16();

                        player.Tithe = p.ReadInt32();
                    }
                }

                ClientCommunication.RequestTitlebarUpdate();

                ClientCommunication.PostHitsUpdate();
                ClientCommunication.PostStamUpdate();
                ClientCommunication.PostManaUpdate();

                Engine.MainWindow.UpdateTitle(); // update player name
            }
        }
开发者ID:herculesjr,项目名称:razor,代码行数:85,代码来源:Handlers.cs

示例5: RunUOProtocolExtention

        private static void RunUOProtocolExtention(PacketReader p, PacketHandlerEventArgs args)
        {
            args.Block = true;

            switch (p.ReadByte())
            {
                case 1: // Custom Party information
                {
                    Serial serial;

                    PacketHandlers.SpecialPartyReceived++;

                    while ((serial = p.ReadUInt32()) > 0)
                    {
                        Mobile mobile = World.FindMobile(serial);

                        short x = p.ReadInt16();
                        short y = p.ReadInt16();
                        byte map = p.ReadByte();

                        if (mobile == null)
                        {
                            World.AddMobile( mobile = new Mobile(serial) );
                            mobile.Visible = false;
                        }

                        if ( mobile.Name == null || mobile.Name.Length <= 0 )
                            mobile.Name = "(Not Seen)";

                        if ( !m_Party.Contains( serial ) )
                            m_Party.Add( serial );

                        if ( map == World.Player.Map )
                            mobile.Position = new Point3D(x, y, mobile.Position.Z);
                        else
                            mobile.Position = Point3D.Zero;
                    }

                    if (Engine.MainWindow.MapWindow != null)
                        Engine.MainWindow.MapWindow.UpdateMap();

                    break;
                }
                case 0xFE: // Begin Handshake/Features Negotiation
                {
                    ulong features = p.ReadRawUInt64();

                    if ( ClientCommunication.HandleNegotiate( features ) != 0 )
                    {
                        ClientCommunication.SendToServer( new RazorNegotiateResponse() );
                        Engine.MainWindow.UpdateControlLocks();
                    }
                    break;
                }
            }
        }
开发者ID:herculesjr,项目名称:razor,代码行数:56,代码来源:Handlers.cs

示例6: LoginConfirm

        private static void LoginConfirm( PacketReader p, PacketHandlerEventArgs args )
        {
            World.Items.Clear();
            World.Mobiles.Clear();

            UseNewStatus = false;

            Serial serial = p.ReadUInt32();

            PlayerData m = new PlayerData( serial );
            m.Name = World.OrigPlayerName;

            Mobile test = World.FindMobile( serial );
            if ( test != null )
                test.Remove();

            World.AddMobile( World.Player = m );
            Config.LoadProfileFor( World.Player );

            PlayerData.ExternalZ = false;

            p.ReadUInt32(); // always 0?
            m.Body = p.ReadUInt16();
            m.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadInt16() );
            m.Direction = (Direction)p.ReadByte();
            m.Resync();

            //ClientCommunication.SendToServer( new SkillsQuery( m ) );
            //ClientCommunication.SendToServer( new StatusQuery( m ) );

            ClientCommunication.RequestTitlebarUpdate();
            ClientCommunication.PostLogin( (int)serial.Value );
            Engine.MainWindow.UpdateTitle(); // update player name & shard name
            /*
            //the rest of the packet: (total length: 37)
            m_Stream.Write( (byte) 0 );
            m_Stream.Write( (int) -1 );

            m_Stream.Write( (short) 0 );
            m_Stream.Write( (short) 0 );
            m_Stream.Write( (short) (map==null?6144:map.Width) );
            m_Stream.Write( (short) (map==null?4096:map.Height) );

            Stream.Fill();
            */

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

示例7: DropRequest

        private static void DropRequest(PacketReader p, PacketHandlerEventArgs args)
        {
            Serial serial = p.ReadUInt32();
            int x = p.ReadInt16();
            int y = p.ReadInt16();
            int z = p.ReadSByte();
            Item container = World.FindItem(p.ReadUInt32());

            if (items.ContainsKey(serial))
            {
                args.Block = true;
                FakeItem fake = items[serial];
                if (container == World.Player.Backpack)
                    fake.Position = new Point3D(x, y, z);
                else
                    foreach (Serial s in fake.List.Take(lifting))
                        DragDrop.Move(World.FindItem(s), container);
                lifting = 0;
                Resend();
            }
            else
                args.Block = PacketHandler.ProcessViewers(dropRequest, p);
        }
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:23,代码来源:PotionStack.cs

示例8: ImportObjects

        private void ImportObjects(string[] args, int length, string full, Client client)
        {
            string zone = args[1];
            string folder = args[2];

            var packetList = Directory.GetFiles(folder);
            Array.Sort(packetList);

            List<GameObject> newObjects = new List<GameObject>();
            foreach (var path in packetList)
            {
                var data = File.ReadAllBytes(path);
                PacketReader reader = new PacketReader(data);
                PacketHeader header = reader.ReadStruct<PacketHeader>();
                if (header.Type != 0x8 || header.Subtype != 0xB)
                {
                    Logger.WriteWarning("[WRN] File {0} not an Object spawn packet, skipping.", path);
                    continue;
                }

                GameObject newObj = new GameObject();
                newObj.ObjectID = (int)reader.ReadStruct<ObjectHeader>().ID;
                var pos = reader.ReadEntityPosition();
                newObj.RotX = pos.RotX;
                newObj.RotY = pos.RotY;
                newObj.RotZ = pos.RotZ;
                newObj.RotW = pos.RotW;

                newObj.PosX = pos.PosX;
                newObj.PosY = pos.PosY;
                newObj.PosZ = pos.PosZ;
                reader.ReadInt16();
                newObj.ObjectName = reader.ReadFixedLengthAscii(0x2C);
                var objHeader = reader.ReadStruct<ObjectHeader>(); // Seems to always be blank...
                if (objHeader.ID != 0)
                    Logger.WriteWarning("[OBJ] It seems object {0} has a nonzero objHeader! ({1}) Investigate.", newObj.ObjectName, objHeader.ID);
                newObj.ZoneName = zone;
                var thingCount = reader.ReadUInt32();
                newObj.ObjectFlags = new byte[thingCount * 4];
                for (int i = 0; i < thingCount; i++)
                {
                    Buffer.BlockCopy(BitConverter.GetBytes(reader.ReadUInt32()), 0, newObj.ObjectFlags, i * 4, 4); // This should work
                }
                newObjects.Add(newObj);
                Logger.WriteInternal("[OBJ] Adding new Object {0} to the database for zone {1}", newObj.ObjectName, zone);
            }

            using (var db = new PolarisEf())
            {
                db.GameObjects.AddRange(newObjects);
                db.SaveChanges();
            }
        }
开发者ID:mattkloc,项目名称:PolarisServer,代码行数:53,代码来源:ConsoleSystem.cs

示例9: ImportNPCs

        private void ImportNPCs(string[] args, int length, string full, Client client)
        {
            string zone = args[1];
            string folder = args[2];

            var packetList = Directory.GetFiles(folder);
            Array.Sort(packetList);

            List<NPC> newNPCs = new List<NPC>();
            foreach (var path in packetList)
            {
                var data = File.ReadAllBytes(path);
                PacketReader reader = new PacketReader(data);
                PacketHeader header = reader.ReadStruct<PacketHeader>();
                if (header.Type != 0x8 || header.Subtype != 0xC)
                {
                    Logger.WriteWarning("[WRN] File {0} not an NPC spawn packet, skipping.", path);
                    continue;
                }

                NPC newNPC = new NPC();
                newNPC.EntityID = (int)reader.ReadStruct<ObjectHeader>().ID;
                var pos = reader.ReadEntityPosition();
                newNPC.RotX = pos.RotX;
                newNPC.RotY = pos.RotY;
                newNPC.RotZ = pos.RotZ;
                newNPC.RotW = pos.RotW;

                newNPC.PosX = pos.PosX;
                newNPC.PosY = pos.PosY;
                newNPC.PosZ = pos.PosZ;
                reader.ReadInt16();
                newNPC.NPCName = reader.ReadFixedLengthAscii(0x20);
                newNPC.ZoneName = zone;
                newNPCs.Add(newNPC);
                Logger.WriteInternal("[NPC] Adding new NPC {0} to the database for zone {1}", newNPC.NPCName, zone);
            }

            using (var db = new PolarisEf())
            {
                db.NPCs.AddRange(newNPCs);
                db.SaveChanges();
            }
        }
开发者ID:mattkloc,项目名称:PolarisServer,代码行数:44,代码来源:ConsoleSystem.cs

示例10: ServerChange

 private static void ServerChange( PacketReader p )
 {
     World.Player.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadInt16() );
 }
开发者ID:herculesjr,项目名称:razor,代码行数:4,代码来源:Handlers.cs


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