Ejemplo n.º 1
0
        public static void SerializeDelta(Stream stream, PlayerInventory instance, PlayerInventory previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.invMain != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                ItemContainer.SerializeDelta(memoryStream, instance.invMain, previous.invMain);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.invBelt != null)
            {
                stream.WriteByte(18);
                memoryStream.SetLength((long)0);
                ItemContainer.SerializeDelta(memoryStream, instance.invBelt, previous.invBelt);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            if (instance.invWear != null)
            {
                stream.WriteByte(26);
                memoryStream.SetLength((long)0);
                ItemContainer.SerializeDelta(memoryStream, instance.invWear, previous.invWear);
                uint length1 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length1);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length1);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
        public static void SerializeDelta(Stream stream, PlayerUpdateLoot instance, PlayerUpdateLoot previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.itemID != previous.itemID)
            {
                stream.WriteByte(8);
                ProtocolParser.WriteUInt32(stream, instance.itemID);
            }
            if (instance.entityID != previous.entityID)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.entityID);
            }
            if (instance.containers != null)
            {
                for (int i = 0; i < instance.containers.Count; i++)
                {
                    ItemContainer item = instance.containers[i];
                    stream.WriteByte(26);
                    memoryStream.SetLength((long)0);
                    ItemContainer.SerializeDelta(memoryStream, item, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Ejemplo n.º 3
0
 public virtual void WriteToStreamDelta(Stream stream, ItemContainer previous)
 {
     if (previous == null)
     {
         ItemContainer.Serialize(stream, this);
         return;
     }
     ItemContainer.SerializeDelta(stream, this, previous);
 }
Ejemplo n.º 4
0
        public static void SerializeDelta(Stream stream, Loot instance, Loot previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.contents != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                ItemContainer.SerializeDelta(memoryStream, instance.contents, previous.contents);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
            public static void SerializeDelta(Stream stream, LootableCorpse.Private instance, LootableCorpse.Private previous)
            {
                MemoryStream memoryStream = Pool.Get <MemoryStream>();

                if (instance.container != null)
                {
                    for (int i = 0; i < instance.container.Count; i++)
                    {
                        ItemContainer item = instance.container[i];
                        stream.WriteByte(10);
                        memoryStream.SetLength((long)0);
                        ItemContainer.SerializeDelta(memoryStream, item, item);
                        uint length = (uint)memoryStream.Length;
                        ProtocolParser.WriteUInt32(stream, length);
                        stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                    }
                }
                Pool.FreeMemoryStream(ref memoryStream);
            }
        public static void SerializeDelta(Stream stream, UpdateItemContainer instance, UpdateItemContainer previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.type != previous.type)
            {
                stream.WriteByte(8);
                ProtocolParser.WriteUInt64(stream, (ulong)instance.type);
            }
            if (instance.container != null)
            {
                for (int i = 0; i < instance.container.Count; i++)
                {
                    ItemContainer item = instance.container[i];
                    stream.WriteByte(18);
                    memoryStream.SetLength((long)0);
                    ItemContainer.SerializeDelta(memoryStream, item, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Ejemplo n.º 7
0
        public static void SerializeDelta(Stream stream, ResourceExtractor instance, ResourceExtractor previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.fuelContents != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                ItemContainer.SerializeDelta(memoryStream, instance.fuelContents, previous.fuelContents);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.outputContents != null)
            {
                stream.WriteByte(18);
                memoryStream.SetLength((long)0);
                ItemContainer.SerializeDelta(memoryStream, instance.outputContents, previous.outputContents);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }