Esempio n. 1
0
        public void Serialize(NetBitReader reader)
        {
            reader.SkipBytes(9);

            Key  = reader.ReadFString();
            Text = reader.ReadFString();
        }
Esempio n. 2
0
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/099c2469b494de4752e9d63535767bb9fcc90d16/Engine/Source/Runtime/Core/Private/Math/UnrealMath.cpp#L832
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            X = reader.ReadSingle();
            Y = reader.ReadSingle();
            Z = reader.ReadSingle();

            var XYZMagSquared = (X * X + Y * Y + Z * Z);
            var WSquared      = 1.0f - XYZMagSquared;

            // If mag of (X,Y,Z) <= 1.0, then we calculate W to make magnitude of Q 1.0
            if (WSquared >= 0f)
            {
                W = (float)Math.Sqrt(WSquared);
            }
            // If mag of (X,Y,Z) > 1.0, we set W to zero, and then renormalize
            else
            {
                W = 0f;

                float XYZInvMag = (float)(1 / Math.Sqrt(XYZMagSquared));
                X *= XYZInvMag;
                Y *= XYZInvMag;
                Z *= XYZInvMag;
            }
        }
Esempio n. 3
0
        public void ReadVectorFieldTest()
        {
            var reader = new NetBitReader(new byte[] { 0x01, 0x0B, 0xC7, 0x47, 0x8A, 0x26, 0xA7, 0xC7, 0x00, 0x80, 0x71, 0xC5 }, 96)
            {
                NetworkVersion       = NetworkVersionHistory.HISTORY_CHARACTER_MOVEMENT_NOINTERP,
                EngineNetworkVersion = EngineNetworkVersionHistory.HISTORY_CLASSNETCACHE_FULLNAME
            };

            var export = new NetFieldExport()
            {
                Handle = 0,
                Name   = "VectorField"
            };

            var group = new NetFieldExportGroup()
            {
                PathName = "group1",
                NetFieldExportsLength = 1,
                NetFieldExports       = new NetFieldExport[] { export },
                PathNameIndex         = 1
            };

            var guidCache = new NetGuidCache();
            var parser    = new NetFieldParser(guidCache, ParseMode.Full, "Unreal.Core.Test");

            var data = parser.CreateType(group.PathName);

            parser.ReadField(data, export, export.Handle, group, reader);
            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
            Assert.Equal(-3864, ((NetFieldGroup1)data).VectorField.Z);
        }
Esempio n. 4
0
        public void ReadBooleanFieldTest()
        {
            var reader = new NetBitReader(new byte[] { 0x01 }, 1);
            var export = new NetFieldExport()
            {
                Handle = 0,
                Name   = "bField"
            };
            var group = new NetFieldExportGroup()
            {
                PathName = "group1",
                NetFieldExportsLength = 1,
                NetFieldExports       = new NetFieldExport[] { export },
                PathNameIndex         = 1
            };

            var guidCache = new NetGuidCache();
            var parser    = new NetFieldParser(guidCache, ParseMode.Full, "Unreal.Core.Test");

            var data = parser.CreateType(group.PathName);

            parser.ReadField(data, export, export.Handle, group, reader);
            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
            Assert.True(((NetFieldGroup1)data).bField);
        }
Esempio n. 5
0
        public void ReadGuidFieldTest()
        {
            var reader = new NetBitReader(new byte[] { 0x87, 0x04 });
            var export = new NetFieldExport()
            {
                Handle = 0,
                Name   = "ItemDefinitionField"
            };

            var group = new NetFieldExportGroup()
            {
                PathName = "group1",
                NetFieldExportsLength = 1,
                NetFieldExports       = new NetFieldExport[] { export },
                PathNameIndex         = 1
            };

            var guidCache = new NetGuidCache();
            var parser    = new NetFieldParser(guidCache, ParseMode.Full, "Unreal.Core.Test");

            var data = parser.CreateType(group.PathName);

            parser.ReadField(data, export, export.Handle, group, reader);
            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
            Assert.True(((NetFieldGroup1)data).ItemDefinitionField.IsValid());
            Assert.Equal(323u, ((NetFieldGroup1)data).ItemDefinitionField.Value);
        }
        public void Serialize(NetBitReader reader)
        {
            var isHardcoded = reader.ReadBoolean();

            if (isHardcoded)
            {
                uint nameIndex;
                if (reader.EngineNetworkVersion < EngineNetworkVersionHistory.HISTORY_CHANNEL_NAMES)
                {
                    nameIndex = reader.ReadUInt32();
                }
                else
                {
                    nameIndex = reader.ReadIntPacked();
                }

                Value = ((UnrealNames)nameIndex).ToString();

                return;
            }

            var inString = reader.ReadFString();
            var inNumber = reader.ReadInt32();

            Value = inString;
        }
