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


C# PacketReader.ReadInt32方法代码示例

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


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

示例1: OnCompressedGump

 private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e)
 {
     p.MoveToData();
     uint sender = p.ReadUInt32();
     uint id = p.ReadUInt32();
     if (id == responseID)
         _responseSender = sender;
     if (id != compressedID)
         return;
     p.Seek(19, SeekOrigin.Begin);
     p.Seek(p.ReadInt32(), SeekOrigin.Current);
     int lines = p.ReadInt32(), cLen = p.ReadInt32(), dLen = p.ReadInt32();
     if (cLen < 5)
         return;
     byte[] buffer = new byte[dLen];
     ZLib.uncompress(buffer, ref dLen, p.CopyBytes(p.Position, cLen - 4), cLen - 4);
     string afk = string.Empty;
     for (int i = 0, pos = 0; i < lines; i++)
     {
         int strLen = (buffer[pos++] << 8) | buffer[pos++];
         string str = Encoding.BigEndianUnicode.GetString(buffer, pos, strLen * 2);
         int index = str.IndexOf('>');
         if (index != -1 && index < str.Length - 1)
             afk += str[index + 1].ToString().ToUpper().Normalize(NormalizationForm.FormD)[0];
         pos += strLen * 2;
     }
     afk = afk.Trim();
     if (afk.Length == 5 && _responseSender != 0)
     {
         /*ClientCommunication.SendToClient(new CloseGump(responseID));
         WorldEx.SendToServer(new GumpResponse(responseSender, responseID, 0x310, new int[0], new[] { new GumpTextEntry(0x310, afk) }));
         responseSender = 0;*/
         WorldEx.OverHeadMessage(afk);
     }
 }
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:35,代码来源:AFK.cs

示例2: OnServerInfo

		private static void OnServerInfo(Client client, PacketReader reader){
			//服务器信息
			Program.Config.ChatPort = reader.ReadInt32();
			Program.Config.DuelPort = reader.ReadInt32();
			Program.Config.NeedAuth = reader.ReadBoolean();
            client.Pwd = reader.ReadUnicode(32);
#if DEBUG
			MessageBox.Show(Program.Config.ChatPort+":"+Program.Config.DuelPort+":"+Program.Config.NeedAuth + ":" + client.Pwd);
#endif
            client.OnLoginOk();
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:ClientEvent.cs

示例3: OnCompressedGump

        private static void OnCompressedGump(PacketReader p, PacketHandlerEventArgs e)
        {
            p.Seek(7, SeekOrigin.Begin);
            if (p.ReadUInt32() != 0x1105B263)
                return;

            p.Seek(19, SeekOrigin.Begin);
            p.Seek(p.ReadInt32() + 4, SeekOrigin.Current);
            int cLen = p.ReadInt32(), dLen = p.ReadInt32();
            byte[] buffer = new byte[dLen];
            ZLib.uncompress(buffer, ref dLen, p.CopyBytes(p.Position, cLen - 4), cLen - 4);
            int strLen = (buffer[0] << 8) | buffer[1];
            string[] str = Encoding.BigEndianUnicode.GetString(buffer, 2, strLen * 2).Split(',');

            string[] lat = str[0].Split('°');
            int yLat = int.Parse(lat[0]);
            int yMins = int.Parse(lat[1].Split('\'')[0]);
            bool ySouth = lat[1][lat[1].Length - 1] == 'S';

            string[] lon = str[1].Split('°');
            int xLong = int.Parse(lon[0]);
            int xMins = int.Parse(lon[1].Split('\'')[0]);
            bool xEast = lon[1][lon[1].Length - 1] == 'E';

            const int xWidth = 5120;
            const int yHeight = 4096;
            const int xCenter = 1323;
            const int yCenter = 1624;

            double absLong = xLong + ((double)xMins / 60);
            double absLat = yLat + ((double)yMins / 60);

            if (!xEast)
                absLong = 360.0 - absLong;

            if (!ySouth)
                absLat = 360.0 - absLat;

            int x = xCenter + (int)((absLong * xWidth) / 360);
            int y = yCenter + (int)((absLat * yHeight) / 360);

            if (x < 0)
                x += xWidth;
            else if (x >= xWidth)
                x -= xWidth;

            if (y < 0)
                y += yHeight;
            else if (y >= yHeight)
                y -= yHeight;

            onGump(x, y);
        }
开发者ID:jaryn-kubik,项目名称:RazorEx,代码行数:53,代码来源:SOS.cs

示例4: HandlePacket

        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            var reader = new PacketReader(data);
            var id = reader.ReadInt32();

            Logger.Write("[CHR] {0} is deleting character with ID {1}", context.User.Username, id);

            // Delete Character
            using (var db = new PolarisEf())
            {

                foreach (var character in db.Characters)
                    if (character.CharacterId == id)
                    {
                        db.Characters.Remove(character);
                        db.ChangeTracker.DetectChanges();
                        break;
                    }

                // Detect the deletion and save the Database
                if (db.ChangeTracker.HasChanges())
                    db.SaveChanges();
            }

            // Disconnect for now
            // TODO: What do we do after a deletion?
            context.Socket.Close();
        }
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:28,代码来源:SimplePackets.cs

