Exemplo n.º 1
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                s.Write(mScreenRatio);
                s.Write(mSize);
            }
Exemplo n.º 2
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mData.X);
            s.Write(mData.Y);
        }
Exemplo n.º 3
0
        protected override Stream UnParse()
        {
            var outputStream = new MemoryStream();
            var s            = new BinaryStreamWrapper(outputStream, ByteOrder.BigEndian);

            s.Write(mVersion);
            if (mEffectSections == null)
            {
                mEffectSections = new EffectSectionList(OnResourceChanged);
            }
            mEffectSections.UnParse(outputStream);
            if (mResourceSections == null)
            {
                mResourceSections = new ResourceSectionList(OnResourceChanged);
            }
            mResourceSections.UnParse(outputStream);
            if (mVisualEffectSections == null)
            {
                mVisualEffectSections = new VisualEffectSection(0, OnResourceChanged, 2);
            }
            s.Write(mVisualEffectSections.Version);
            mVisualEffectSections.UnParse(outputStream);
            if (mVisualEffectIds == null)
            {
                mVisualEffectIds = new VisualEffectIdList(OnResourceChanged);
            }
            mVisualEffectIds.UnParse(outputStream);
            if (mVisualEffectNames == null)
            {
                mVisualEffectNames = new VisualEffectNameList(OnResourceChanged);
            }
            mVisualEffectNames.UnParse(outputStream);
            return(outputStream);
        }
Exemplo n.º 4
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mIndex);
            s.Write(mEffectId);
        }
Exemplo n.º 5
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mIndex);
            s.Write(mEffectName, StringType.ZeroDelimited);
        }
Exemplo n.º 6
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                mStrengthCurve.UnParse(stream);
                s.Write(mRange);
                s.Write(mKillRange);
            }
Exemplo n.º 7
0
            protected override void WriteElement(Stream stream, Property element)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                s.Write((ulong)element.Key);
                s.Write((byte)element.ValueType);
                element.UnParse(stream);
            }
Exemplo n.º 8
0
        public override void UnParse(Stream s)
        {
            var sw = new BinaryStreamWrapper(s, ByteOrder.LittleEndian);

            sw.Write(mData.R);
            sw.Write(mData.G);
            sw.Write(mData.B);
        }
Exemplo n.º 9
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(HashedName);
            s.Write((ulong)Shader);
            mProperties.UnParse(stream);
        }
Exemplo n.º 10
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                s.Write(mEmitScale);
                s.Write(mSizeScale);
                s.Write(mAlphaScale);
            }
Exemplo n.º 11
0
            public void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.LittleEndian);

                s.Write(mInstance);
                s.Write(mUnknown1);
                s.Write(mUnknown2);
            }
Exemplo n.º 12
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mData.Left);
            s.Write(mData.Top);
            s.Write(mData.Right);
            s.Write(mData.Bottom);
        }
Exemplo n.º 13
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mFlags);
            s.Write(mScale);
            mOrientation.UnParse(stream);
            mPosition.UnParse(stream);
        }
Exemplo n.º 14
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                s.Write(mType);
                s.Write(mDestination);
                s.Write(mSource);
                mParameters.UnParse(stream);
            }
Exemplo n.º 15
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                mLengthRange.UnParse(stream);
                mCurve.UnParse(stream);
                s.Write(mCurveVary);
                s.Write(mSpeedScale);
                s.Write(mChannelId);
                s.Write(mMode);
            }
Exemplo n.º 16
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mLifetime);
            s.Write(mFadeTime);
            mStrengthCurve.UnParse(stream);
            mFrequencyCurve.UnParse(stream);
            s.Write(mAspectRatio);
            s.Write(mBaseTableType);
            s.Write(mFalloff);
        }
Exemplo n.º 17
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            foreach (TSection list in this)
            {
                s.Write(list.Type);
                s.Write(list.Version);
                list.UnParse(stream);
            }
            s.Write((ushort)0xFFFF);
        }
Exemplo n.º 18
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                mTime.UnParse(stream);
                mStrength.UnParse(stream);
                s.Write(mTurnRange);
                s.Write(mTurnOffset);
                s.Write(mMix);
                mTurnOffsets.UnParse(stream);
                s.Write(mWalkLoopType);
            }
Exemplo n.º 19
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                if (isTheSims4)
                {
                    s.Write(mData);
                }
                else
                {
                    uint data = (uint)(mData & 0xFFFFFFFF);
                    s.Write(data);
                }
            }