Esempio n. 7
0
        public void Serialize(NetBitReader reader)
        {
            _reader = new NetBitReader(reader.ReadBits(reader.GetBitsLeft()));
            _reader.EngineNetworkVersion = reader.EngineNetworkVersion;

            TotalBits = _reader.GetBitsLeft();
        }
        public void Serialize(NetBitReader reader)
        {
            byte sourceNum = reader.ReadByte();

            bool    bHasAdditiveSources          = reader.ReadBit();
            bool    bHasOverrideSources          = reader.ReadBit();
            FVector lastPreAdditiveVelocity      = reader.SerializePropertyVector10();
            bool    bIsAdditiveVelocityApplied   = reader.ReadBit();
            byte    lastAccumulatedSettingsFlags = reader.ReadByte();

            //Off by about 130 bits
            for (int i = 0; i < sourceNum; i++)
            {
                uint guid = reader.SerializePropertyObject();

                ushort priority = reader.ReadUInt16();
                ushort localId  = reader.ReadUInt16();
                byte   accumulatedModeSerialize = reader.ReadByte();
                string instanceName             = reader.SerializePropertyName();
                float  currentTime   = reader.SerializePropertyFloat();
                float  duration      = reader.SerializePropertyFloat();
                byte   statusFlags   = reader.ReadByte();
                bool   bInLocalSpace = reader.ReadBit();
            }
        }
Esempio n. 9
0
        public void Serialize(NetBitReader reader)
        {
            DebugData = reader.ReadBytes(2);

            if (reader.IsError || !reader.AtEnd())
            {
            }
        }
        public void NetUniqueIdTest(byte[] rawData, int bitCount)
        {
            var reader = new NetBitReader(rawData, bitCount);

            reader.SerializePropertyNetId();
            Assert.False(reader.IsError);
            Assert.True(reader.AtEnd());
        }
Esempio n. 11
0
        public void NetUniqueIdTest(byte[] rawData, int bitCount, string expected)
        {
            var reader = new NetBitReader(rawData, bitCount);
            var result = reader.SerializePropertyNetId();

            Assert.Equal(expected, result);
            Assert.False(reader.IsError);
            Assert.True(reader.AtEnd());
        }
Esempio n. 12
0
        public void ReadFixedCompressedFloatTest(byte[] rawData, float expected, int maxValue, int numBits)
        {
            var reader = new NetBitReader(rawData);
            var result = reader.ReadFixedCompressedFloat(maxValue, numBits);

            Assert.Equal(expected, result);
            Assert.False(reader.IsError);
            Assert.True(reader.AtEnd());
        }
        //bool FQuat::NetSerialize(FArchive& Ar, class UPackageMap*, bool& bOutSuccess)
        public void Serialize(NetBitReader reader)
        {
            X = reader.ReadSingle();
            Y = reader.ReadSingle();
            Z = reader.ReadSingle();

            var XYZMagSquared = (X * X + Y * Y + Z * Z);
            var WSquared      = 1.0f - XYZMagSquared;
        }
