private string AsNetId() { _reader.Reset(); string netId = _reader.SerializePropertyNetId(); if (_reader.IsError || !_reader.AtEnd()) { return(null); } return(netId); }
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); }
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 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); }
public void NetUniqueIdTest(byte[] rawData, int bitCount) { var reader = new NetBitReader(rawData, bitCount); reader.SerializePropertyNetId(); Assert.False(reader.IsError); Assert.True(reader.AtEnd()); }
public void Serialize(NetBitReader reader) { DebugData = reader.ReadBytes(2); if (reader.IsError || !reader.AtEnd()) { } }
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()); }
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()); }
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); }
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); }
// 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 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 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); }
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 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 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); }
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); }
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()); }
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()); }
public void NetUniqueIdTest2() { byte[] rawData = { 0x11, 0x10, 0x37, 0xDF, 0x4A, 0x07, 0x98, 0xC2, 0x40, 0x2E, 0xAA, 0x62, 0x69, 0x47, 0xEC, 0x29, 0x90, 0x3F }; var reader = new NetBitReader(rawData, 144); reader.SerializePropertyNetId(); Assert.True(reader.AtEnd()); }
1463u)] // replay 6.30 public void PlaylistInfoTest1(byte[] rawData, int bitCount, NetworkVersionHistory networkVersion, EngineNetworkVersionHistory engineNetworkVersion, uint id) { var reader = new NetBitReader(rawData, bitCount) { NetworkVersion = networkVersion, EngineNetworkVersion = engineNetworkVersion }; var playlist = new PlaylistInfo(); playlist.Serialize(reader); Assert.Equal(id, playlist.Id); Assert.True(reader.AtEnd()); Assert.False(reader.IsError); }
public void NetUniqueIdTest() { byte[] rawData = { 0x08, 0x31, 0x00, 0x00, 0x00, 0x44, 0x45, 0x53, 0x4B, 0x54, 0x4F, 0x50, 0x2D, 0x32, 0x32, 0x38, 0x4E, 0x47, 0x43, 0x35, 0x2D, 0x42, 0x39, 0x31, 0x33, 0x37, 0x31, 0x30, 0x38, 0x34, 0x46, 0x46, 0x32, 0x46, 0x37, 0x45, 0x35, 0x44, 0x36, 0x38, 0x38, 0x30, 0x31, 0x39, 0x35, 0x30, 0x35, 0x30, 0x39, 0x41, 0x43, 0x31, 0x34, 0x00 }; var reader = new NetBitReader(rawData, 432); reader.SerializePropertyNetId(); Assert.True(reader.AtEnd()); }
public void ReadArrayFieldTest() { var reader = new NetBitReader(new byte[] { 0x0C, 0x02, 0x6F, 0x02, 0x20, 0xD7, 0x08, 0x00, 0x04, 0x6F, 0x02, 0x20, 0xDF, 0x08, 0x00, 0x06, 0x6F, 0x02, 0x20, 0xE7, 0x08, 0x00, 0x08, 0x6F, 0x02, 0x20, 0xEF, 0x08, 0x00, 0x0A, 0x6F, 0x02, 0x20, 0x8F, 0x06, 0x00, 0x0C, 0x6F, 0x02, 0x20, 0xF7, 0x08, 0x00, 0x00 }, 352) { NetworkVersion = NetworkVersionHistory.HISTORY_CHARACTER_MOVEMENT_NOINTERP, EngineNetworkVersion = EngineNetworkVersionHistory.HISTORY_CLASSNETCACHE_FULLNAME }; var export = new NetFieldExport() { Handle = 0, Name = "ArrayField" }; var group = new NetFieldExportGroup() { PathName = "group1", NetFieldExportsLength = 183, NetFieldExports = new NetFieldExport[183], PathNameIndex = 1 }; group.NetFieldExports[182] = export; 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(6, ((NetFieldGroup1)data).ArrayField.Length); }
/// <summary> /// see https://github.com/EpicGames/UnrealEngine/blob/6c20d9831a968ad3cb156442bebb41a883e62152/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayEffectTypes.cpp#L789 /// </summary> /// <param name="reader"></param> public void Serialize(NetBitReader reader) { const byte NUM_LEVEL_BITS = 5; // need to bump this up to support 20 levels for AbilityLevel // const byte MAX_LEVEL = (1 << NUM_LEVEL_BITS) - 1; var RepBits = reader.ReadBitsToInt((int)RepFlag.REP_MAX); // Tag containers serialize empty containers with 1 bit, so no need to serialize this in the RepBits field. AggregatedSourceTags.Serialize(reader); AggregatedTargetTags.Serialize(reader); if ((RepBits & (1 << (int)RepFlag.REP_NormalizedMagnitude)) > 0) { NormalizedMagnitude = reader.ReadSingle(); } if ((RepBits & (1 << (int)RepFlag.REP_RawMagnitude)) > 0) { RawMagnitude = reader.ReadSingle(); } if ((RepBits & (1 << (int)RepFlag.REP_EffectContext)) > 0) { // FGameplayEffectContextHandle if (reader.ReadBit()) { } } if ((RepBits & (1 << (int)RepFlag.REP_Location)) > 0) { Location = reader.SerializePropertyVector10(); } if ((RepBits & (1 << (int)RepFlag.REP_Normal)) > 0) { Normal = reader.SerializePropertyVectorNormal(); } if ((RepBits & (1 << (int)RepFlag.REP_Instigator)) > 0) { Instigator = reader.ReadIntPacked(); } if ((RepBits & (1 << (int)RepFlag.REP_EffectCauser)) > 0) { EffectCauser = reader.ReadIntPacked(); } if ((RepBits & (1 << (int)RepFlag.REP_SourceObject)) > 0) { SourceObject = reader.ReadIntPacked(); } if ((RepBits & (1 << (int)RepFlag.REP_TargetAttachComponent)) > 0) { TargetAttachComponent = reader.ReadIntPacked(); } if ((RepBits & (1 << (int)RepFlag.REP_PhysMaterial)) > 0) { PhysicalMaterial = reader.ReadIntPacked(); } if ((RepBits & (1 << (int)RepFlag.REP_GELevel)) > 0) { GameplayEffectLevel = reader.ReadBitsToInt(NUM_LEVEL_BITS); } if ((RepBits & (1 << (int)RepFlag.REP_AbilityLevel)) > 0) { AbilityLevel = reader.ReadBitsToInt(NUM_LEVEL_BITS); } if (!reader.AtEnd()) { } }