Exemplo n.º 20
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                mParticleLifetime.UnParse(stream);
                s.Write(mPrerollTime);
                mEmitDelay.UnParse(stream);
                mEmitRetrigger.UnParse(stream);
                mEmitDirection.UnParse(stream);
                mEmitSpeed.UnParse(stream);
                mEmitVolume.UnParse(stream);
                if (bHasTorus)
                {
                    s.Write(mEmitTorusWidth);
                }
            }
Exemplo n.º 21
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            mElements.UnParse(stream);
            s.Write(mFlags);
        }
Exemplo n.º 22
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mFlags);
            s.Write(mViewFlags);
            s.Write(mLifetime);
            mHeadingCurve.UnParse(stream);
            mPitchCurve.UnParse(stream);
            mRollCurve.UnParse(stream);
            mDistanceCurve.UnParse(stream);
            mFOVCurve.UnParse(stream);
            mNearClipCurve.UnParse(stream);
            mFarClipCurve.UnParse(stream);
            s.Write(mCameraId);
            s.Write(mCubemapResource);
        }
Exemplo n.º 23
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                s.Write(mTimeRate);
                mRateDir.UnParse(stream);
                mWiggleDir.UnParse(stream);
            }
Exemplo n.º 24
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                mPosition.UnParse(stream);
                mVelocity.UnParse(stream);
                s.Write(mTime);
            }
Exemplo n.º 25
0
            public override void UnParse(Stream stream)
            {
                var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

                s.Write(mFlags);
                s.Write(mId);
                s.Write(mBounce);
                s.Write(mSlide);
                s.Write(mCollisionRadius);
                s.Write(mDeathProbability);
                s.Write(mPinOffset);
                s.Write(mString01, StringType.ZeroDelimited);
                s.Write(mString02, StringType.ZeroDelimited);
                mData.UnParse(stream);
            }
Exemplo n.º 26
0
            public override void UnParse(Stream s)
            {
                var w = new BinaryStreamWrapper(s, ByteOrder.BigEndian);

                foreach (VisualEffectName item in this)
                {
                    item.UnParse(s);
                }
                w.Write(0xFFFFFFFF);
            }
Exemplo n.º 27
0
        public void UnParse(Stream stream)
        {
            BinaryStreamWrapper wrapper = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            wrapper.Write(this.mVersion);
            // Write Effect Sections
            this.mEffectSectionList.UnParse(stream);
            // Write Resource Sections
            this.mResourceSectionList.UnParse(stream);
            // Write Visual Effects
            wrapper.Write(this.mVisualEffectSection.Version);
            this.mVisualEffectSection.UnParse(stream);
            //wrapper.Write(this.mVisualEffectVersion);
            //this.mVisualEffectBuilders.UnParse(stream);
            // Write Reserved
            wrapper.Write(this.mReserved);
            // Write Handle List
            this.mVisualEffectHandleList.UnParse(stream);
        }
Exemplo n.º 28
0
            public void UnParse(Stream s)
            {
                BinaryStreamWrapper wrapper = new BinaryStreamWrapper(s, ByteOrder.BigEndian);
                int count = base.Count;

                for (int i = 0; i < count; i++)
                {
                    base[i].UnParse(s);
                }
                wrapper.Write(uint.MaxValue);
            }
Exemplo n.º 29
0
            public void UnParse(Stream s)
            {
                var br = new BinaryStreamWrapper(s, ByteOrder.BigEndian);

                br.Write((UInt32)mId);
                br.Write((ushort)mTypeCode);
                br.Write(mRepCode);
                if (!HasTypeData && mItems.Count == 0)
                {
                    mItems.Add();
                }
                if (HasTypeData)
                {
                    br.Write(mItems.Count);
                    br.Write(ItemSize);
                }
                foreach (TypedData block in mItems)
                {
                    block.UnParse(s);
                }
            }