Esempio n. 14
0
        public void SerializePropertyVector2DTest(byte[] rawData, float x, float y)
        {
            var reader   = new NetBitReader(rawData);
            var result   = reader.SerializePropertyVector2D();
            var expected = new FVector2D(x, y);

            Assert.Equal(expected, result);
            Assert.False(reader.IsError);
            Assert.True(reader.AtEnd());
        }
        public void DateTimeTest(byte[] rawData, int bitCount)
        {
            var reader     = new NetBitReader(rawData, bitCount);
            var playerName = new FDateTime();

            playerName.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
        public void BuildingAttributeTest(byte[] rawData, int bitCount)
        {
            var reader = new NetBitReader(rawData, bitCount);
            var attr   = new FQuantizedBuildingAttribute();

            attr.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
        public void GameplayEffectContextHandleTest(byte[] rawData, int bitCount)
        {
            var reader = new NetBitReader(rawData, bitCount);
            var handle = new FGameplayEffectContextHandle();

            handle.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Source/Runtime/Core/Private/Internationalization/Text.cpp#L794
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            //var flags = reader.ReadInt32();
            //var historyType = reader.ReadByteAsEnum<ETextHistoryType>();
            // 4 bytes ?
            reader.SkipBytes(9);

            Namespace = reader.ReadFString();
            Text      = reader.ReadFString();
        }
Esempio n. 19
0
        public void GameplayAbilityRepAnimMontageTest(byte[] rawData, int bitCount)
        {
            var reader  = new NetBitReader(rawData, bitCount);
            var montage = new FGameplayAbilityRepAnimMontage();

            montage.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
Esempio n. 20
0
        public void GameplayTagTeste(byte[] rawData, int bitCount)
        {
            var reader = new NetBitReader(rawData, bitCount);
            var tag    = new FGameplayTag();

            tag.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
Esempio n. 21
0
        // doesnt work because of FGameplayEffectContextHandle
        //[InlineData(new byte[] {
        //    0x04, 0xF0, 0x41, 0x2F, 0x4E, 0x0D, 0x21, 0x00,
        //    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 }, 110)]
        //[InlineData(new byte[] {
        //    0x04, 0xF0, 0x41, 0x91, 0x43, 0x1D, 0x1E, 0x00,
        //    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 }, 110)]
        public void GameplayCueParametersTest(byte[] rawData, int bitCount)
        {
            var reader = new NetBitReader(rawData, bitCount);
            var cue    = new FGameplayCueParameters();

            cue.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
 public void Serialize(NetBitReader reader)
 {
     if (reader.EngineNetworkVersion >= EngineNetworkVersionHistory.HISTORY_FAST_ARRAY_DELTA_STRUCT)
     {
         reader.ReadBit();
     }
     reader.ReadBit();
     Id = reader.ReadIntPacked();
     reader.SkipBits(31);
 }
Esempio n. 23
0
        public void PredictionKeyTest(byte[] rawData, int bitCount)
        {
            var reader = new NetBitReader(rawData, bitCount);
            var key    = new FPredictionKey();

            key.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
        }
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayEffectTypes.cpp#L311
        /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayEffectTypes.cpp#L177
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            var validData = reader.ReadBit();

            if (validData)
            {
                var RepBits = reader.ReadBitsToInt(7);

                if ((RepBits & (1 << 0)) > 0)
                {
                    Instigator = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 1)) > 0)
                {
                    EffectCauser = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 2)) > 0)
                {
                    AbilityCDO = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 3)) > 0)
                {
                    SourceObject = reader.ReadIntPacked();
                }
                if ((RepBits & (1 << 4)) > 0)
                {
                    // SafeNetSerializeTArray_HeaderOnly
                    var bitCount = (int)Math.Ceiling(Math.Log2(31));
                    var arrayNum = reader.ReadBitsToInt(bitCount);

                    // SafeNetSerializeTArray_Default
                    Actors = new ActorGuid[arrayNum];
                    for (var i = 0; i < arrayNum; i++)
                    {
                        Actors[i] = new ActorGuid()
                        {
                            Value = reader.ReadIntPacked()
                        };
                    }
                }
                if ((RepBits & (1 << 5)) > 0)
                {
                    HitResult = new FHitResult(reader);
                }
                if ((RepBits & (1 << 6)) > 0)
                {
                    WorldOrigin     = reader.SerializePropertyVector100();
                    bHasWorldOrigin = true;
                }
                else
                {
                    bHasWorldOrigin = false;
                }
            }
        }
        public void Serialize(NetBitReader reader)
        {
            reader.ReadBits(2); //Unknown

            Id = new NetworkGUID
            {
                Value = reader.ReadIntPacked()
            };

            reader.ReadBits(31); //Unknown
        }