示例5: ReadPacket

 public void ReadPacket(PacketReader reader)
 {
     FailureReason = (LoginFailureReason)reader.ReadInt32();
     var fingerprintJson = reader.ReadString();
     if (fingerprintJson != null)
         Fingerprint = new Fingerprint(fingerprintJson);
     HostName = reader.ReadString();
     AssetsRootUrl = reader.ReadString();
     iTunesUrl = reader.ReadString();
     Unknown1 = reader.ReadString();
     RemainingTime = reader.ReadInt32();
     Unknown2 = reader.ReadByte();
     CompressedFingerprintJson = reader.ReadByteArray();
     Unknown3 = reader.ReadString();
     Unknown4 = reader.ReadString();
 }
开发者ID:maithanhtan,项目名称:CoCSharp,代码行数:16,代码来源:LoginFailedPacket.cs

示例6: ReadPacket

        public void ReadPacket(PacketReader reader)
        {
            LastVisit = TimeSpan.FromSeconds(reader.ReadInt32());

            //Unknown1 = reader.ReadInt();
            reader.Seek(4, SeekOrigin.Current);

            TimeStamp = reader.ReadInt64();
            UserID = reader.ReadInt64();
            ShieldDuration = TimeSpan.FromSeconds(reader.ReadInt32());

            //Unknown2 = reader.ReadLong();
            reader.Seek(8, SeekOrigin.Current);
            Compressed = reader.ReadBoolean();
            Home = new Village();
            Home.ReadFromPacketReader(reader);

            //Unknown4 = reader.ReadInt();
            reader.Seek(4, SeekOrigin.Current);

            //UserID2 = reader.ReadLong();
            //UserID3 = reader.ReadLong();
            reader.Seek(16, SeekOrigin.Current);

            if ((HasClan = reader.ReadBoolean()))
            {
                Clan = new Clan()
                {
                    ID = reader.ReadInt64(),
                    Name = reader.ReadString(),
                    Badge = reader.ReadInt32(),
                };
                Level = reader.ReadInt32(); // member status?
                Level = reader.ReadInt32();
            }

            if (reader.ReadBoolean())
                reader.Seek(8, SeekOrigin.Current);
            if (reader.ReadBoolean())
                reader.Seek(8, SeekOrigin.Current);

            //Unknown5 = (byte)reader.ReadByte();
            //Unknown6 = reader.ReadInt();
            //Unknown7 = reader.ReadLong();
            //Unknown8 = reader.ReadLong();
            reader.Seek(4, SeekOrigin.Current);

            AllianceCastleLevel = reader.ReadInt32();
            AllianceCastleCapacity = reader.ReadInt32();
            AllianceCastleUsed = reader.ReadInt32();
            TownHallLevel = reader.ReadInt32();
            Username = reader.ReadString();
            FacebookID = reader.ReadInt32();
            Level = reader.ReadInt32();
            Experience = reader.ReadInt32();
            Gems = reader.ReadInt32();
            //Gems1 = reader.ReadInt();

            //Unknown9 = reader.ReadLong();
            reader.Seek(12, SeekOrigin.Current);

            TrophiesCount = reader.ReadInt32();
            AttackWon = reader.ReadInt32();
            AttackLost = reader.ReadInt32();
            DefenceWon = reader.ReadInt32();
            DefenceLost = reader.ReadInt32();

            reader.Seek(21, SeekOrigin.Current);

            HasName = reader.ReadBoolean();

            reader.Seek(16, SeekOrigin.Current);
        }
开发者ID:jibinthomas007,项目名称:CoCSharp,代码行数:73,代码来源:OwnHomeDataPacket.cs

