コード例 #1
0
ファイル: MovementAccepted_22.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _Sequence = reader.ReadByte();
            _Status = reader.ReadByte();
        }
コード例 #2
0
ファイル: MobileQuery_34.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte(); // ID
            reader.ReadUInt32();

            _Type = reader.ReadByte();
            _Serial = reader.ReadUInt32();
        }
コード例 #3
0
ファイル: MovementRequest_02.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte(); // ID

            _Direction = (Direction)reader.ReadByte();
            _SequenceNumber = reader.ReadByte();
            _FastwalkPreventionKey = reader.ReadUInt32();
        }
コード例 #4
0
ファイル: UnknownPacket_BF24.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size
            reader.ReadInt16(); // Command

            _WTF = reader.ReadByte();
        }
コード例 #5
0
ファイル: MapChange_BF08.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size
            reader.ReadInt16(); // Command

            _MapID = (MapNames) reader.ReadByte();
        }
コード例 #6
0
ファイル: ChangeWeather_65.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _WeatherType = (WeatherTypes)reader.ReadByte();
            _Density = reader.ReadByte();
            _Temperature = reader.ReadByte();
        }
コード例 #7
0
ファイル: MobileAnimation.cs プロジェクト: greeduomacro/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _Serial = reader.ReadUInt32();
            _AnimationType = (AnimationType) reader.ReadInt16();
            _Action = reader.ReadInt16();
            _Delay = reader.ReadByte();
        }
コード例 #8
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte();
            reader.ReadInt16();

            _Serial = reader.ReadUInt32();
            reader.ReadInt16();
            _Status = reader.ReadInt16();
            _Flag = reader.ReadByte();
        }
コード例 #9
0
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size
            reader.ReadInt16(); // Command

            _Serial = reader.ReadUInt32();
            _FacingDirection = (Direction)reader.ReadByte();
            _MovingDirection = (Direction)reader.ReadByte();
            _BoatCommand = (BoatCommand)reader.ReadByte();
        }
コード例 #10
0
ファイル: PlaySound_54.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _Flags = reader.ReadByte();
            _SoundID = reader.ReadInt16();
            _Volume = reader.ReadInt16();
            _X = reader.ReadInt16();
            _Y = reader.ReadInt16();
            _Z = reader.ReadInt16();
        }
コード例 #11
0
ファイル: EquipUpdate_2E.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte(); // ID

            _Serial = reader.ReadUInt32();
            _ObjectID = reader.ReadInt16();
            reader.ReadByte(); //0x00
            _Layer = (ItemLayer)reader.ReadByte();
            _ParentSerial = reader.ReadUInt32();
            _Hue = reader.ReadInt16();
        }
コード例 #12
0
ファイル: Animation_6E.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _Serial = reader.ReadUInt32();
            _Action = reader.ReadInt16();
            _FrameCount = reader.ReadInt16();
            _RepeatTimes = reader.ReadInt16();
            _Forward = reader.ReadByte();
            _Repeat = reader.ReadByte();
            _Delay = reader.ReadByte();
        }
コード例 #13
0
 public ContainerItem( UltimaPacket parent, BigEndianReader reader )
 {
     _Parent = parent;
     _Serial = reader.ReadUInt32();
     _ItemID = reader.ReadInt16();
     _ItemIDOffset = reader.ReadByte();
     _Amount = reader.ReadInt16();
     _X = reader.ReadInt16();
     _Y = reader.ReadInt16();
     _GridLocation = reader.ReadByte();
     _ParentSerial = reader.ReadUInt32();
     _Hue = reader.ReadInt16();
 }
コード例 #14
0
ファイル: UnicodeMessage.cs プロジェクト: greeduomacro/SpyUO
 protected override void Parse( BigEndianReader reader )
 {
     reader.ReadByte(); // ID
     reader.ReadInt16();
     _Serial = reader.ReadUInt32();
     _Graphics = reader.ReadInt16();
     _Type = (MessageType) reader.ReadByte();
     _Hue = reader.ReadInt16();
     _Font = reader.ReadInt16();
     _Language = reader.ReadAsciiString( 4 );
     _EntityName = reader.ReadAsciiString( 30 );
     _Message = reader.ReadUnicodeString( ( Data.Length - 44 ) / 2 );
 }
コード例 #15
0
ファイル: AsciiMessage_1C.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            int length = reader.ReadInt16() - 44;

            _Serial = reader.ReadUInt32();
            _Graphics = reader.ReadInt16();
            _Type = (MessageType) reader.ReadByte();
            _Hue = reader.ReadInt16();
            _Font = reader.ReadInt16();
            _EntityName = reader.ReadAsciiString( 30 );
            _Message = reader.ReadAsciiString( length );
        }
コード例 #16
0
ファイル: Damage_0B.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _Serial = reader.ReadUInt32();
            _Damage = reader.ReadInt16();
        }
コード例 #17
0
ファイル: DeathAnimation.cs プロジェクト: greeduomacro/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _Victim = reader.ReadUInt32();
            _Corpse = reader.ReadUInt32();
        }
コード例 #18
0
ファイル: MobileStam_A3.cs プロジェクト: Ben1028/SpyUO
 protected override void Parse(BigEndianReader reader)
 {
     reader.ReadByte(); // ID
     _Serial = reader.ReadUInt32();
     _MaxStamina = reader.ReadInt16();
     _Stamina = reader.ReadInt16();
 }
コード例 #19
0
ファイル: MobileName_98.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            _Serial = reader.ReadUInt32();
            _MobileName = reader.ReadAsciiString( 30 );
        }
コード例 #20
0
ファイル: MobileHits_A1.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte(); // ID

            _Serial = reader.ReadUInt32();
            _MaxHitpoints = reader.ReadInt16();
            _Hitpoints = reader.ReadInt16();
        }
コード例 #21
0
ファイル: CloseGump_BF04.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size
            reader.ReadInt16(); // Command

            _GumpID = reader.ReadUInt32();
            _ButtonID = reader.ReadUInt32();
        }
コード例 #22
0
 protected override void Parse( BigEndianReader reader )
 {
     reader.ReadByte(); // ID
     _Serial = reader.ReadUInt32();
     _ItemID = reader.ReadInt16();
     _ItemIDOffset = reader.ReadByte();
     _Amount = reader.ReadInt16();
     _X = reader.ReadInt16();
     _Y = reader.ReadInt16();
     _GridLocation = reader.ReadByte();
     _ParentSerial = reader.ReadUInt32();
     _Hue = reader.ReadInt16();
 }
コード例 #23
0
ファイル: MapDetails.cs プロジェクト: greeduomacro/SpyUO
 protected override void Parse( BigEndianReader reader )
 {
     reader.ReadByte(); // ID
     _Serial = reader.ReadUInt32();
     _CornerImage = reader.ReadInt16();
     _X1 = reader.ReadInt16();
     _Y1 = reader.ReadInt16();
     _X2 = reader.ReadInt16();
     _Y2 = reader.ReadInt16();
     _Width = reader.ReadInt16();
     _Height = reader.ReadInt16();
     _Map = reader.ReadInt16();
 }
コード例 #24
0
ファイル: ShopList.cs プロジェクト: greeduomacro/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            _Serial = reader.ReadUInt32();

            int itemCount = reader.ReadByte();
            _Items = new List<ShopListItem>();

            for ( int i = 0; i < itemCount; i++ )
                _Items.Add( new ShopListItem( reader ) );
        }
コード例 #25
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            _Serial = reader.ReadUInt32();
            _GumpID = reader.ReadInt16();

            int type = reader.ReadInt16();

            if ( type == 0 )
                _ContainerType = ContainerType.Vendor;
            else
                _ContainerType = ContainerType.ContainerOrSpellbook;
        }
コード例 #26
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            _Items = new List<QueryPropertiesItem>();
            uint serial = 0;
            int maxCount = ( Data.Length - 3 ) / 4;
            int count = 0;

            while ( count++ < maxCount && ( serial = reader.ReadUInt32() ) != 0 )
                _Items.Add( new QueryPropertiesItem( this, serial ) );
        }
コード例 #27
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            int count = reader.ReadInt16();
            _Items = new List<ContainerItem>();

            for ( int i = 0; i < count; i++ )
            {
                _Items.Add( new ContainerItem( this, reader ) );
                _Serial = _Items[ 0 ].ParentSerial;
            }
        }
コード例 #28
0
ファイル: CompressedGump.cs プロジェクト: greeduomacro/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            _Serial = reader.ReadUInt32();
            _GumpID = reader.ReadInt32();
            _X = reader.ReadInt32();
            _Y = reader.ReadInt32();

            int compressedEntriesLength = reader.ReadInt32() - 4;
            int decompressedEntriesLength = reader.ReadInt32();

            byte[] compressedEntries = reader.ReadBytes( compressedEntriesLength );
            byte[] decompressedEntries = new byte[ decompressedEntriesLength ];

            Ultima.Package.Zlib.Decompress( decompressedEntries, ref decompressedEntriesLength, compressedEntries, compressedEntriesLength );
            string entries = Encoding.ASCII.GetString( decompressedEntries );

            int lineCount = reader.ReadInt32();
            int compressedStringsLength = reader.ReadInt32() - 4;
            int decompressedStringsLength = reader.ReadInt32();

            byte[] compressedStrings = reader.ReadBytes( compressedStringsLength );
            byte[] decompressedStrings = new byte[ decompressedStringsLength ];

            Ultima.Package.Zlib.Decompress( decompressedStrings, ref decompressedStringsLength, compressedStrings, compressedStringsLength );
            string strings = Encoding.ASCII.GetString( decompressedStrings );

            _Text = new List<string>();

            int start = 0;

            for ( int i = 0; i < strings.Length; i++ )
            {
                if ( strings[ i ] == 0 )
                {
                    if ( i - start > 0 )
                        _Text.Add( strings.Substring( start, i - start ) );
                    else
                        _Text.Add( String.Empty );

                    start = i + 1;
                }
            }

            Parse( entries );
        }
