public static ConnectionAddressView Deserialize(Stream bytes)
 {
     return(new ConnectionAddressView
     {
         Ipv4 = Int32Proxy.Deserialize(bytes),
         Port = UInt16Proxy.Deserialize(bytes)
     });
 }
 public static void Serialize(Stream stream, ConnectionAddressView instance)
 {
     using (var bytes = new MemoryStream())
     {
         Int32Proxy.Serialize(bytes, instance.Ipv4);
         UInt16Proxy.Serialize(bytes, instance.Port);
         bytes.WriteTo(stream);
     }
 }
        // Token: 0x06001333 RID: 4915 RVA: 0x00021AA8 File Offset: 0x0001FCA8
        private void AllPlayerPositions(byte[] _bytes)
        {
            using (MemoryStream memoryStream = new MemoryStream(_bytes))
            {
                List <PlayerMovement> allPositions = ListProxy <PlayerMovement> .Deserialize(memoryStream, new ListProxy <PlayerMovement> .Deserializer <PlayerMovement>(PlayerMovementProxy.Deserialize));

                ushort gameframe = UInt16Proxy.Deserialize(memoryStream);
                this.OnAllPlayerPositions(allPositions, gameframe);
            }
        }
Exemple #4
0
        public static PyLongObject Create(DkmProcess process, BigInteger value)
        {
            var allocator = process.GetDataItem <PyObjectAllocator>();

            Debug.Assert(allocator != null);

            var bitsInDigit  = process.Is64Bit() ? 30 : 15;
            var bytesInDigit = process.Is64Bit() ? 4 : 2;

            var  absValue  = BigInteger.Abs(value);
            long numDigits = 0;

            for (var t = absValue; t != 0;)
            {
                ++numDigits;
                t >>= bitsInDigit;
            }

            var result = allocator.Allocate <PyLongObject>(numDigits * bytesInDigit);

            if (value == 0)
            {
                result.ob_size.Write(0);
            }
            else if (value > 0)
            {
                result.ob_size.Write(numDigits);
            }
            else if (value < 0)
            {
                result.ob_size.Write(-numDigits);
            }

            if (bitsInDigit == 15)
            {
                for (var digitPtr = new UInt16Proxy(process, result.ob_digit.Address); absValue != 0; digitPtr = digitPtr.GetAdjacentProxy(1))
                {
                    digitPtr.Write((ushort)(absValue % (1 << bitsInDigit)));
                    absValue >>= bitsInDigit;
                }
            }
            else
            {
                for (var digitPtr = new UInt32Proxy(process, result.ob_digit.Address); absValue != 0; digitPtr = digitPtr.GetAdjacentProxy(1))
                {
                    digitPtr.Write((uint)(absValue % (1 << bitsInDigit)));
                    absValue >>= bitsInDigit;
                }
            }

            return(result);
        }
 // Token: 0x0600133F RID: 4927 RVA: 0x00021E04 File Offset: 0x00020004
 private void PlayerKilled(byte[] _bytes)
 {
     using (MemoryStream memoryStream = new MemoryStream(_bytes))
     {
         int     shooter     = Int32Proxy.Deserialize(memoryStream);
         int     target      = Int32Proxy.Deserialize(memoryStream);
         byte    weaponClass = ByteProxy.Deserialize(memoryStream);
         ushort  damage      = UInt16Proxy.Deserialize(memoryStream);
         byte    bodyPart    = ByteProxy.Deserialize(memoryStream);
         Vector3 direction   = Vector3Proxy.Deserialize(memoryStream);
         this.OnPlayerKilled(shooter, target, weaponClass, damage, bodyPart, direction);
     }
 }
 // Token: 0x060012BE RID: 4798 RVA: 0x000200E8 File Offset: 0x0001E2E8
 public void SendUpdatePing(ushort ping)
 {
     using (MemoryStream memoryStream = new MemoryStream())
     {
         UInt16Proxy.Serialize(memoryStream, ping);
         Dictionary <byte, object> customOpParameters = new Dictionary <byte, object>
         {
             {
                 this.__id,
                 memoryStream.ToArray()
             }
         };
         if (this.sendOperation != null)
         {
             this.sendOperation(13, customOpParameters, true, 0, false);
         }
     }
 }