Exemplo n.º 30
0
        public override void UnParse(Stream stream)
        {
            var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian);

            s.Write(mFlags);

            s.Write(mMessageId);
            s.Write(mMessageData1);
            s.Write(mMessageData2);
            s.Write(mMessageData3);
            s.Write(mMessageData4);
            s.Write(mMessageString, StringType.ZeroDelimited);
            s.Write(mLife);
        }
        public unsafe void TestMethod()
        {
            MemoryStream stream = new MemoryStream();
            BinaryStreamWrapper bs = new BinaryStreamWrapper(stream, false);
            Random rand = new Random();
            int seed = rand.Next();
            rand = new Random(seed);
            byte[] data = new byte[16];
            byte[] data2 = new byte[16];

            fixed (byte* lp = data)
            {
                for (int x = 0; x < 10000; x++)
                {
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(byte*)lp);
                    int skip = rand.Next(40) + 1;
                    bs.Position += skip;
                    bs.Position -= rand.Next(skip);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(sbyte*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(short*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(int*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(long*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(ushort*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(uint*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(ulong*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(NextDecimal(data, rand));
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(*(Guid*)lp);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(NextDate(data, rand));
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(NextSingle(data, rand));
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write(NextDouble(data, rand));
                    rand.NextBytes(data);
                    bool value = (*lp != 0);
                    while (rand.Next(4) < 2) bs.Write(value);

                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp);
                    data[3] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp);
                    data[2] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp);
                    data[1] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp);

                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);
                    data[7] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);
                    data[6] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);
                    data[5] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);
                    data[4] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);
                    data[3] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);
                    data[2] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);
                    data[1] = 0;
                    while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp);

                    rand.NextBytes(data);
                    bs.Write(data, 0, data.Length);

                    while (rand.Next(4) < 2)
                    {
                        if (bs.Position > 100)
                        {
                            bs.Position -= 100;
                            int insertCount = rand.Next(16) + 1;
                            bs.InsertBytes(insertCount, 100);
                            bs.Write(data, 0, insertCount);
                            bs.Position -= insertCount;
                            bs.ReadAll(data2, 0, insertCount);
                            bs.Position -= insertCount;
                            bs.RemoveBytes(insertCount, 100);
                            bs.Position += 100;

                            for (int y = 0; y < insertCount; y++)
                            {
                                if (data[y] != data2[y])
                                    throw new Exception();
                            }
                        }
                    }
                }
                rand = new Random(seed);

                bs.Position = 0;

                for (int x = 0; x < 10000; x++)
                {
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadUInt8() != (*(byte*)lp)) throw new Exception();
                    int skip = rand.Next(40) + 1;
                    bs.Position += skip;
                    bs.Position -= rand.Next(skip);
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadInt8() != (*(sbyte*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadInt16() != (*(short*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadInt32() != (*(int*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadInt64() != (*(long*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadUInt16() != (*(ushort*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadUInt32() != (*(uint*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadUInt64() != (*(ulong*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadDecimal() != NextDecimal(data, rand)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadGuid() != (*(Guid*)lp)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadDateTime() != NextDate(data, rand)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadSingle() != NextSingle(data, rand)) throw new Exception();
                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.ReadDouble() != NextDouble(data, rand)) throw new Exception();
                    rand.NextBytes(data);
                    bool b2 = (*lp != 0);
                    while (rand.Next(4) < 2) if (bs.ReadBoolean() != b2) throw new Exception();

                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception();
                    data[3] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception();
                    data[2] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception();
                    data[1] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception();

                    rand.NextBytes(data);
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();
                    data[7] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();
                    data[6] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();
                    data[5] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();
                    data[4] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();
                    data[3] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();
                    data[2] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();
                    data[1] = 0;
                    while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception();

                    rand.NextBytes(data);
                    bs.ReadAll(data2, 0, 16);
                    if (!data2.SequenceEqual<byte>(data)) throw new Exception();

                    while (rand.Next(4) < 2)
                    {
                        if (bs.Position > 100)
                        {
                            int insertCount = rand.Next(16);
                        }
                    }
                }
            }
        }
        public void Test()
        {
            MemoryPoolTest.TestMemoryLeak();
            const int count = 1000;
            MemoryStream ms = new MemoryStream();
            ms.Write(new byte[100000], 0, 100000);
            ms.Write(new byte[100000], 0, 100000);
            ms.Position = 0;
            BinaryStreamWrapper bs = new BinaryStreamWrapper(ms, false);
            Stopwatch sw = new Stopwatch();
            //DateTime b = DateTime.UtcNow;
            long b = 10;
            //Guid b = Guid.NewGuid() ;
            for (int x2 = 0; x2 < count; x2++)
            {
                bs.Position = 0;
                for (int x = 0; x < count; x++)
                {
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                }
            }

            sw.Start();
            for (int x2 = 0; x2 < count; x2++)
            {
                bs.Position = 0;
                for (int x = 0; x < count; x++)
                {
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    bs.Write(b);
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadDecimal();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt64();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt32();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadInt16();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.ReadByte();
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                    //bs.Write7Bit(b);
                }
            }
            sw.Stop();
            Assert.IsTrue(true);
            ms.Dispose();
            MemoryPoolTest.TestMemoryLeak();

            //MessageBox.Show((count * count * 10 / sw.Elapsed.TotalSeconds / 1000000).ToString());
        }