コード例 #29
0
ファイル: GumpResponse.cs プロジェクト: greeduomacro/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            _Serial = reader.ReadUInt32();
            _GumpID = reader.ReadInt32();
            _ButtonID = reader.ReadInt32();

            int switchCount = reader.ReadInt32();
            _Switches = new List<int>( switchCount );

            for ( int i = 0; i < switchCount; i++ )
                _Switches.Add( reader.ReadInt32() );

            int entryCount = reader.ReadInt32();
            _TextEntries = new List<GumpResponseTextEntry>( entryCount );

            for ( int i = 0; i < entryCount; i++ )
                _TextEntries.Add( new GumpResponseTextEntry( reader ) );
        }
コード例 #30
0
ファイル: GenericGump_B0.cs プロジェクト: Ben1028/SpyUO
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID
            reader.ReadInt16(); // Size

            _Serial = reader.ReadUInt32();
            _GumpID = reader.ReadInt32();
            _X = reader.ReadInt32();
            _Y = reader.ReadInt32();

            string layout = reader.ReadAsciiString();

            int textLength = reader.ReadInt16();
            _Text = new List<string>( textLength );

            for ( int i = 0; i < textLength; i++ )
            {
                _Text.Add( reader.ReadAsciiString() );
            }

            Parse( layout );
        }
コード例 #31
0
        // Methods
        internal void Init(BigEndianReader Reader, int MapVersion)
        {
            this.Floor = (Reader.ReadByte() * 10);
            if (this.Floor == -1280)
            {
                return;
            }

            if (MapVersion >= 9)
            {
                tmpbytesv9 = Reader.ReadInt16();

                Mov = (tmpbytesv9 & 1) == 0;
                NonWalkableDuringFight = (tmpbytesv9 & 2) != 0;
                NonWalkableDuringRP    = (tmpbytesv9 & 4) != 0;
                Los      = (tmpbytesv9 & 8) == 0;
                Blue     = (tmpbytesv9 & 16) != 0;
                Red      = (tmpbytesv9 & 32) != 0;
                Visible  = (tmpbytesv9 & 64) != 0;
                FarmCell = (tmpbytesv9 & 128) != 0;

                if (MapVersion >= 10)
                {
                    HavenbagCell = (tmpbytesv9 & 256) != 0;
                    TopArrow     = (tmpbytesv9 & 512) != 0;
                    BottomArrow  = (tmpbytesv9 & 1024) != 0;
                    RightArrow   = (tmpbytesv9 & 2048) != 0;
                    LeftArrow    = (tmpbytesv9 & 4096) != 0;
                }
                else
                {
                    TopArrow    = (tmpbytesv9 & 256) != 0;
                    BottomArrow = (tmpbytesv9 & 512) != 0;
                    RightArrow  = (tmpbytesv9 & 1024) != 0;
                    LeftArrow   = (tmpbytesv9 & 2048) != 0;
                }
            }
            else
            {
                LosMov = Reader.ReadSByte();

                this.Los                    = (LosMov & 2) >> 1 == 1;
                this.Mov                    = (LosMov & 1) == 1;
                this.Visible                = (LosMov & 64) >> 6 == 1;
                this.FarmCell               = ((LosMov & 32) >> 5) == 1;
                this.Blue                   = (LosMov & 16) >> 4 == 1;
                this.Red                    = (LosMov & 8) >> 3 == 1;
                this.NonWalkableDuringRP    = (LosMov & 128) >> 7 == 1;
                this.NonWalkableDuringFight = (LosMov & 4) >> 2 == 1;
            }
            this.Speed         = Reader.ReadByte();
            this.MapChangeData = Reader.ReadByte();
            if (MapVersion > 5)
            {
                this.MoveZone = Reader.ReadByte();
            }
            if (MapVersion == 8)
            {
                tmp   = Reader.ReadByte();
                Arrow = 15 & tmp;
            }
            IsTopChange   = (MapChangeData & 64) > 0 ? true : false;
            IsBotChange   = (MapChangeData & 4) > 0 ? true : false;
            IsLeftChange  = (MapChangeData & 16) > 0 ? true : false;;
            IsRightChange = (MapChangeData & 1) > 0 ? true : false;
        }
コード例 #32
0
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte();  // ID
            reader.ReadInt16(); // Size

            Serial = reader.ReadUInt32();
            GumpID = reader.ReadInt32();
            X      = reader.ReadInt32();
            Y      = reader.ReadInt32();

            compressedEntriesLength   = reader.ReadInt32() - 4;
            decompressedEntriesLength = reader.ReadInt32();

            compressedEntries   = reader.ReadBytes(compressedEntriesLength);
            decompressedEntries = new byte[decompressedEntriesLength];

            if (SystemInfo.IsX64)
            {
                Ultima.Package.Zlib64.Decompress(decompressedEntries, ref decompressedEntriesLength, compressedEntries, compressedEntriesLength);
            }
            else
            {
                Ultima.Package.Zlib32.Decompress(decompressedEntries, ref decompressedEntriesLength, compressedEntries, compressedEntriesLength);
            }

            entries = Encoding.ASCII.GetString(decompressedEntries);

            lineCount = reader.ReadInt32();
            compressedStringsLength   = reader.ReadInt32() - 4;
            decompressedStringsLength = reader.ReadInt32();

            if (compressedStringsLength >= 0)
            {
                compressedStrings   = reader.ReadBytes(compressedStringsLength);
                decompressedStrings = new byte[decompressedStringsLength];

                if (SystemInfo.IsX64)
                {
                    Ultima.Package.Zlib64.Decompress(decompressedStrings, ref decompressedStringsLength, compressedStrings, compressedStringsLength);
                }
                else
                {
                    Ultima.Package.Zlib32.Decompress(decompressedStrings, ref decompressedStringsLength, compressedStrings, compressedStringsLength);
                }

                strings = Encoding.ASCII.GetString(decompressedStrings);

                Text = new List <string>();

                start = 0;

                for (int i = 0; i < strings.Length; i++)
                {
                    if (strings[i] == 0)
                    {
                        if (i - start > 0)
                        {
                            Text.Add(strings.Substring(start, i - start));
                        }
                        else
                        {
                            Text.Add(String.Empty);
                        }

                        start = i + 1;
                    }
                }
            }

            Parse(entries);
        }
コード例 #33
0
        public bool Build(BigEndianReader reader)
        {
            bool result;

            if (reader.BytesAvailable <= 0L)
            {
                result = false;
            }
            else
            {
                if (IsValid)
                {
                    result = true;
                }
                else
                {
                    if (!Header.HasValue && reader.BytesAvailable < 2L)
                    {
                        result = false;
                    }
                    else
                    {
                        if (reader.BytesAvailable >= 2L && !Header.HasValue)
                        {
                            Header = reader.ReadShort();
                        }
                        bool arg_CC_0;
                        if (LengthBytesCount.HasValue)
                        {
                            long num  = reader.BytesAvailable;
                            int? num2 = LengthBytesCount;
                            if (num >= num2.GetValueOrDefault() && num2.HasValue)
                            {
                                arg_CC_0 = Length.HasValue;
                                goto IL_CC;
                            }
                        }
                        arg_CC_0 = true;
IL_CC:
                        if (!arg_CC_0)
                        {
                            if (LengthBytesCount < 0 || LengthBytesCount > 3)
                            {
                                throw new Exception("Malformated Message Header, invalid bytes number to read message length (inferior to 0 or superior to 3)");
                            }
                            Length = 0;
                            for (int i = LengthBytesCount.Value - 1; i >= 0; i--)
                            {
                                Length |= reader.ReadByte() << i * 8;
                            }
                        }
                        if (Length.HasValue && !m_dataMissing)
                        {
                            if (Length == 0)
                            {
                                if (ReadData)
                                {
                                    Data = new byte[0];
                                }
                                result = true;
                                return(result);
                            }
                            long num  = reader.BytesAvailable;
                            int? num2 = Length;
                            if (num >= num2.GetValueOrDefault() && num2.HasValue)
                            {
                                if (ReadData)
                                {
                                    Data = reader.ReadBytes(Length.Value);
                                }
                                else
                                {
                                    m_availableBytes = reader.BytesAvailable;
                                }
                                result = true;
                                return(result);
                            }
                            num2 = Length;
                            num  = reader.BytesAvailable;
                            if (num2.GetValueOrDefault() > num && num2.HasValue)
                            {
                                if (ReadData)
                                {
                                    Data = reader.ReadBytes(reader.BytesAvailable);
                                }
                                else
                                {
                                    m_availableBytes = reader.BytesAvailable;
                                }
                                m_dataMissing = true;
                                result        = false;
                                return(result);
                            }
                        }
                        else
                        {
                            if (Length.HasValue && m_dataMissing)
                            {
                                long num  = (long)(ReadData ? Data.Length : 0) + reader.BytesAvailable;
                                int? num2 = Length;
                                if (num < num2.GetValueOrDefault() && num2.HasValue)
                                {
                                    if (ReadData)
                                    {
                                        int destinationIndex = m_data.Length;
                                        Array.Resize(ref m_data, (int)((long)Data.Length + reader.BytesAvailable));
                                        byte[] array = reader.ReadBytes(reader.BytesAvailable);
                                        Array.Copy(array, 0, Data, destinationIndex, array.Length);
                                    }
                                    else
                                    {
                                        m_availableBytes = reader.BytesAvailable;
                                    }
                                    m_dataMissing = true;
                                }
                                num  = (long)(ReadData ? Data.Length : 0) + reader.BytesAvailable;
                                num2 = Length;
                                if (num >= num2.GetValueOrDefault() && num2.HasValue)
                                {
                                    if (ReadData)
                                    {
                                        int num3 = Length.Value - Data.Length;
                                        Array.Resize(ref m_data, Data.Length + num3);
                                        byte[] array = reader.ReadBytes(num3);
                                        Array.Copy(array, 0, Data, Data.Length - num3, num3);
                                    }
                                    else
                                    {
                                        m_availableBytes = reader.BytesAvailable;
                                    }
                                }
                            }
                        }
                        result = IsValid;
                    }
                }
            }
            return(result);
        }