Esempio n. 26
0
        /// <summary>
        /// see https://github.com/EpicGames/UnrealEngine/blob/c10022aa46e208b1593dd537c2607784aac158f1/Engine/Source/Runtime/Engine/Private/Collision/Collision.cpp#L42
        /// </summary>
        /// <param name="reader"></param>
        public void Serialize(NetBitReader reader)
        {
            // pack bitfield with flags
            // Most of the time the vectors are the same values, use that as an optimization
            BlockingHit      = reader.ReadBit();
            StartPenetrating = reader.ReadBit();
            var bImpactPointEqualsLocation = reader.ReadBit();
            var bImpactNormalEqualsNormal  = reader.ReadBit();

            // Often times the indexes are invalid, use that as an optimization
            var bInvalidItem         = reader.ReadBit();
            var bInvalidFaceIndex    = reader.ReadBit();
            var bNoPenetrationDepth  = reader.ReadBit();
            var bInvalidElementIndex = reader.EngineNetworkVersion >= EngineNetworkVersionHistory.HISTORY_ENUM_SERIALIZATION_COMPAT && reader.ReadBit();

            Time = reader.ReadSingle();

            Location = reader.ReadPackedVector(1, 20);
            Normal   = reader.SerializePropertyVectorNormal();

            ImpactPoint = !bImpactPointEqualsLocation?reader.ReadPackedVector(1, 20) : Location;

            ImpactNormal = !bImpactNormalEqualsNormal?reader.SerializePropertyVectorNormal() : Normal;

            TraceStart = reader.ReadPackedVector(1, 20);
            TraceEnd   = reader.ReadPackedVector(1, 20);

            PenetrationDepth = !bNoPenetrationDepth?reader.SerializePropertyFloat() : 0.0f;

            Distance = (ImpactPoint - TraceStart).Size();
            Item     = !bInvalidItem?reader.ReadInt32() : 0;

            PhysMaterial = reader.SerializePropertyObject();

            if (reader.EngineNetworkVersion < EngineNetworkVersionHistory.HISTORY_HITRESULT_INSTANCEHANDLE)
            {
                Actor = reader.SerializePropertyObject();
            }
            else
            {
                Actor = reader.SerializePropertyObject();

                // see https://github.com/EpicGames/UnrealEngine/blob/4564529ed77196caada6971f5de1be829900b9e1/Engine/Source/Runtime/Engine/Private/EngineTypes.cpp#L558
                //Ar << Handle.Actor;
                //Ar << Handle.Manager;
                //Ar << Handle.InstanceIndex;
            }

            Component = reader.SerializePropertyObject();
            BoneName  = reader.SerializePropertyName();
            FaceIndex = !bInvalidFaceIndex?reader.ReadInt32() : 0;

            ElementIndex = !bInvalidElementIndex && reader.EngineNetworkVersion >= EngineNetworkVersionHistory.HISTORY_ENUM_SERIALIZATION_COMPAT ? reader.ReadByte() : new byte();
        }
        public void RepMovementTest(byte[] rawData, int bitCount,
                                    VectorQuantization locationQuantizationLevel  = VectorQuantization.RoundTwoDecimals,
                                    RotatorQuantization rotationQuantizationLevel = RotatorQuantization.ByteComponents,
                                    VectorQuantization velocityQuantizationLevel  = VectorQuantization.RoundWholeNumber)
        {
            var reader = new NetBitReader(rawData, bitCount);

            reader.SerializeRepMovement(locationQuantizationLevel, rotationQuantizationLevel, velocityQuantizationLevel);
            Assert.False(reader.IsError);
            Assert.True(reader.AtEnd());
        }
        public void HitResultTest(byte[] rawData, int bitCount, string boneName)
        {
            var reader    = new NetBitReader(rawData, bitCount);
            var hitResult = new FHitResult();

            hitResult.Serialize(reader);

            Assert.True(reader.AtEnd());
            Assert.False(reader.IsError);
            Assert.Equal(boneName, hitResult.BoneName);
        }
Esempio n. 29
0
        public void RepMovementTest()
        {
            byte[] rawData =
            {
                0x50, 0x76, 0x07, 0x4F, 0xEB, 0xB0, 0x7F, 0x90, 0x01, 0xDD, 0x81, 0x0F,
                0xE2, 0x0E, 0x20
            };
            var reader = new NetBitReader(rawData, 79);

            reader.SerializeRepMovement();
            Assert.True(reader.AtEnd());
        }
Esempio n. 30
0
        public void NetUniqueIdTest3()
        {
            byte[] rawData =
            {
                0x29, 0x08, 0x25, 0x35, 0x43, 0x94, 0x31, 0x47, 0x40, 0x39
            };

            var reader = new NetBitReader(rawData, 80);

            reader.SerializePropertyNetId();
            Assert.True(reader.AtEnd());
        }