Exemple #7
0
        public BigInteger ToBigInteger()
        {
            var bitsInDigit = Process.Is64Bit() ? 30 : 15;

            long ob_size = this.ob_size.Read();

            if (ob_size == 0)
            {
                return(0);
            }
            long count = Math.Abs(ob_size);

            // Read and parse digits in reverse, starting from the most significant ones.
            var result = new BigInteger(0);

            if (bitsInDigit == 15)
            {
                var digitPtr = new UInt16Proxy(Process, ob_digit.Address).GetAdjacentProxy(count);
                for (long i = 0; i != count; ++i)
                {
                    digitPtr = digitPtr.GetAdjacentProxy(-1);
                    result <<= bitsInDigit;
                    result  += digitPtr.Read();
                }
            }
            else
            {
                var digitPtr = new UInt32Proxy(Process, ob_digit.Address).GetAdjacentProxy(count);
                for (long i = 0; i != count; ++i)
                {
                    digitPtr = digitPtr.GetAdjacentProxy(-1);
                    result <<= bitsInDigit;
                    result  += digitPtr.Read();
                }
            }

            return(ob_size > 0 ? result : -result);
        }
Exemple #8
0
        public static PyLongObject Create(DkmProcess process, BigInteger value) {
            var allocator = process.GetDataItem<PyObjectAllocator>();
            Debug.Assert(allocator != null);

            var bitsInDigit = process.Is64Bit() ? 30 : 15;
            var bytesInDigit = process.Is64Bit() ? 4 : 2;

            var absValue = BigInteger.Abs(value);
            long numDigits = 0;
            for (var t = absValue; t != 0; ) {
                ++numDigits;
                t >>= bitsInDigit;
            }

            var result = allocator.Allocate<PyLongObject>(numDigits * bytesInDigit);

            if (value == 0) {
                result.ob_size.Write(0);
            } else if (value > 0) {
                result.ob_size.Write(numDigits);
            } else if (value < 0) {
                result.ob_size.Write(-numDigits);
            }

            if (bitsInDigit == 15) {
                for (var digitPtr = new UInt16Proxy(process, result.ob_digit.Address); absValue != 0; digitPtr = digitPtr.GetAdjacentProxy(1)) {
                    digitPtr.Write((ushort)(absValue % (1 << bitsInDigit)));
                    absValue >>= bitsInDigit;
                }
            } else {
                for (var digitPtr = new UInt32Proxy(process, result.ob_digit.Address); absValue != 0; digitPtr = digitPtr.GetAdjacentProxy(1)) {
                    digitPtr.Write((uint)(absValue % (1 << bitsInDigit)));
                    absValue >>= bitsInDigit;
                }
            }

            return result;
        }