コード例 #34
0
        /// <summary>
        /// Build or continue building the message. Returns true if the resulted message is valid and ready to be parsed
        /// </summary>
        public bool Build(BigEndianReader reader)
        {
            if (IsValid)
            {
                return(true);
            }

            AllByte = reader.Data;
            if (reader.BytesAvailable >= 2 && !Header.HasValue)
            {
                Header = reader.ReadShort();
            }

            if (LengthBytesCount.HasValue &&
                reader.BytesAvailable >= LengthBytesCount && !Length.HasValue)
            {
                if (LengthBytesCount < 0 || LengthBytesCount > 3)
                {
                    throw new System.Exception("Malformated Message Header, invalid bytes number to read message length (inferior to 0 or superior to 3)");
                }

                Length = 0;

                // 3..0 or 2..0 or 1..0
                for (int i = LengthBytesCount.Value - 1; i >= 0; i--)
                {
                    Length |= reader.ReadByte() << (i * 8);
                }
            }

            // first case : no data read
            if (Data == null && Length.HasValue)
            {
                if (Length == 0)
                {
                    Data = new byte[0];
                }

                // enough bytes in the buffer to build a complete message
                if (reader.BytesAvailable >= Length)
                {
                    Data = reader.ReadBytes(Length.Value);
                }
                // not enough bytes, so we read what we can
                else if (Length > reader.BytesAvailable)
                {
                    Data = reader.ReadBytes((int)reader.BytesAvailable);
                }
            }
            //second case : the message was split and it missed some bytes
            if (Data != null && Length.HasValue && Data.Length < Length)
            {
                int bytesToRead = 0;

                // still miss some bytes ...
                if (Data.Length + reader.BytesAvailable < Length)
                {
                    bytesToRead = (int)reader.BytesAvailable;
                }

                // there is enough bytes in the buffer to complete the message :)
                else if (Data.Length + reader.BytesAvailable >= Length)
                {
                    bytesToRead = Length.Value - Data.Length;
                }

                if (bytesToRead != 0)
                {
                    int oldLength = Data.Length;
                    Array.Resize(ref m_data, (int)(Data.Length + bytesToRead));
                    Array.Copy(reader.ReadBytes(bytesToRead), 0, Data, oldLength, bytesToRead);
                }
            }

            return(IsValid);
        }
コード例 #35
0
        private TrueTypeFontTable ReadOS2Table(uint length, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            OS2Table os2 = new OS2Table(reader.Position);

            os2.Version           = (OS2TableVersion)reader.ReadUInt16();
            os2.XAverageCharWidth = reader.ReadInt16();
            os2.WeightClass       = (WeightClass)reader.ReadUInt16();
            os2.WidthClass        = (WidthClass)reader.ReadUInt16();
            os2.FSType            = (FontRestrictions)reader.ReadUInt16();

            os2.SubscriptXSize   = reader.ReadInt16();
            os2.SubscriptYSize   = reader.ReadInt16();
            os2.SubscriptXOffset = reader.ReadInt16();
            os2.SubscriptYOffset = reader.ReadInt16();

            os2.SuperScriptXSize   = reader.ReadInt16();
            os2.SuperScriptYSize   = reader.ReadInt16();
            os2.SuperscriptXOffset = reader.ReadInt16();
            os2.SuperscriptYOffset = reader.ReadInt16();

            os2.StrikeoutSize     = reader.ReadInt16();
            os2.StrikeoutPosition = reader.ReadInt16();

            byte hi = reader.ReadByte();
            byte lo = reader.ReadByte();

            os2.FamilyClass = new IBMFontClass(hi, lo);

            byte[] data = reader.Read(10);
            os2.Panose = new PanoseArray(data);

            uint zero  = reader.ReadUInt32();
            uint one   = reader.ReadUInt32();
            uint two   = reader.ReadUInt32();
            uint three = reader.ReadUInt32();

            os2.UnicodeRanges = new UnicodeRanges(zero, one, two, three);

            os2.VendorID  = reader.ReadString(4);
            os2.Selection = (FontSelection)reader.ReadUInt16();

            os2.FirstCharIndex = reader.ReadUInt16();
            os2.LastCharIndex  = reader.ReadUInt16();
            os2.TypoAscender   = reader.ReadInt16();
            os2.TypoDescender  = reader.ReadInt16();
            os2.TypoLineGap    = reader.ReadInt16();
            os2.WinAscent      = reader.ReadUInt16();
            os2.WinDescent     = reader.ReadUInt16();

            if (os2.Version >= OS2TableVersion.TrueType166)
            {
                zero = reader.ReadUInt32();
                one  = reader.ReadUInt32();
                os2.CodePageRanges = new CodePageRange(zero, one);

                if (os2.Version >= OS2TableVersion.OpenType12)
                {
                    os2.Height      = reader.ReadInt16();
                    os2.CapHeight   = reader.ReadInt16();
                    os2.DefaultChar = reader.ReadUInt16();
                    os2.BreakChar   = reader.ReadUInt16();
                    os2.MaxContext  = reader.ReadUInt16();
                }
            }

            return(os2);
        }
コード例 #36
0
        internal void Init(BigEndianReader reader)
        {
            char b = (char)reader.ReadByte();

            MapVersion = reader.ReadByte();
            Id         = (int)reader.ReadUInt();
            if (MapVersion >= 7)
            {
                Encrypted        = reader.ReadBoolean();
                EncryptedVersion = reader.ReadByte();
                int count = reader.ReadInt();
                if (Encrypted)
                {
                    byte[] buffer  = CustomHex.ToArray(CustomHex.FromString("649ae451ca33ec53bbcbcc33becf15f4", false));
                    byte[] buffer2 = reader.ReadBytes(count);
                    int    num7    = (buffer2.Length - 1);
                    int    n       = 0;
                    while (n <= num7)
                    {
                        buffer2[n] = Convert.ToByte((buffer2[n] ^ buffer[(n % buffer.Length)]));
                        n         += 1;
                    }
                    reader = new BigEndianReader(buffer2);
                }
            }
            RelativeId            = (int)reader.ReadUInt();
            MapType               = reader.ReadByte();
            SubAreaId             = reader.ReadInt();
            TopNeighbourId        = reader.ReadInt();
            BottomNeighbourId     = reader.ReadInt();
            LeftNeighbourId       = reader.ReadInt();
            RightNeighbourId      = reader.ReadInt();
            ShadowBonusOnEntities = reader.ReadUInt();
            if (MapVersion >= 9)
            {
                int readColor = reader.ReadInt();
                BackGroundAlpha = (readColor & 4278190080) >> 32;
                BackgroundRed   = (readColor & 16711680) >> 16;
                BackgroundGreen = (readColor & 65280) >> 8;
                BackgroundBlue  = readColor & 255;
                var gridColor = reader.ReadUInt();
                var gridAlpha = (gridColor & 4278190080) >> 32;
                var gridRed   = (gridColor & 16711680) >> 16;
                var gridGreen = (gridColor & 65280) >> 8;
                var gridBlue  = gridColor & 255;
                GridColor = (gridAlpha & 255) << 32 | (gridRed & 255) << 16 | (gridGreen & 255) << 8 | gridBlue & 255;
            }
            else if (MapVersion >= 3)
            {
                BackgroundRed   = reader.ReadByte();
                BackgroundGreen = reader.ReadByte();
                BackgroundBlue  = reader.ReadByte();
            }
            BackGroundColor = (BackgroundRed & 255) << 16 | (BackgroundGreen & 255) << 8 | BackgroundBlue & 255;
            if (MapVersion >= 4)
            {
                ZoomScale   = (Convert.ToDouble(reader.ReadUShort()) / 100);
                ZoomOffsetX = reader.ReadShort();
                ZoomOffsetY = reader.ReadShort();
                if (ZoomScale < 1)
                {
                    ZoomScale   = 1;
                    ZoomOffsetX = 0;
                    ZoomOffsetY = 0;
                }
            }
            UseLowPassFilter = reader.ReadBoolean();
            UseReverb        = reader.ReadBoolean();
            if (UseReverb)
            {
                PresetId = reader.ReadInt();
            }
            else
            {
                PresetId = -1;
            }
            BackgroundsCount = reader.ReadByte();
            int backgroundsCount = BackgroundsCount;
            int i = 1;

            while (i <= backgroundsCount)
            {
                Fixture item = new Fixture();
                item.Init(reader);
                BackgroundFixtures.Add(item);
                i += 1;
            }
            ForegroundsCount = reader.ReadByte();
            int foregroundsCount = ForegroundsCount;
            int j = 1;

            while (j <= foregroundsCount)
            {
                Fixture fixture2 = new Fixture();
                fixture2.Init(reader);
                ForegroundFixtures.Add(fixture2);
                j += 1;
            }
            CellsCount = 560;
            reader.ReadInt();
            GroundCRC   = reader.ReadInt().ToString();
            LayersCount = reader.ReadByte();
            int layersCount = LayersCount;
            int k           = 1;

            while (k <= layersCount)
            {
                Layer layer = new Layer();
                layer.Init(reader, MapVersion);
                Layers.Add(layer);
                k += 1;
            }
            int  cellsCount = CellsCount;
            int  m          = 1;
            uint oldMvtSys  = 0;

            TopArrowCells    = new List <int>();
            BottomArrowCells = new List <int>();
            RightArrowCells  = new List <int>();
            LeftArrowCells   = new List <int>();
            while (m <= cellsCount)
            {
                CellData data = new CellData(m);
                data.Init(reader, MapVersion, this);
                if (oldMvtSys == 0)
                {
                    oldMvtSys = (uint)data.MoveZone;
                }
                if (data.MoveZone != oldMvtSys)
                {
                    IsUsingNewMovementSystem = true;
                }
                Cells.Add(data);
                m += 1;
            }
        }
