Exemple #1
0
        private void MessageDeltaDescription()
        {
            if (!demo.ConvertNetworkProtocol() || demo.NetworkProtocol > 43)
            {
                parser.MessageDeltaDescription();
                return;
            }

            Int32 messageStartOffset = parser.BitBuffer.CurrentByte;

            parser.BitBuffer.Endian = BitBuffer.EndianType.Big;
            BitWriter bitWriter = new BitWriter();

            // read/write message
            String structureName = parser.BitBuffer.ReadString();

            bitWriter.WriteString(structureName);

            UInt32 nEntries = parser.BitBuffer.ReadUnsignedBits(16);

            bitWriter.WriteUnsignedBits(nEntries, 16);

            HalfLifeDeltaStructure newDeltaStructure = new HalfLifeDeltaStructure(structureName);

            parser.AddDeltaStructure(newDeltaStructure);

            HalfLifeDeltaStructure deltaDescription = parser.GetDeltaStructure("delta_description_t");

            for (UInt16 i = 0; i < nEntries; i++)
            {
                HalfLifeDelta delta = deltaDescription.CreateDelta();
                Byte[]        bitmaskBytes;
                deltaDescription.ReadDelta(parser.BitBuffer, delta, out bitmaskBytes);

                if (demo.Game != null)
                {
                    demo.Game.ConvertDeltaDescriptionCallback(demo.GameVersion, structureName, delta);
                }

                deltaDescription.WriteDelta(bitWriter, delta, bitmaskBytes);
                newDeltaStructure.AddEntry(delta);
            }

            parser.BitBuffer.SkipRemainingBits();
            parser.BitBuffer.Endian = BitBuffer.EndianType.Little;

            // insert new message
            ReWriteMessage(messageStartOffset, bitWriter.Data);
        }