Exemple #9
0
        public BigInteger ToBigInteger() {
            var bitsInDigit = Process.Is64Bit() ? 30 : 15;

            long ob_size = this.ob_size.Read();
            if (ob_size == 0) {
                return 0;
            } 
            long count = Math.Abs(ob_size);

            // Read and parse digits in reverse, starting from the most significant ones.
            var result = new BigInteger(0);
            if (bitsInDigit == 15) {
                var digitPtr = new UInt16Proxy(Process, ob_digit.Address).GetAdjacentProxy(count);
                for (long i = 0; i != count; ++i) {
                    digitPtr = digitPtr.GetAdjacentProxy(-1);
                    result <<= bitsInDigit;
                    result += digitPtr.Read();
                }
            } else {
                var digitPtr = new UInt32Proxy(Process, ob_digit.Address).GetAdjacentProxy(count);
                for (long i = 0; i != count; ++i) {
                    digitPtr = digitPtr.GetAdjacentProxy(-1);
                    result <<= bitsInDigit;
                    result += digitPtr.Read();
                }
            }

            return ob_size > 0 ? result : -result;
        }
        public static GameActorInfoDeltaView Deserialize(Stream bytes)
        {
            int  mask = Int32Proxy.Deserialize(bytes);
            byte id   = ByteProxy.Deserialize(bytes);

            var view = new GameActorInfoDeltaView();

            view.Id = id;
            if (mask != 0)
            {
                if ((mask & 1) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.AccessLevel] = EnumProxy <MemberAccessLevel> .Deserialize(bytes);
                }
                if ((mask & 2) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.ArmorPointCapacity] = ByteProxy.Deserialize(bytes);
                }
                if ((mask & 4) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.ArmorPoints] = ByteProxy.Deserialize(bytes);
                }
                if ((mask & 8) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Channel] = EnumProxy <ChannelType> .Deserialize(bytes);
                }
                if ((mask & 16) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.ClanTag] = StringProxy.Deserialize(bytes);
                }
                if ((mask & 32) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Cmid] = Int32Proxy.Deserialize(bytes);
                }
                if ((mask & 64) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.CurrentFiringMode] = EnumProxy <FireMode> .Deserialize(bytes);
                }
                if ((mask & 128) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.CurrentWeaponSlot] = ByteProxy.Deserialize(bytes);
                }
                if ((mask & 256) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Deaths] = Int16Proxy.Deserialize(bytes);
                }
                if ((mask & 512) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.FunctionalItems] = ListProxy <int> .Deserialize(bytes, Int32Proxy.Deserialize);
                }
                if ((mask & 1024) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Gear] = ListProxy <int> .Deserialize(bytes, Int32Proxy.Deserialize);
                }
                if ((mask & 2048) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Health] = Int16Proxy.Deserialize(bytes);
                }
                if ((mask & 4096) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Kills] = Int16Proxy.Deserialize(bytes);
                }
                if ((mask & 8192) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Level] = Int32Proxy.Deserialize(bytes);
                }
                if ((mask & 16384) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Ping] = UInt16Proxy.Deserialize(bytes);
                }
                if ((mask & 32768) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.PlayerId] = ByteProxy.Deserialize(bytes);
                }
                if ((mask & 65536) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.PlayerName] = StringProxy.Deserialize(bytes);
                }
                if ((mask & 131072) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.PlayerState] = EnumProxy <PlayerStates> .Deserialize(bytes);
                }
                if ((mask & 262144) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.QuickItems] = ListProxy <int> .Deserialize(bytes, Int32Proxy.Deserialize);
                }
                if ((mask & 524288) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Rank] = ByteProxy.Deserialize(bytes);
                }
                if ((mask & 1048576) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.SkinColor] = ColorProxy.Deserialize(bytes);
                }
                if ((mask & 2097152) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.StepSound] = EnumProxy <SurfaceType> .Deserialize(bytes);
                }
                if ((mask & 4194304) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.TeamID] = EnumProxy <TeamID> .Deserialize(bytes);
                }
                if ((mask & 8388608) != 0)
                {
                    view.Changes[GameActorInfoDeltaView.Keys.Weapons] = ListProxy <int> .Deserialize(bytes, Int32Proxy.Deserialize);
                }
            }
            return(view);
        }
        public static void Serialize(Stream stream, GameActorInfoDeltaView instance)
        {
            if (instance != null)
            {
                Int32Proxy.Serialize(stream, instance.DeltaMask);
                ByteProxy.Serialize(stream, instance.Id);

                if ((instance.DeltaMask & 1) != 0)
                {
                    EnumProxy <MemberAccessLevel> .Serialize(stream, (MemberAccessLevel)((int)instance.Changes[GameActorInfoDeltaView.Keys.AccessLevel]));
                }
                if ((instance.DeltaMask & 2) != 0)
                {
                    ByteProxy.Serialize(stream, (byte)instance.Changes[GameActorInfoDeltaView.Keys.ArmorPointCapacity]);
                }
                if ((instance.DeltaMask & 4) != 0)
                {
                    ByteProxy.Serialize(stream, (byte)instance.Changes[GameActorInfoDeltaView.Keys.ArmorPoints]);
                }
                if ((instance.DeltaMask & 8) != 0)
                {
                    EnumProxy <ChannelType> .Serialize(stream, (ChannelType)((int)instance.Changes[GameActorInfoDeltaView.Keys.Channel]));
                }
                if ((instance.DeltaMask & 16) != 0)
                {
                    StringProxy.Serialize(stream, (string)instance.Changes[GameActorInfoDeltaView.Keys.ClanTag]);
                }
                if ((instance.DeltaMask & 32) != 0)
                {
                    Int32Proxy.Serialize(stream, (int)instance.Changes[GameActorInfoDeltaView.Keys.Cmid]);
                }
                if ((instance.DeltaMask & 64) != 0)
                {
                    EnumProxy <FireMode> .Serialize(stream, (FireMode)((int)instance.Changes[GameActorInfoDeltaView.Keys.CurrentFiringMode]));
                }
                if ((instance.DeltaMask & 128) != 0)
                {
                    ByteProxy.Serialize(stream, (byte)instance.Changes[GameActorInfoDeltaView.Keys.CurrentWeaponSlot]);
                }
                if ((instance.DeltaMask & 256) != 0)
                {
                    Int16Proxy.Serialize(stream, (short)instance.Changes[GameActorInfoDeltaView.Keys.Deaths]);
                }
                if ((instance.DeltaMask & 512) != 0)
                {
                    ListProxy <int> .Serialize(stream, (List <int>) instance.Changes[GameActorInfoDeltaView.Keys.FunctionalItems], Int32Proxy.Serialize);
                }
                if ((instance.DeltaMask & 1024) != 0)
                {
                    ListProxy <int> .Serialize(stream, (List <int>) instance.Changes[GameActorInfoDeltaView.Keys.Gear], Int32Proxy.Serialize);
                }
                if ((instance.DeltaMask & 2048) != 0)
                {
                    Int16Proxy.Serialize(stream, (short)instance.Changes[GameActorInfoDeltaView.Keys.Health]);
                }
                if ((instance.DeltaMask & 4096) != 0)
                {
                    Int16Proxy.Serialize(stream, (short)instance.Changes[GameActorInfoDeltaView.Keys.Kills]);
                }
                if ((instance.DeltaMask & 8192) != 0)
                {
                    Int32Proxy.Serialize(stream, (int)instance.Changes[GameActorInfoDeltaView.Keys.Level]);
                }
                if ((instance.DeltaMask & 16384) != 0)
                {
                    UInt16Proxy.Serialize(stream, (ushort)instance.Changes[GameActorInfoDeltaView.Keys.Ping]);
                }
                if ((instance.DeltaMask & 32768) != 0)
                {
                    ByteProxy.Serialize(stream, (byte)instance.Changes[GameActorInfoDeltaView.Keys.PlayerId]);
                }
                if ((instance.DeltaMask & 65536) != 0)
                {
                    StringProxy.Serialize(stream, (string)instance.Changes[GameActorInfoDeltaView.Keys.PlayerName]);
                }
                if ((instance.DeltaMask & 131072) != 0)
                {
                    EnumProxy <PlayerStates> .Serialize(stream, (PlayerStates)((byte)instance.Changes[GameActorInfoDeltaView.Keys.PlayerState]));
                }
                if ((instance.DeltaMask & 262144) != 0)
                {
                    ListProxy <int> .Serialize(stream, (List <int>) instance.Changes[GameActorInfoDeltaView.Keys.QuickItems], Int32Proxy.Serialize);
                }
                if ((instance.DeltaMask & 524288) != 0)
                {
                    ByteProxy.Serialize(stream, (byte)instance.Changes[GameActorInfoDeltaView.Keys.Rank]);
                }
                if ((instance.DeltaMask & 1048576) != 0)
                {
                    ColorProxy.Serialize(stream, (Color)instance.Changes[GameActorInfoDeltaView.Keys.SkinColor]);
                }
                if ((instance.DeltaMask & 2097152) != 0)
                {
                    EnumProxy <SurfaceType> .Serialize(stream, (SurfaceType)((int)instance.Changes[GameActorInfoDeltaView.Keys.StepSound]));
                }
                if ((instance.DeltaMask & 4194304) != 0)
                {
                    EnumProxy <TeamID> .Serialize(stream, (TeamID)((int)instance.Changes[GameActorInfoDeltaView.Keys.TeamID]));
                }
                if ((instance.DeltaMask & 8388608) != 0)
                {
                    ListProxy <int> .Serialize(stream, (List <int>) instance.Changes[GameActorInfoDeltaView.Keys.Weapons], Int32Proxy.Serialize);
                }
            }
            else
            {
                Int32Proxy.Serialize(stream, 0);
            }
        }