コード例 #37
0
ファイル: CellData.cs プロジェクト: gateaubleu/Burning
        public void FromRaw(BigEndianReader param1)
        {
            BigEndianReader bigEndianReader = param1;

            try
            {
                this.Floor = (int)bigEndianReader.ReadByte() * 10;
                if (this.Floor == -1280)
                {
                    return;
                }
                if (this._map.MapVersion >= 9)
                {
                    int num = (int)bigEndianReader.ReadShort();
                    this.Mov = (num & 1) == 0;
                    this.NonWalkableDuringFight = (uint)(num & 2) > 0U;
                    this.NonWalkableDuringRp    = (uint)(num & 4) > 0U;
                    this.Los      = (num & 8) == 0;
                    this.Blue     = (uint)(num & 16) > 0U;
                    this.Red      = (uint)(num & 32) > 0U;
                    this.Visible  = (uint)(num & 64) > 0U;
                    this.FarmCell = (uint)(num & 128) > 0U;
                    bool flag1;
                    bool flag2;
                    bool flag3;
                    bool flag4;
                    if (this._map.MapVersion >= 10)
                    {
                        this.HavenbagCell = (uint)(num & 256) > 0U;
                        flag1             = (uint)(num & 512) > 0U;
                        flag2             = (uint)(num & 1024) > 0U;
                        flag3             = (uint)(num & 2048) > 0U;
                        flag4             = (uint)(num & 4096) > 0U;
                    }
                    else
                    {
                        flag1 = (uint)(num & 256) > 0U;
                        flag2 = (uint)(num & 512) > 0U;
                        flag3 = (uint)(num & 1024) > 0U;
                        flag4 = (uint)(num & 2048) > 0U;
                    }
                    if (flag1)
                    {
                        this._map.TopArrowCell.Add(this.Id);
                    }
                    if (flag2)
                    {
                        this._map.BottomArrowCell.Add(this.Id);
                    }
                    if (flag3)
                    {
                        this._map.RightArrowCell.Add(this.Id);
                    }
                    if (flag4)
                    {
                        this._map.LeftArrowCell.Add(this.Id);
                    }
                }
                else
                {
                    this._losmov                = (int)bigEndianReader.ReadByte();
                    this.Los                    = (this._losmov & 2) >> 1 == 1;
                    this.Mov                    = (this._losmov & 1) == 1;
                    this.Visible                = (this._losmov & 64) >> 6 == 1;
                    this.FarmCell               = (this._losmov & 32) >> 5 == 1;
                    this.Blue                   = (this._losmov & 16) >> 4 == 1;
                    this.Red                    = (this._losmov & 8) >> 3 == 1;
                    this.NonWalkableDuringRp    = (this._losmov & 128) >> 7 == 1;
                    this.NonWalkableDuringFight = (this._losmov & 4) >> 2 == 1;
                }
                this.Speed         = (int)bigEndianReader.ReadByte();
                this.MapChangeData = (uint)bigEndianReader.ReadByte();
                if (this._map.MapVersion > 5)
                {
                    this.MoveZone = (uint)bigEndianReader.ReadByte();
                }
                if (this._map.MapVersion > 10 && (this.HasLinkedZoneRP || this.HasLinkedZoneFight))
                {
                    this.LinkedZone = bigEndianReader.ReadByte();
                }
                if (this._map.MapVersion <= 7 || this._map.MapVersion >= 9)
                {
                    return;
                }
                this._arrow = 15 & (int)bigEndianReader.ReadByte();
                if (this.UseTopArrow)
                {
                    this._map.TopArrowCell.Add(this.Id);
                }
                if (this.UseBottomArrow)
                {
                    this._map.BottomArrowCell.Add(this.Id);
                }
                if (this.UseLeftArrow)
                {
                    this._map.LeftArrowCell.Add(this.Id);
                }
                if (!this.UseRightArrow)
                {
                    return;
                }
                this._map.RightArrowCell.Add(this.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine((object)ex);
                throw;
            }
        }
コード例 #38
0
        /// <summary>
        ///     Build or continue building the message. Returns true if the resulted message is valid and ready to be parsed
        /// </summary>
        public bool Build(BigEndianReader reader)
        {
            try
            {
                if (reader.BytesAvailable <= 0)
                {
                    return(false);
                }

                if (IsValid)
                {
                    return(true);
                }

                if (!Header.HasValue && reader.BytesAvailable < 2)
                {
                    return(false);
                }

                if (reader.BytesAvailable >= 2 && !Header.HasValue)
                {
                    Header = reader.ReadShort();
                }

                if (LengthBytesCount.HasValue &&
                    reader.BytesAvailable >= LengthBytesCount && !Length.HasValue)
                {
                    if (LengthBytesCount < 0 || LengthBytesCount > 3)
                    {
                        throw new Exception(
                                  "Malformated Message Header, invalid bytes number to read message length (inferior to 0 or superior to 3)");
                    }

                    Length = 0;

                    // 3..0 or 2..0 or 1..0
                    for (var i = LengthBytesCount.Value - 1; i >= 0; i--)
                    {
                        Length |= reader.ReadByte() << (i * 8);
                    }
                }

                // first case : no data read
                if (Data == null && Length.HasValue)
                {
                    if (Length == 0)
                    {
                        Data = new byte[0];
                    }

                    // enough bytes in the buffer to build a complete message
                    if (reader.BytesAvailable >= Length)
                    {
                        Data = reader.ReadBytes(Length.Value);
                        return(true);
                    }
                    // not enough bytes, so we read what we can
                    else if (Length > reader.BytesAvailable)
                    {
                        Data = reader.ReadBytes((int)reader.BytesAvailable);
                        return(false);
                    }
                }
                //second case : the message was split and it missed some bytes
                if (Data != null && Length.HasValue && Data.Length < Length)
                {
                    // still miss some bytes ...
                    if (Data.Length + reader.BytesAvailable < Length)
                    {
                        var lastLength = Data.Length;
                        Array.Resize(ref m_data, (int)(Data.Length + reader.BytesAvailable));
                        var array = reader.ReadBytes((int)reader.BytesAvailable);

                        Array.Copy(array, 0, Data, lastLength, array.Length);
                    }
                    // there is enough bytes in the buffer to complete the message :)
                    else if (Data.Length + reader.BytesAvailable >= Length)
                    {
                        var bytesToRead = Length.Value - Data.Length;

                        Array.Resize(ref m_data, Data.Length + bytesToRead);
                        var array = reader.ReadBytes(bytesToRead);

                        Array.Copy(array, 0, Data, Data.Length - bytesToRead, bytesToRead);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(IsValid);
        }
コード例 #39
0
 protected override void Parse(BigEndianReader reader)
 {
     reader.ReadByte();             // ID
     _Size         = reader.ReadUInt16();
     _Unk1         = reader.ReadUInt32();
     _CharSlot     = reader.ReadUInt32();
     _CharName     = reader.ReadAsciiString(30);
     _Unk2         = reader.ReadAsciiString(30);
     _Profession   = reader.ReadByte();
     _Flags        = reader.ReadByte();
     _Gender       = reader.ReadByte();
     _Race         = reader.ReadByte();
     _Strength     = reader.ReadByte();
     _Dexterity    = reader.ReadByte();
     _Intelligence = reader.ReadByte();
     _SkinColor    = reader.ReadUInt16();
     reader.ReadUInt32();
     reader.ReadUInt32();
     _Skill1       = reader.ReadByte();
     _Skill1Amount = reader.ReadByte();
     _Skill2       = reader.ReadByte();
     _Skill2Amount = reader.ReadByte();
     _Skill3       = reader.ReadByte();
     _Skill3Amount = reader.ReadByte();
     _Skill4       = reader.ReadByte();
     _Skill4Amount = reader.ReadByte();
     reader.ReadBytes(25);
     reader.ReadByte();
     _HairHue   = reader.ReadInt16();
     _HairStyle = reader.ReadUInt16();
     reader.ReadByte();
     reader.ReadUInt32();
     reader.ReadByte();
     _ShirtColor = reader.ReadInt16();
     _ShirtID    = reader.ReadInt16();
     reader.ReadByte();
     _FaceColor = reader.ReadUInt16();
     _FaceID    = reader.ReadUInt16();
     reader.ReadByte();
     _BeardHue   = reader.ReadInt16();
     _BeardStyle = reader.ReadInt16();
 }
コード例 #40
0
 public override void Deserialize(BigEndianReader reader)
 {
     m_reason = reader.ReadByte();
 }
コード例 #41
0
 public override void Deserialize(BigEndianReader reader)
 {
     m_serverId     = reader.ReadVarUShort();
     m_error        = reader.ReadByte();
     m_serverStatus = reader.ReadByte();
 }
コード例 #42
0
 public ShopListItem(BigEndianReader reader)
 {
     _Price = reader.ReadInt32();
     _Name  = reader.ReadAsciiString(reader.ReadByte());
 }
コード例 #43
0
ファイル: Map.cs プロジェクト: shadowok/BlueSheep
        internal void Init(BigEndianReader reader)
        {
            reader.ReadByte();
            this.MapVersion = reader.ReadByte();
            this.Id         = (int)reader.ReadUInt();
            if (this.MapVersion >= 7)
            {
                this.Encrypted        = reader.ReadBoolean();
                this.EncryptedVersion = reader.ReadByte();
                int count = reader.ReadInt();
                if (this.Encrypted)
                {
                    byte[] buffer  = CustomHex.ToArray(CustomHex.FromString("649ae451ca33ec53bbcbcc33becf15f4", false));
                    byte[] buffer2 = reader.ReadBytes(count);
                    int    num7    = (buffer2.Length - 1);
                    int    n       = 0;
                    while (n <= num7)
                    {
                        buffer2[n] = Convert.ToByte((buffer2[n] ^ buffer[(n % buffer.Length)]));
                        n         += 1;
                    }
                    reader = new BigEndianReader(buffer2);
                }
            }
            this.RelativeId            = (int)reader.ReadUInt();
            this.MapType               = reader.ReadByte();
            this.SubAreaId             = reader.ReadInt();
            this.TopNeighbourId        = reader.ReadInt();
            this.BottomNeighbourId     = reader.ReadInt();
            this.LeftNeighbourId       = reader.ReadInt();
            this.RightNeighbourId      = reader.ReadInt();
            this.ShadowBonusOnEntities = reader.ReadInt();
            if (this.MapVersion >= 3)
            {
                this.BackgroundRed   = reader.ReadByte();
                this.BackgroundGreen = reader.ReadByte();
                this.BackgroundBlue  = reader.ReadByte();
            }
            if (this.MapVersion >= 4)
            {
                this.ZoomScale   = (Convert.ToDouble(reader.ReadUShort()) / 100);
                this.ZoomOffsetX = reader.ReadShort();
                this.ZoomOffsetY = reader.ReadShort();
            }
            this.UseLowPassFilter = reader.ReadBoolean();
            this.UseReverb        = reader.ReadBoolean();
            if (this.UseReverb)
            {
                this.PresetId = reader.ReadInt();
            }
            this.BackgroundsCount = reader.ReadByte();
            int backgroundsCount = this.BackgroundsCount;
            int i = 1;

            while (i <= backgroundsCount)
            {
                Fixture item = new Fixture();
                item.Init(reader);
                this.BackgroundFixtures.Add(item);
                i += 1;
            }
            this.ForegroundsCount = reader.ReadByte();
            int foregroundsCount = this.ForegroundsCount;
            int j = 1;

            while (j <= foregroundsCount)
            {
                Fixture fixture2 = new Fixture();
                fixture2.Init(reader);
                this.ForegroundFixtures.Add(fixture2);
                j += 1;
            }
            this.CellsCount = 560;
            reader.ReadInt();
            this.GroundCRC   = reader.ReadInt().ToString();
            this.LayersCount = reader.ReadByte();
            int layersCount = this.LayersCount;
            int k           = 1;

            while (k <= layersCount)
            {
                Layer layer = new Layer();
                layer.Init(reader, this.MapVersion);
                this.Layers.Add(layer);
                k += 1;
            }
            int  cellsCount = this.CellsCount;
            int  m          = 1;
            uint oldMvtSys  = 0;

            while (m <= cellsCount)
            {
                CellData data = new CellData();
                data.Init(reader, this.MapVersion);
                if (oldMvtSys == 0)
                {
                    oldMvtSys = (uint)data.MoveZone;
                }
                if (data.MoveZone != oldMvtSys)
                {
                    IsUsingNewMovementSystem = true;
                }
                this.Cells.Add(data);
                m += 1;
            }
        }
コード例 #44
0
        public void FromRaw(string path)
        {
            BigEndianReader raw = new BigEndianReader(Uncompress(File.ReadAllBytes(path)));

            _rawData = raw;

            types = new Dictionary <int, int>();

            int header = raw.ReadByte();

            if (header != 69)
            {
                throw new Exception("Unknown file format");
            }

            int Version = raw.ReadByte();
            int skypLen = 0;

            var count = raw.ReadUInt();

            for (int i = 0; i < count; i++)
            {
                if (Version >= 9)
                {
                    skypLen = raw.ReadUShort();
                }

                var id = raw.ReadInt();

                //if(Version > 8)
                //    raw.Seek(skypLen - 4, SeekOrigin.Current);

                var type = raw.ReadByte();
                types[id] = type;

                switch (type)
                {
                case 2:     //ANIMATED
                    raw.ReadInt();
                    raw.ReadByte();
                    raw.ReadBoolean();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    if (Version == 4)
                    {
                        raw.ReadInt();
                        raw.ReadInt();
                    }
                    break;

                case 5:     //BLENDED
                    raw.ReadInt();
                    raw.ReadByte();
                    raw.ReadBoolean();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadUTFBytes(raw.ReadInt());
                    break;

                case 1:     //BOUNDING_BOX
                    raw.ReadInt();
                    raw.ReadByte();
                    raw.ReadBoolean();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    break;

                case 3:     //ENTITY
                    string test = raw.ReadUTF7BitLength();
                    raw.ReadBoolean();
                    if (Version >= 7)
                    {
                        raw.ReadBoolean();
                    }
                    if (Version >= 6)
                    {
                        raw.ReadBoolean();
                    }
                    if (Version >= 5)
                    {
                        raw.ReadInt();
                        raw.ReadInt();
                    }
                    break;

                case 0:     //NORMAL
                    raw.ReadInt();
                    raw.ReadByte();
                    raw.ReadBoolean();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    raw.ReadShort();
                    break;

                case 4:     //PARTICLES
                    raw.ReadShort();
                    break;

                default:
                    Console.WriteLine("Unknown graphical data of type " + type);
                    break;
                }
            }

            if (Version >= 8)
            {
                var gfxCount = raw.ReadInt();
                for (int i = 0; i < gfxCount; i++)
                {
                    raw.ReadInt();
                }
            }
        }
コード例 #45
0
                public static void ReadFromReader(this ICommand command, BigEndianReader read)
                {
                    var properties = command.GetType().GetProperties()
                                     .Where(f => f.GetCustomAttribute <CommandFieldAttribute>() != null)
                                     .Select(f => new { Property = f, Metadata = f.GetCustomAttribute <CommandFieldAttribute>() });

                    while (true)
                    {
                        byte fieldID = read.ReadByte();
                        if (fieldID == 255 || read.PeekChar() < 0)
                        {
                            break;
                        }

                        ushort fieldLength = read.ReadUInt16();

                        var fieldInfo         = properties.First(f => f.Metadata.FieldID == fieldID);
                        var serializationType = fieldInfo.Property.PropertyType;
                        if (fieldInfo.Metadata.SerializeAs != null)
                        {
                            serializationType = fieldInfo.Metadata.SerializeAs;
                        }

                        if (Nullable.GetUnderlyingType(serializationType) != null)
                        {
                            serializationType = Nullable.GetUnderlyingType(serializationType);
                        }

                        if (fieldInfo.Metadata.Repeated)
                        {
                            if (!serializationType.GetInterfaces().Any(i => i == typeof(IList)))
                            {
                                throw new Exception("Repeated field is not of a list type");
                            }

                            var listType = serializationType.GetInterfaces().First(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList <>));
                            var internalSerializationType = listType.GetGenericArguments()[0];

                            var cur = fieldInfo.Property.GetValue(command) as IList;
                            if (!serializationType.IsArray)
                            {
                                if (cur == null)
                                {
                                    cur = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(internalSerializationType));
                                }
                                cur.Add(read.ReadOfType(fieldLength, internalSerializationType));
                            }
                            else
                            {
                                if (cur == null)
                                {
                                    cur = Array.CreateInstance(internalSerializationType, 1);
                                }
                                else
                                {
                                    var arr = Array.CreateInstance(internalSerializationType, cur.Count + 1);
                                    Array.Copy((Array)cur, arr, cur.Count);
                                    cur = arr;
                                }

                                cur[cur.Count - 1] = read.ReadOfType(fieldLength, internalSerializationType);
                            }

                            fieldInfo.Property.SetValue(command, cur);
                        }
                        else
                        {
                            var value = read.ReadOfType(fieldLength, serializationType);
                            if (serializationType != fieldInfo.Property.PropertyType)
                            {
                                if (!fieldInfo.Property.PropertyType.IsEnum)
                                {
                                    value = Convert.ChangeType(value, fieldInfo.Property.PropertyType);
                                }
                            }

                            fieldInfo.Property.SetValue(command, value);
                        }
                    }
                }
コード例 #46
0
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte();             // ID
            reader.ReadInt16();            // Size

            _Serial     = reader.ReadUInt32();
            _MobileName = reader.ReadAsciiString(30);

            _HitPoints       = reader.ReadInt16();
            _MaxHitPoints    = reader.ReadInt16();
            _AllowNameChange = reader.ReadByte() == 1 ? true : false;
            byte features = reader.ReadByte();

            _IsFemale     = reader.ReadByte() == 1 ? true : false;
            _Strength     = reader.ReadInt16();
            _Dexterity    = reader.ReadInt16();
            _Intelligence = reader.ReadInt16();
            _Stamina      = reader.ReadInt16();
            _MaxStamina   = reader.ReadInt16();
            _Mana         = reader.ReadInt16();
            _MaxMana      = reader.ReadInt16();
            _Gold         = reader.ReadInt32();
            _ArmorRating  = reader.ReadInt16();
            _Weight       = reader.ReadInt16();

            if ((features & 0x5) == 0x5)
            {
                _MaxWeight = reader.ReadInt16();
                _Race      = (MobileRace)reader.ReadByte();
            }

            if ((features & 0x2) == 0x2)
            {
                _StatCap = reader.ReadInt16();
            }

            if ((features & 0x3) == 0x3)
            {
                _Followers    = reader.ReadByte();
                _MaxFollowers = reader.ReadByte();
            }

            if ((features & 0x4) == 0x4)
            {
                _FireResistance   = reader.ReadInt16();
                _ColdResistance   = reader.ReadInt16();
                _PoisonResistance = reader.ReadInt16();
                _EnergyResistance = reader.ReadInt16();
                _Luck             = reader.ReadInt16();
                _MinWeaponDamage  = reader.ReadInt16();
                _MaxWeaponDamage  = reader.ReadInt16();
                _TithingPoints    = reader.ReadInt32();
            }

            if ((features & 0x6) == 0x6)
            {
                _HitChanceIncrease        = reader.ReadInt16();
                _SwingSpeedIncrease       = reader.ReadInt16();
                _DamageChanceIncrease     = reader.ReadInt16();
                _LowerReagentCost         = reader.ReadInt16();
                _HitPointRegeneration     = reader.ReadInt16();
                _StaminaRegeneration      = reader.ReadInt16();
                _ManaRegeneration         = reader.ReadInt16();
                _ReflectPhysicalDamage    = reader.ReadInt16();
                _EnhancePotions           = reader.ReadInt16();
                _DefenseChanceIncrease    = reader.ReadInt16();
                _SpellDamageIncrease      = reader.ReadInt16();
                _FasterCastRecovery       = reader.ReadInt16();
                _FasterCasting            = reader.ReadInt16();
                _LowerManaCost            = reader.ReadInt16();
                _StrengthIncrease         = reader.ReadInt16();
                _DexterityIncrease        = reader.ReadInt16();
                _IntelligenceIncrease     = reader.ReadInt16();
                _HitPointsIncrease        = reader.ReadInt16();
                _StaminaIncrease          = reader.ReadInt16();
                _ManaIncrease             = reader.ReadInt16();
                _MaximumHitPointsIncrease = reader.ReadInt16();
                _MaximumStaminaIncrease   = reader.ReadInt16();
                _MaximumManaIncrease      = reader.ReadInt16();
            }
        }
コード例 #47
0
 public override void Deserialize(BigEndianReader reader)
 {
     base.Deserialize(reader);
     m_install    = reader.ReadByte();
     m_technology = reader.ReadByte();
 }
コード例 #48
0
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte(); // ID

            _Serial = reader.ReadUInt32();
        }
