Esempio n. 1
0
        public static void Parse(Replay replay, byte[] buffer)
        {
            const int headerSize = 5;

            var attributes = new ReplayAttribute[BitConverter.ToInt32(buffer, headerSize)];

            var initialOffset = 4 + headerSize;

            for (var i = 0; i < attributes.Length; i++)
            {
                var currentOffset = initialOffset + (i * 13);

                var attribute = new ReplayAttribute {
                    Header        = BitConverter.ToInt32(buffer, currentOffset),
                    AttributeType = (ReplayAttributeEventType)BitConverter.ToInt32(buffer, currentOffset + 4),
                    PlayerId      = buffer[currentOffset + 8],
                    Value         = new byte[4]
                };

                Array.Copy(buffer, currentOffset + 9, attribute.Value, 0, 4);

                attributes[i] = attribute;
            }

            ApplyAttributes(replay, attributes.OrderBy(i => i.AttributeType).ToArray());

            /* var stringList = attributes.OrderBy(i => i.AttributeType);
             * Console.WriteLine(stringList.Count()); */
        }
        public static ReplayAttribute Parse(byte[] buffer, int offset)
        {
            var attribute = new ReplayAttribute
            {
                Header        = BitConverter.ToInt32(buffer, offset),
                AttributeType = (Heroes.ReplayParser.ReplayAttributeEvents.ReplayAttributeEventType)BitConverter.ToInt32(buffer, offset + 4),
                PlayerId      = buffer[offset + 8],
                Value         = new byte[4],
            };

            Array.Copy(buffer, offset + 9, attribute.Value, 0, 4);

            return(attribute);
        }
        public static ReplayAttribute Parse(byte[] buffer, int offset)
        {
            var attribute = new ReplayAttribute
            {
                Header = BitConverter.ToInt32(buffer, offset),
                AttributeType = (Heroes.ReplayParser.ReplayAttributeEvents.ReplayAttributeEventType)BitConverter.ToInt32(buffer, offset + 4),
                PlayerId = buffer[offset + 8],
                Value = new byte[4],
            };

            Array.Copy(buffer, offset + 9, attribute.Value, 0, 4);

            return attribute;
        }
        public static void Parse(Replay replay, byte[] buffer)
        {
            var headerSize = 5;

            var numAttributes = BitConverter.ToInt32(buffer, headerSize);

            var attributes = new ReplayAttribute[numAttributes];

            var initialOffset = 4 + headerSize;

            for (int i = 0; i < numAttributes; i++)
                attributes[i] = ReplayAttribute.Parse(buffer, initialOffset + (i*13));

            new ReplayAttributeEvents { Attributes = attributes.OrderBy(i => i.AttributeType).ToArray() }.ApplyAttributes(replay);

            /* var stringList = attributes.OrderBy(i => i.AttributeType);
            Console.WriteLine(stringList.Count()); */
        }
        public static void Parse(Replay replay, byte[] buffer)
        {
            var headerSize = 5;

            var numAttributes = BitConverter.ToInt32(buffer, headerSize);

            var attributes = new ReplayAttribute[numAttributes];

            var initialOffset = 4 + headerSize;

            for (int i = 0; i < numAttributes; i++)
            {
                attributes[i] = ReplayAttribute.Parse(buffer, initialOffset + (i * 13));
            }

            new ReplayAttributeEvents {
                Attributes = attributes.OrderBy(i => i.AttributeType).ToArray()
            }.ApplyAttributes(replay);

            /* var stringList = attributes.OrderBy(i => i.AttributeType);
             * Console.WriteLine(stringList.Count()); */
        }