Exemple #12
0
        public static GameActorInfoView Deserialize(Stream bytes)
        {
            int mask = Int32Proxy.Deserialize(bytes);
            var view = new GameActorInfoView();

            view.AccessLevel = EnumProxy <MemberAccessLevel> .Deserialize(bytes);

            view.ArmorPointCapacity = ByteProxy.Deserialize(bytes);
            view.ArmorPoints        = ByteProxy.Deserialize(bytes);
            view.Channel            = EnumProxy <ChannelType> .Deserialize(bytes);

            if ((mask & 1) != 0)
            {
                view.ClanTag = StringProxy.Deserialize(bytes);
            }

            view.Cmid = Int32Proxy.Deserialize(bytes);
            view.CurrentFiringMode = EnumProxy <FireMode> .Deserialize(bytes);

            view.CurrentWeaponSlot = ByteProxy.Deserialize(bytes);
            view.Deaths            = Int16Proxy.Deserialize(bytes);

            if ((mask & 2) != 0)
            {
                view.FunctionalItems = ListProxy <int> .Deserialize(bytes, new ListProxy <int> .Deserializer <int>(Int32Proxy.Deserialize));
            }
            if ((mask & 4) != 0)
            {
                view.Gear = ListProxy <int> .Deserialize(bytes, new ListProxy <int> .Deserializer <int>(Int32Proxy.Deserialize));
            }

            view.Health   = Int16Proxy.Deserialize(bytes);
            view.Kills    = Int16Proxy.Deserialize(bytes);
            view.Level    = Int32Proxy.Deserialize(bytes);
            view.Ping     = UInt16Proxy.Deserialize(bytes);
            view.PlayerId = ByteProxy.Deserialize(bytes);

            if ((mask & 8) != 0)
            {
                view.PlayerName = StringProxy.Deserialize(bytes);
            }

            view.PlayerState = EnumProxy <PlayerStates> .Deserialize(bytes);

            if ((mask & 16) != 0)
            {
                view.QuickItems = ListProxy <int> .Deserialize(bytes, new ListProxy <int> .Deserializer <int>(Int32Proxy.Deserialize));
            }

            view.Rank      = ByteProxy.Deserialize(bytes);
            view.SkinColor = ColorProxy.Deserialize(bytes);
            view.StepSound = EnumProxy <SurfaceType> .Deserialize(bytes);

            view.TeamID = EnumProxy <TeamID> .Deserialize(bytes);

            if ((mask & 32) != 0)
            {
                view.Weapons = ListProxy <int> .Deserialize(bytes, new ListProxy <int> .Deserializer <int>(Int32Proxy.Deserialize));
            }

            return(view);
        }