コード例 #49
0
        public void FromRaw(BigEndianReader param1, byte[] param2)
        {
            int             num1            = -1;
            BigEndianReader bigEndianReader = param1;

            byte[] numArray = param2;
            try
            {
                if (bigEndianReader.ReadByte() != (byte)77)
                {
                    throw new Exception("Unknown file format.");
                }
                this.MapVersion = (int)bigEndianReader.ReadByte();
                this.Id         = bigEndianReader.ReadInt();
                if (this.MapVersion >= 7)
                {
                    this.Encrypted         = bigEndianReader.ReadBoolean();
                    this.EncryptionVersion = (uint)bigEndianReader.ReadByte();
                    int n = bigEndianReader.ReadInt();
                    if (this.Encrypted)
                    {
                        if (numArray.Length < 1)
                        {
                            throw new Exception("Map decryption key is empty");
                        }
                        byte[] buffer = bigEndianReader.ReadBytes(n);
                        for (int index = 0; index < buffer.Length; ++index)
                        {
                            buffer[index] = (byte)((uint)buffer[index] ^ (uint)numArray[index % numArray.Length]);
                        }
                        bigEndianReader = new BigEndianReader((Stream) new MemoryStream(buffer));
                    }
                }
                this.RelativeId            = bigEndianReader.ReadInt();
                this.MapType               = (int)bigEndianReader.ReadByte();
                this.SubAreaId             = bigEndianReader.ReadInt();
                this.TopNeighbourId        = bigEndianReader.ReadInt();
                this.BottomNeighbourId     = bigEndianReader.ReadInt();
                this.LeftNeighbourId       = bigEndianReader.ReadInt();
                this.RightNeighbourId      = bigEndianReader.ReadInt();
                this.ShadowBonusOnEntities = bigEndianReader.ReadInt();
                if (this.MapVersion >= 9)
                {
                    int num2 = bigEndianReader.ReadInt();
                    this.BackgroundAlpha = (int)(((long)num2 & 4278190080L) >> 32);
                    this.BackgroundRed   = (num2 & 16711680) >> 16;
                    this.BackgroundGreen = (num2 & 65280) >> 8;
                    this.BackgroundBlue  = num2 & (int)byte.MaxValue;
                    int num3 = bigEndianReader.ReadInt();
                    this.GridColor = (uint)((int)(((long)num3 & 4278190080L) >> 32) & (int)byte.MaxValue | ((num3 & 16711680) >> 16 & (int)byte.MaxValue) << 16 | ((num3 & 65280) >> 8 & (int)byte.MaxValue) << 8 | num3 & (int)byte.MaxValue & (int)byte.MaxValue);
                }
                else if (this.MapVersion >= 3)
                {
                    this.BackgroundRed   = (int)bigEndianReader.ReadByte();
                    this.BackgroundGreen = (int)bigEndianReader.ReadByte();
                    this.BackgroundBlue  = (int)bigEndianReader.ReadByte();
                }
                this.BackgroundColor = (uint)(this.BackgroundAlpha & (int)byte.MaxValue | (this.BackgroundRed & (int)byte.MaxValue) << 16 | (this.BackgroundGreen & (int)byte.MaxValue) << 8 | this.BackgroundBlue & (int)byte.MaxValue);
                if (this.MapVersion >= 4)
                {
                    this.ZoomScale   = (int)bigEndianReader.ReadShort() / 100;
                    this.ZoomOffsetX = (int)bigEndianReader.ReadShort();
                    this.ZoomOffsetY = (int)bigEndianReader.ReadShort();
                    if (this.ZoomScale < 1)
                    {
                        this.ZoomScale   = 1;
                        this.ZoomOffsetY = 0;
                        this.ZoomOffsetX = 0;
                    }
                }
                if (this.MapVersion > 10)
                {
                    this.TacticalModeTemplateId = bigEndianReader.ReadInt();
                }
                this.UseLowPassFilter    = bigEndianReader.ReadByte() == (byte)1;
                this.UseReverb           = bigEndianReader.ReadByte() == (byte)1;
                this.PresetId            = !this.UseReverb ? -1 : bigEndianReader.ReadInt();
                this.BackgroundsCount    = (int)bigEndianReader.ReadByte();
                this.BackgroundsFixtures = new Fixture[this.BackgroundsCount];
                for (int index = 0; index < this.BackgroundsCount; ++index)
                {
                    Fixture fixture = new Fixture(this);
                    fixture.FromRaw(bigEndianReader);
                    this.BackgroundsFixtures[index] = fixture;
                }
                this.ForegroundsCount   = (int)bigEndianReader.ReadByte();
                this.ForegroundFixtures = new Fixture[this.ForegroundsCount];
                for (int index = 0; index < this.ForegroundsCount; ++index)
                {
                    Fixture fixture = new Fixture(this);
                    fixture.FromRaw(bigEndianReader);
                    this.ForegroundFixtures[index] = fixture;
                }
                this.CellsCount = Constants.MapCellsCount;
                bigEndianReader.ReadInt();
                this.GroundCrc   = bigEndianReader.ReadInt();
                this.LayersCount = (int)bigEndianReader.ReadByte();
                this.Layers      = new Layer[this.LayersCount];
                for (int index = 0; index < this.LayersCount; ++index)
                {
                    Layer layer = new Layer(this);
                    layer.FromRaw(bigEndianReader, this.MapVersion);
                    this.Layers[index] = layer;
                }
                this.Cells = new CellData[this.CellsCount];
                for (int index = 0; index < this.CellsCount; ++index)
                {
                    CellData cellData = new CellData(this, (uint)index);
                    cellData.FromRaw(bigEndianReader);
                    if (num1 == -1)
                    {
                        num1 = (int)cellData.MoveZone;
                    }
                    if ((long)cellData.MoveZone != (long)num1)
                    {
                        this.IsUsingNewMovementSystem = true;
                    }
                    this.Cells[index] = cellData;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine((object)ex);
                throw;
            }
        }
コード例 #50
0
ファイル: MountClientData.cs プロジェクト: shadowok/BlueSheep
        public virtual void Deserialize(BigEndianReader reader)
        {
            byte b = reader.ReadByte();

            this.sex                = BooleanByteWrapper.GetFlag(b, 0);
            this.isRideable         = BooleanByteWrapper.GetFlag(b, 1);
            this.isWild             = BooleanByteWrapper.GetFlag(b, 2);
            this.isFecondationReady = BooleanByteWrapper.GetFlag(b, 3);
            id = reader.ReadDouble();
            if (id < -9.007199254740992E15 || id > 9.007199254740992E15)
            {
                throw new Exception("Forbidden value on id = " + id + ", it doesn't respect the following condition : id < -9.007199254740992E15 || id > 9.007199254740992E15");
            }
            model = reader.ReadVarInt();
            if (model < 0)
            {
                throw new Exception("Forbidden value on model = " + model + ", it doesn't respect the following condition : model < 0");
            }
            var limit = reader.ReadUShort();

            ancestor = new int[limit];
            for (int i = 0; i < limit; i++)
            {
                ancestor[i] = reader.ReadInt();
            }
            limit     = reader.ReadUShort();
            behaviors = new int[limit];
            for (int i = 0; i < limit; i++)
            {
                behaviors[i] = reader.ReadInt();
            }
            name    = reader.ReadUTF();
            ownerId = reader.ReadInt();
            if (ownerId < 0)
            {
                throw new Exception("Forbidden value on ownerId = " + ownerId + ", it doesn't respect the following condition : ownerId < 0");
            }
            experience = reader.ReadVarUhLong();
            if (experience < 0 || experience > 9.007199254740992E15)
            {
                throw new Exception("Forbidden value on experience = " + experience + ", it doesn't respect the following condition : experience < 0 || experience > 9.007199254740992E15");
            }
            experienceForLevel = reader.ReadVarUhLong();
            if (experienceForLevel < 0 || experienceForLevel > 9.007199254740992E15)
            {
                throw new Exception("Forbidden value on experienceForLevel = " + experienceForLevel + ", it doesn't respect the following condition : experienceForLevel < 0 || experienceForLevel > 9.007199254740992E15");
            }
            experienceForNextLevel = reader.ReadDouble();
            if (experienceForNextLevel < -9.007199254740992E15 || experienceForNextLevel > 9.007199254740992E15)
            {
                throw new Exception("Forbidden value on experienceForNextLevel = " + experienceForNextLevel + ", it doesn't respect the following condition : experienceForNextLevel < -9.007199254740992E15 || experienceForNextLevel > 9.007199254740992E15");
            }
            level = reader.ReadSByte();
            if (level < 0)
            {
                throw new Exception("Forbidden value on level = " + level + ", it doesn't respect the following condition : level < 0");
            }
            maxPods = reader.ReadVarInt();
            if (maxPods < 0)
            {
                throw new Exception("Forbidden value on maxPods = " + maxPods + ", it doesn't respect the following condition : maxPods < 0");
            }
            stamina = reader.ReadVarInt();
            if (stamina < 0)
            {
                throw new Exception("Forbidden value on stamina = " + stamina + ", it doesn't respect the following condition : stamina < 0");
            }
            staminaMax = reader.ReadVarInt();
            if (staminaMax < 0)
            {
                throw new Exception("Forbidden value on staminaMax = " + staminaMax + ", it doesn't respect the following condition : staminaMax < 0");
            }
            maturity = reader.ReadVarInt();
            if (maturity < 0)
            {
                throw new Exception("Forbidden value on maturity = " + maturity + ", it doesn't respect the following condition : maturity < 0");
            }
            maturityForAdult = reader.ReadVarInt();
            if (maturityForAdult < 0)
            {
                throw new Exception("Forbidden value on maturityForAdult = " + maturityForAdult + ", it doesn't respect the following condition : maturityForAdult < 0");
            }
            energy = reader.ReadVarInt();
            if (energy < 0)
            {
                throw new Exception("Forbidden value on energy = " + energy + ", it doesn't respect the following condition : energy < 0");
            }
            energyMax = reader.ReadVarInt();
            if (energyMax < 0)
            {
                throw new Exception("Forbidden value on energyMax = " + energyMax + ", it doesn't respect the following condition : energyMax < 0");
            }
            serenity        = reader.ReadInt();
            aggressivityMax = reader.ReadInt();
            serenityMax     = reader.ReadVarInt();
            if (serenityMax < 0)
            {
                throw new Exception("Forbidden value on serenityMax = " + serenityMax + ", it doesn't respect the following condition : serenityMax < 0");
            }
            love = reader.ReadVarInt();
            if (love < 0)
            {
                throw new Exception("Forbidden value on love = " + love + ", it doesn't respect the following condition : love < 0");
            }
            loveMax = reader.ReadVarInt();
            if (loveMax < 0)
            {
                throw new Exception("Forbidden value on loveMax = " + loveMax + ", it doesn't respect the following condition : loveMax < 0");
            }
            fecondationTime = reader.ReadInt();
            boostLimiter    = reader.ReadInt();
            if (boostLimiter < 0)
            {
                throw new Exception("Forbidden value on boostLimiter = " + boostLimiter + ", it doesn't respect the following condition : boostLimiter < 0");
            }
            boostMax = reader.ReadDouble();
            if (boostMax < -9.007199254740992E15 || boostMax > 9.007199254740992E15)
            {
                throw new Exception("Forbidden value on boostMax = " + boostMax + ", it doesn't respect the following condition : boostMax < -9.007199254740992E15 || boostMax > 9.007199254740992E15");
            }
            reproductionCount    = reader.ReadInt();
            reproductionCountMax = reader.ReadVarInt();
            if (reproductionCountMax < 0)
            {
                throw new Exception("Forbidden value on reproductionCountMax = " + reproductionCountMax + ", it doesn't respect the following condition : reproductionCountMax < 0");
            }
            limit      = reader.ReadUShort();
            effectList = new Types.ObjectEffectInteger[limit];
            for (int i = 0; i < limit; i++)
            {
                effectList[i] = new Types.ObjectEffectInteger();
                effectList[i].Deserialize(reader);
            }
        }
コード例 #51
0
        internal void Init(BigEndianReader reader)
        {
            byte header = reader.ReadByte();

            if (header != 77)
            {
                throw new Exception("Header cannot be different than 77");
            }
            MapVersion = reader.ReadSByte();
            Id         = reader.ReadUInt();
            if (MapVersion >= 7)
            {
                Encrypted        = reader.ReadBoolean();
                EncryptedVersion = reader.ReadSByte();
                int dataLen = reader.ReadInt();
                if (Encrypted)
                {
                    byte[] key           = Encoding.UTF8.GetBytes("649ae451ca33ec53bbcbcc33becf15f4");
                    var    encryptedData = reader.ReadBytes(dataLen);
                    System.IO.MemoryStream decryptedData = new System.IO.MemoryStream();
                    for (int i = 0; i < dataLen; i++)
                    {
                        decryptedData.WriteByte((byte)(encryptedData[i] ^ (key[i % key.Length])));
                    }

                    reader = new BigEndianReader(decryptedData.ToArray());
                }
            }

            RelativeId            = reader.ReadUInt();
            MapType               = reader.ReadSByte();
            SubAreaId             = reader.ReadInt();
            TopNeighbourId        = reader.ReadInt();
            BottomNeighbourId     = reader.ReadInt();
            LeftNeighbourId       = reader.ReadInt();
            RightNeighbourId      = reader.ReadInt();
            ShadowBonusOnEntities = reader.ReadInt();

            if (MapVersion >= 9)
            {
                int color = reader.ReadInt();
                BackgroundAlpha = (color & 4278190080) >> 32;
                BackgroundRed   = (color & 16711680) >> 16;
                BackgroundGreen = (color & 65280) >> 8;
                BackgroundBlue  = (color & 255);
                uint gridColor = reader.ReadUInt();
                GridAlpha = (gridColor & 4278190080) >> 32;
                GridRed   = (gridColor & 16711680) >> 16;
                GridGreen = (gridColor & 65280) >> 8;
                GridBlue  = (gridColor & 255);
                GridColor = (GridAlpha & 255) << 32 | (GridRed & 255) << 16 | (GridGreen & 255) << 8 | (GridBlue & 255);
            }
            else if (MapVersion >= 3)
            {
                BackgroundRed   = reader.ReadSByte();
                BackgroundGreen = reader.ReadSByte();
                BackgroundBlue  = reader.ReadSByte();
            }
            BackgroundColor = (BackgroundRed & 255) << 16 | (BackgroundGreen & 255) << 8 | (BackgroundBlue & 255);
            if (MapVersion >= 4)
            {
                ZoomScale   = Convert.ToDouble(reader.ReadUShort() / 100);
                ZoomOffsetX = Convert.ToInt32(reader.ReadShort());
                ZoomOffsetY = Convert.ToInt32(reader.ReadShort());
                if (ZoomScale < 1)
                {
                    ZoomScale   = 1;
                    ZoomOffsetX = 0;
                    ZoomOffsetY = 0;
                }
            }
            if (MapVersion > 10)
            {
                TacticalModeTempladeId = reader.ReadInt();
            }
            UseLowPassFilter = reader.ReadBoolean();
            UseReverb        = reader.ReadBoolean();
            if (UseReverb)
            {
                PresetId = reader.ReadInt();
            }
            else
            {
                PresetId = -1;
            }

            BackgroundsCount = reader.ReadSByte();
            for (var i = 0; i < BackgroundsCount; i++)
            {
                var fixture = new Fixture();
                fixture.Init(reader);
                BackgroundFixtures.Add(fixture);
            }
            ForegroundsCount = reader.ReadSByte();
            for (var i = 0; i < ForegroundsCount; i++)
            {
                var fixture = new Fixture();
                fixture.Init(reader);
                ForegroundFixtures.Add(fixture);
            }
            reader.ReadInt();
            GroundCRC   = reader.ReadInt().ToString();
            LayersCount = reader.ReadSByte();
            for (int i = 0; i < LayersCount; i++)
            {
                var layer = new Layer();
                layer.Init(reader, MapVersion);
                Layers.Add(layer);
            }
            CellsCount = 560;
            for (int i = 0; i < CellsCount; i++)
            {
                CellData cd = new CellData();
                cd.Init(reader, MapVersion, i, this);
                Cells.Add(cd);
            }
        }
コード例 #52
0
        public bool Build(BigEndianReader reader)
        {
            bool result;

            if (reader.BytesAvailable <= 0L)
            {
                result = false;
            }
            else
            {
                if (this.IsValid)
                {
                    result = true;
                }
                else
                {
                    if (!this.Header.HasValue && reader.BytesAvailable < 2L)
                    {
                        result = false;
                    }
                    else
                    {
                        if (reader.BytesAvailable >= 2L && !this.Header.HasValue)
                        {
                            this.Header = new int?((int)reader.ReadShort());
                        }
                        bool formatedHeader;
                        if (this.LengthBytesCount.HasValue)
                        {
                            long num  = reader.BytesAvailable;
                            int? num2 = this.LengthBytesCount;
                            if (num >= (long)num2.GetValueOrDefault() && num2.HasValue)
                            {
                                formatedHeader = this.Length.HasValue;
                                goto CheckHeader;
                            }
                        }
                        formatedHeader = true;
CheckHeader:
                        if (!formatedHeader)
                        {
                            if (this.LengthBytesCount < 0 || this.LengthBytesCount > 3)
                            {
                                throw new Exception("Malformated Message Header, invalid bytes number to read message length (inferior to 0 or superior to 3)");
                            }
                            this.Length = new int?(0);
                            for (int i = this.LengthBytesCount.Value - 1; i >= 0; i--)
                            {
                                this.Length |= (int)reader.ReadByte() << i * 8;
                            }
                        }
                        if (this.Length.HasValue && !this.m_dataMissing)
                        {
                            if (this.Length == 0)
                            {
                                if (this.ReadData)
                                {
                                    this.Data = new byte[0];
                                }
                                result = true;
                                return(result);
                            }
                            long num  = reader.BytesAvailable;
                            int? num2 = this.Length;
                            if (num >= (long)num2.GetValueOrDefault() && num2.HasValue)
                            {
                                if (this.ReadData)
                                {
                                    this.Data = reader.ReadBytes(this.Length.Value);
                                }
                                else
                                {
                                    this.m_availableBytes = reader.BytesAvailable;
                                }
                                result = true;
                                return(result);
                            }
                            num2 = this.Length;
                            num  = reader.BytesAvailable;
                            if ((long)num2.GetValueOrDefault() > num && num2.HasValue)
                            {
                                if (this.ReadData)
                                {
                                    this.Data = reader.ReadBytes((int)reader.BytesAvailable);
                                }
                                else
                                {
                                    this.m_availableBytes = reader.BytesAvailable;
                                }
                                this.m_dataMissing = true;
                                result             = false;
                                return(result);
                            }
                        }
                        else
                        {
                            if (this.Length.HasValue && this.m_dataMissing)
                            {
                                long num  = (long)(this.ReadData ? this.Data.Length : 0) + reader.BytesAvailable;
                                int? num2 = this.Length;
                                if (num < (long)num2.GetValueOrDefault() && num2.HasValue)
                                {
                                    if (this.ReadData)
                                    {
                                        int destinationIndex = this.m_data.Length;
                                        Array.Resize <byte>(ref this.m_data, (int)((long)this.Data.Length + reader.BytesAvailable));
                                        byte[] array = reader.ReadBytes((int)reader.BytesAvailable);
                                        Array.Copy(array, 0, this.Data, destinationIndex, array.Length);
                                    }
                                    else
                                    {
                                        this.m_availableBytes = reader.BytesAvailable;
                                    }
                                    this.m_dataMissing = true;
                                }
                                num  = (long)(this.ReadData ? this.Data.Length : 0) + reader.BytesAvailable;
                                num2 = this.Length;
                                if (num >= (long)num2.GetValueOrDefault() && num2.HasValue)
                                {
                                    if (this.ReadData)
                                    {
                                        int num3 = this.Length.Value - this.Data.Length;
                                        Array.Resize <byte>(ref this.m_data, this.Data.Length + num3);
                                        byte[] array = reader.ReadBytes(num3);
                                        Array.Copy(array, 0, this.Data, this.Data.Length - num3, num3);
                                    }
                                    else
                                    {
                                        this.m_availableBytes = reader.BytesAvailable;
                                    }
                                }
                            }
                        }
                        result = this.IsValid;
                    }
                }
            }
            return(result);
        }
コード例 #53
0
ファイル: DlmMap.cs プロジェクト: Zaetic/Symbioz-2.38-RED
        public static DlmMap ReadFromStream(BigEndianReader givenReader, DlmReader dlmReader)
        {
            BigEndianReader reader = givenReader;
            DlmMap          map    = new DlmMap();

            map.Version = reader.ReadByte();
            map.Id      = reader.ReadInt();
            if (map.Version >= 7)
            {
                map.Encrypted         = reader.ReadBoolean();
                map.EncryptionVersion = reader.ReadByte();
                int len = reader.ReadInt();
                if (map.Encrypted)
                {
                    string key = dlmReader.DecryptionKey;
                    if (key == null && dlmReader.DecryptionKeyProvider != null)
                    {
                        key = dlmReader.DecryptionKeyProvider(map.Id);
                    }
                    if (key == null)
                    {
                        throw new InvalidOperationException(string.Format("Cannot decrypt the map {0} without decryption key", map.Id));
                    }
                    byte[] data       = reader.ReadBytes(len);
                    byte[] encodedKey = Encoding.Default.GetBytes(key);
                    if (key.Length > 0)
                    {
                        for (int i = 0; i < data.Length; i++)
                        {
                            data[i] ^= encodedKey[i % key.Length];
                        }
                        reader = new BigEndianReader(new MemoryStream(data));
                    }
                }
            }
            map.RelativeId            = reader.ReadUInt();
            map.MapType               = reader.ReadByte();
            map.SubAreaId             = reader.ReadInt();
            map.TopNeighbourId        = reader.ReadInt();
            map.BottomNeighbourId     = reader.ReadInt();
            map.LeftNeighbourId       = reader.ReadInt();
            map.RightNeighbourId      = reader.ReadInt();
            map.ShadowBonusOnEntities = (int)reader.ReadUInt();

            if (map.Version >= 9)
            {
                var readColor       = reader.ReadInt();
                var backgroundAlpha = (readColor & 4278190080) >> 32;
                var backgroundRed   = (readColor & 16711680) >> 16;
                var backgroundGreen = (readColor & 65280) >> 8;
                var backgroundBlue  = readColor & 255;
                readColor = (int)reader.ReadUInt();
                var gridAlpha = (readColor & 4278190080) >> 32;
                var gridRed   = (readColor & 16711680) >> 16;
                var gridGreen = (readColor & 65280) >> 8;
                var gridBlue  = readColor & 255;
                var gridColor = (gridAlpha & 255) << 32 | (gridRed & 255) << 16 | (gridGreen & 255) << 8 | gridBlue & 255;
            }
            else if (map.Version >= 3)
            {
                map.BackgroundColor = Color.FromArgb((int)reader.ReadByte(), (int)reader.ReadByte(), (int)reader.ReadByte());
            }
            if (map.Version >= 4)
            {
                map.ZoomScale   = reader.ReadUShort();
                map.ZoomOffsetX = reader.ReadShort();
                map.ZoomOffsetY = reader.ReadShort();
            }
            map.UseLowPassFilter = (reader.ReadByte() == 1);
            map.UseReverb        = (reader.ReadByte() == 1);
            if (map.UseReverb)
            {
                map.PresetId = reader.ReadInt();
            }
            else
            {
                map.PresetId = -1;
            }

            map.BackgroudFixtures = new DlmFixture[(int)reader.ReadByte()];
            for (int i = 0; i < map.BackgroudFixtures.Length; i++)
            {
                map.BackgroudFixtures[i] = DlmFixture.ReadFromStream(map, reader);
            }
            map.ForegroundFixtures = new DlmFixture[(int)reader.ReadByte()];
            for (int i = 0; i < map.ForegroundFixtures.Length; i++)
            {
                map.ForegroundFixtures[i] = DlmFixture.ReadFromStream(map, reader);
            }
            reader.ReadInt();
            map.GroundCRC = reader.ReadInt();
            map.Layers    = new DlmLayer[(int)reader.ReadByte()];
            for (int i = 0; i < map.Layers.Length; i++)
            {
                map.Layers[i] = DlmLayer.ReadFromStream(map, reader);
            }
            map.Cells = new DlmCellData[560];
            short j = 0;

            while ((int)j < map.Cells.Length)
            {
                map.Cells[(int)j] = DlmCellData.ReadFromStream(map, j, reader);
                j += 1;
            }
            return(map);
        }
コード例 #54
0
 protected override void Parse(BigEndianReader reader)
 {
     reader.ReadByte();             // ID
     _Unk1       = reader.ReadUInt32();
     _Unk2       = reader.ReadUInt32();
     _Unk3       = reader.ReadByte();
     _CharName   = reader.ReadAsciiString(30);
     _Unk4       = reader.ReadInt16();
     _Flags      = reader.ReadUInt32();
     _Unk5       = reader.ReadUInt32();
     _LoginCount = reader.ReadUInt32();
     _Profession = reader.ReadByte();
     reader.ReadBytes(15);
     _GenderAndRace = reader.ReadByte();
     _Strength      = reader.ReadByte();
     _Dexterity     = reader.ReadByte();
     _Intelligence  = reader.ReadByte();
     _Skill1        = reader.ReadByte();
     _Skill1Amount  = reader.ReadByte();
     _Skill2        = reader.ReadByte();
     _Skill2Amount  = reader.ReadByte();
     _Skill3        = reader.ReadByte();
     _Skill3Amount  = reader.ReadByte();
     _Skill4        = reader.ReadByte();
     _Skill4Amount  = reader.ReadByte();
     _SkinHue       = reader.ReadInt16();
     _HairStyle     = reader.ReadInt16();
     _HairHue       = reader.ReadInt16();
     _BeardStyle    = reader.ReadInt16();
     _BeardHue      = reader.ReadInt16();
     _ShardIndex    = reader.ReadByte();
     _StartingCity  = reader.ReadByte();
     _CharSlot      = reader.ReadUInt32();
     _ClientIP      = reader.ReadUInt32();
     _ShirtHue      = reader.ReadInt16();
     _PantsHue      = reader.ReadInt16();
 }