示例7: ReadPacket

        public void ReadPacket(PacketReader reader)
        {
            var offset = 0x2A;
            LastVisit = TimeSpan.FromSeconds(reader.ReadInt32());
            Unknown1 = reader.ReadInt32();
            Timestamp = DateTimeConverter.FromUnixTimestamp(reader.ReadInt32());
            Unknown2 = reader.ReadInt32();
            UserID = reader.ReadInt64();
            ShieldDuration = TimeSpan.FromSeconds(reader.ReadInt32());
            Unknown3 = reader.ReadInt32();
            Unknown4 = reader.ReadInt32();
            Compressed = reader.ReadBoolean();
            Home = new Village();
            Home.Read(reader);

            Avatar = new Avatar();
            // Seems like a whole object
            Unknown6 = reader.ReadInt32();
            UserID1 = reader.ReadInt64();
            UserID2 = reader.ReadInt64();
            Avatar.ID = UserID1;

            switch (reader.ReadByte())
            {
                case 0:
                    break;

                case 1:
                    Avatar.Clan = new Clan();
                    Avatar.Clan.ID = reader.ReadInt64();
                    Avatar.Clan.Name = reader.ReadString();
                    Avatar.Clan.Badge = reader.ReadInt32();
                    reader.ReadInt32();
                    Avatar.Clan.Level = reader.ReadInt32();
                    offset += 1;
                    break;

                case 2: // clanless but clan castle built?
                    var lel = reader.ReadInt64();
                    break;
            }

            if (Unknown7 = reader.ReadBoolean())
                Unknown8 = reader.ReadInt64();

            if (Unknown9 = reader.ReadBoolean())
                Unknown10 = reader.ReadInt64();

            reader.Seek(offset, SeekOrigin.Current);
            Unknown11 = reader.ReadInt32();
            AllianceCastleLevel = reader.ReadInt32(); // -1 if not constructed
            AllianceCastleUnitCapacity = reader.ReadInt32();
            AllianceCastleUnitCount = reader.ReadInt32();
            Avatar.TownHallLevel = reader.ReadInt32();
            Avatar.Username = reader.ReadString();
            FacebookID = reader.ReadString();
            Avatar.Level = reader.ReadInt32();
            Avatar.Experience = reader.ReadInt32();
            Avatar.Gems = reader.ReadInt32();
            Gems1 = reader.ReadInt32();
            Unknown14 = reader.ReadInt32();
            Unknown15 = reader.ReadInt32();
            Avatar.Trophies = reader.ReadInt32();
            Avatar.AttacksWon = reader.ReadInt32();
            Avatar.AttacksLost = reader.ReadInt32();
            Avatar.DefencesWon = reader.ReadInt32();
            Avatar.DefencesLost = reader.ReadInt32();
            Unknown16 = reader.ReadInt32();
            Unknown17 = reader.ReadInt32();
            Unknown18 = reader.ReadInt32();
            if (Unknown19 = reader.ReadBoolean())
                Unknown20 = reader.ReadInt64();
            Unknown21 = reader.ReadByte();
            Unknown22 = reader.ReadInt32();
            Unknown23 = reader.ReadInt32();
            Unknown24 = reader.ReadInt32();
            Unknown25 = reader.ReadInt32();

            var count1 = reader.ReadInt32();
            for (int i = 0; i < count1; i++)
            {
                var id = reader.ReadInt32(); // resource id from resources.csv
                var capacity = reader.ReadInt32();
            }

            var count2 = reader.ReadInt32();
            for (int i = 0; i < count2; i++)
            {
                var id = reader.ReadInt32(); // resource id from resources.csv
                var amount = reader.ReadInt32();
            }

            var count3 = reader.ReadInt32();
            for (int i = 0; i < count3; i++)
            {
                var id = reader.ReadInt32(); // unit id from characters.csv
                var amount = reader.ReadInt32();
            }

            var count4 = reader.ReadInt32();
//.........这里部分代码省略.........
开发者ID:castelbuilder123,项目名称:CoCSharp,代码行数:101,代码来源:OwnHomeDataPacket.cs

示例8: OnRoomClose

		private static void OnRoomClose(Client client, PacketReader reader){
			int port = reader.ReadInt32();
			string room = reader.ReadUnicode(20);
			client.ServerRoomClose(new RoomInfo(port, room));
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:5,代码来源:ClientEvent.cs

示例9: 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

示例10: OnRoomList

		private static void OnRoomList(Client client, PacketReader reader){
			int count = reader.ReadInt32();
			List<GameConfig2> configs=new List<GameConfig2>();
			for(int i=0;i<count;i++){
                int port = reader.ReadInt32();
                bool needauth = reader.ReadBoolean();
                string name = reader.ReadUnicode(20);
				string banlist = reader.ReadUnicode(20);
				string info = reader.ReadUnicode(20);
                bool start = reader.ReadBoolean();
                GameConfig2 config =new GameConfig2();
				config.Parse(info);
				config.Name = name;
				config.BanList = banlist;
				config.DeulPort = port;
				config.NeedAuth = needauth;
                config.IsStart = start;
                config.RoomString = info;
				configs.Add(config);
			}
			client.ServerRoomList(configs);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:22,代码来源:ClientEvent.cs

示例11: 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

示例12: OnInfo

		private static void OnInfo(DuelServer server, PacketReader packet){
			int Port = packet.ReadInt32();
			bool NeedAuth = packet.ReadBoolean();
			server.Init(Port, NeedAuth);
			Logger.Info("duel server port="+Port+",needauth="+NeedAuth);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:6,代码来源:ServerEvent.cs

示例13: 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

示例14: 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

示例15: OnServerClose

		private static void OnServerClose(Client client, PacketReader reader){
			int port = reader.ReadInt32();
			int nport=reader.ReadInt32();
			Program.Config.DuelPort = nport;
			Program.Config.NeedAuth = reader.ReadBoolean();
			client.ServerClose(port);
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:ClientEvent.cs


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