Exemple #13
0
        public static void Serialize(Stream stream, GameActorInfoView instance)
        {
            int mask = 0;

            using (var bytes = new MemoryStream())
            {
                EnumProxy <MemberAccessLevel> .Serialize(bytes, instance.AccessLevel);

                ByteProxy.Serialize(bytes, instance.ArmorPointCapacity);
                ByteProxy.Serialize(bytes, instance.ArmorPoints);
                EnumProxy <ChannelType> .Serialize(bytes, instance.Channel);

                if (instance.ClanTag != null)
                {
                    StringProxy.Serialize(bytes, instance.ClanTag);
                }
                else
                {
                    mask |= 1;
                }

                Int32Proxy.Serialize(bytes, instance.Cmid);
                EnumProxy <FireMode> .Serialize(bytes, instance.CurrentFiringMode);

                ByteProxy.Serialize(bytes, instance.CurrentWeaponSlot);
                Int16Proxy.Serialize(bytes, instance.Deaths);

                if (instance.FunctionalItems != null)
                {
                    ListProxy <int> .Serialize(bytes, instance.FunctionalItems, new ListProxy <int> .Serializer <int>(Int32Proxy.Serialize));
                }
                else
                {
                    mask |= 2;
                }
                if (instance.Gear != null)
                {
                    ListProxy <int> .Serialize(bytes, instance.Gear, new ListProxy <int> .Serializer <int>(Int32Proxy.Serialize));
                }
                else
                {
                    mask |= 4;
                }

                Int16Proxy.Serialize(bytes, instance.Health);
                Int16Proxy.Serialize(bytes, instance.Kills);
                Int32Proxy.Serialize(bytes, instance.Level);
                UInt16Proxy.Serialize(bytes, instance.Ping);
                ByteProxy.Serialize(bytes, instance.PlayerId);

                if (instance.PlayerName != null)
                {
                    StringProxy.Serialize(bytes, instance.PlayerName);
                }
                else
                {
                    mask |= 8;
                }

                EnumProxy <PlayerStates> .Serialize(bytes, instance.PlayerState);

                if (instance.QuickItems != null)
                {
                    ListProxy <int> .Serialize(bytes, instance.QuickItems, new ListProxy <int> .Serializer <int>(Int32Proxy.Serialize));
                }
                else
                {
                    mask |= 16;
                }

                ByteProxy.Serialize(bytes, instance.Rank);
                ColorProxy.Serialize(bytes, instance.SkinColor);
                EnumProxy <SurfaceType> .Serialize(bytes, instance.StepSound);

                EnumProxy <TeamID> .Serialize(bytes, instance.TeamID);

                if (instance.Weapons != null)
                {
                    ListProxy <int> .Serialize(bytes, instance.Weapons, new ListProxy <int> .Serializer <int>(Int32Proxy.Serialize));
                }
                else
                {
                    mask |= 32;
                }

                Int32Proxy.Serialize(stream, ~mask);
                bytes.WriteTo(stream);
            }
        }