public static PlayerLifeStory DeserializeLengthDelimited(Stream stream)
        {
            PlayerLifeStory playerLifeStory = Pool.Get <PlayerLifeStory>();

            PlayerLifeStory.DeserializeLengthDelimited(stream, playerLifeStory, false);
            return(playerLifeStory);
        }
        public static RespawnInformation DeserializeLengthDelimited(Stream stream, RespawnInformation instance, bool isDelta)
        {
            if (!isDelta && instance.spawnOptions == null)
            {
                instance.spawnOptions = Pool.Get <List <RespawnInformation.SpawnOptions> >();
            }
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            while (stream.Position < position)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    throw new EndOfStreamException();
                }
                if (num == 10)
                {
                    instance.spawnOptions.Add(RespawnInformation.SpawnOptions.DeserializeLengthDelimited(stream));
                }
                else if (num != 18)
                {
                    if (num == 24)
                    {
                        instance.fadeIn = ProtocolParser.ReadBool(stream);
                    }
                    else
                    {
                        Key key = ProtocolParser.ReadKey((byte)num, stream);
                        if (key.Field == 0)
                        {
                            throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                        }
                        ProtocolParser.SkipKey(stream, key);
                    }
                }
                else if (instance.previousLife != null)
                {
                    PlayerLifeStory.DeserializeLengthDelimited(stream, instance.previousLife, isDelta);
                }
                else
                {
                    instance.previousLife = PlayerLifeStory.DeserializeLengthDelimited(stream);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
Exemplo n.º 3
0
        public static BasePlayer DeserializeLengthDelimited(Stream stream, BasePlayer instance, bool isDelta)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            while (stream.Position < position)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    throw new EndOfStreamException();
                }
                if (num <= 50)
                {
                    if (num <= 16)
                    {
                        if (num == 10)
                        {
                            instance.name = ProtocolParser.ReadString(stream);
                            continue;
                        }
                        else if (num == 16)
                        {
                            instance.userid = ProtocolParser.ReadUInt64(stream);
                            continue;
                        }
                    }
                    else if (num == 26)
                    {
                        if (instance.inventory != null)
                        {
                            PlayerInventory.DeserializeLengthDelimited(stream, instance.inventory, isDelta);
                            continue;
                        }
                        else
                        {
                            instance.inventory = PlayerInventory.DeserializeLengthDelimited(stream);
                            continue;
                        }
                    }
                    else if (num != 34)
                    {
                        if (num == 50)
                        {
                            if (instance.modelState != null)
                            {
                                ModelState.DeserializeLengthDelimited(stream, instance.modelState, isDelta);
                                continue;
                            }
                            else
                            {
                                instance.modelState = ModelState.DeserializeLengthDelimited(stream);
                                continue;
                            }
                        }
                    }
                    else if (instance.metabolism != null)
                    {
                        PlayerMetabolism.DeserializeLengthDelimited(stream, instance.metabolism, isDelta);
                        continue;
                    }
                    else
                    {
                        instance.metabolism = PlayerMetabolism.DeserializeLengthDelimited(stream);
                        continue;
                    }
                }
                else if (num <= 64)
                {
                    if (num == 56)
                    {
                        instance.playerFlags = (int)ProtocolParser.ReadUInt64(stream);
                        continue;
                    }
                    else if (num == 64)
                    {
                        instance.heldEntity = ProtocolParser.ReadUInt32(stream);
                        continue;
                    }
                }
                else if (num == 77)
                {
                    instance.health = ProtocolParser.ReadSingle(stream);
                    continue;
                }
                else if (num != 82)
                {
                    if (num == 125)
                    {
                        instance.skinCol = ProtocolParser.ReadSingle(stream);
                        continue;
                    }
                }
                else if (instance.persistantData != null)
                {
                    PersistantPlayer.DeserializeLengthDelimited(stream, instance.persistantData, isDelta);
                    continue;
                }
                else
                {
                    instance.persistantData = PersistantPlayer.DeserializeLengthDelimited(stream);
                    continue;
                }
                Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                uint field = key.Field;
                if (field == 0)
                {
                    throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                }
                switch (field)
                {
                case 16:
                {
                    if (key.WireType != Wire.Fixed32)
                    {
                        continue;
                    }
                    instance.skinTex = ProtocolParser.ReadSingle(stream);
                    continue;
                }

                case 17:
                {
                    if (key.WireType != Wire.Fixed32)
                    {
                        continue;
                    }
                    instance.skinMesh = ProtocolParser.ReadSingle(stream);
                    continue;
                }

                case 18:
                case 19:
                {
                    ProtocolParser.SkipKey(stream, key);
                    continue;
                }

                case 20:
                {
                    if (key.WireType != Wire.LengthDelimited)
                    {
                        continue;
                    }
                    if (instance.currentLife != null)
                    {
                        PlayerLifeStory.DeserializeLengthDelimited(stream, instance.currentLife, isDelta);
                        continue;
                    }
                    else
                    {
                        instance.currentLife = PlayerLifeStory.DeserializeLengthDelimited(stream);
                        continue;
                    }
                }

                case 21:
                {
                    if (key.WireType != Wire.LengthDelimited)
                    {
                        continue;
                    }
                    if (instance.previousLife != null)
                    {
                        PlayerLifeStory.DeserializeLengthDelimited(stream, instance.previousLife, isDelta);
                        continue;
                    }
                    else
                    {
                        instance.previousLife = PlayerLifeStory.DeserializeLengthDelimited(stream);
                        continue;
                    }
                }

                case 22:
                {
                    if (key.WireType != Wire.Varint)
                    {
                        continue;
                    }
                    instance.mounted = ProtocolParser.ReadUInt32(stream);
                    continue;
                }

                case 23:
                {
                    if (key.WireType != Wire.Varint)
                    {
                        continue;
                    }
                    instance.currentTeam = ProtocolParser.ReadUInt64(stream);
                    continue;
                }

                default:
                {
                    goto case 19;
                }
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }