ReadInt32() public method

public ReadInt32 ( ) : int
return int
Beispiel #1
0
 internal override bool ReadTag(NbtBinaryReader readStream)
 {
     if (readStream.Selector != null && !readStream.Selector(this)) {
         readStream.ReadInt32();
         return false;
     }
     Value = readStream.ReadInt32();
     return true;
 }
Beispiel #2
0
 internal override bool ReadTag(NbtBinaryReader readStream)
 {
     if (readStream.Selector != null && !readStream.Selector(this))
     {
         readStream.ReadInt32();
         return(false);
     }
     Value = readStream.ReadInt32();
     return(true);
 }
Beispiel #3
0
        internal override void ReadTag(NbtBinaryReader readStream)
        {
            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative length given in TAG_Int_Array");
            }

            Value = new int[length];
            for (int i = 0; i < length; i++)
            {
                Value[i] = readStream.ReadInt32();
            }
        }
Beispiel #4
0
        void ReadTagHeader(bool readName)
        {
            // Setting state to error in case reader throws
            NbtParseState oldState = state;

            state = NbtParseState.Error;
            TagsRead++;
            TagName = (readName ? reader.ReadString() : null);

            valueCache = null;
            TagLength  = 0;
            atValue    = false;
            ListType   = NbtTagType.Unknown;

            switch (TagType)
            {
            case NbtTagType.Byte:
            case NbtTagType.Short:
            case NbtTagType.Int:
            case NbtTagType.Long:
            case NbtTagType.Float:
            case NbtTagType.Double:
            case NbtTagType.String:
                atValue = true;
                state   = oldState;
                break;

            case NbtTagType.IntArray:
            case NbtTagType.ByteArray:
            case NbtTagType.LongArray:
                TagLength = reader.ReadInt32();
                if (TagLength < 0)
                {
                    throw new NbtFormatException("Negative array length given: " + TagLength);
                }
                atValue = true;
                state   = oldState;
                break;

            case NbtTagType.List:
                ListType  = reader.ReadTagType();
                TagLength = reader.ReadInt32();
                if (TagLength < 0)
                {
                    throw new NbtFormatException("Negative tag length given: " + TagLength);
                }
                state = NbtParseState.AtListBeginning;
                break;

            case NbtTagType.Compound:
                state = NbtParseState.AtCompoundBeginning;
                break;

            default:
                // This should not happen unless NbtBinaryReader is bugged
                throw new NbtFormatException("Trying to read tag of unknown type.");
            }
        }
Beispiel #5
0
        internal override void SkipTag(NbtBinaryReader readStream)
        {
            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative length given in TAG_Int_Array");
            }
            readStream.Skip(length * sizeof(int));
        }
Beispiel #6
0
        internal override bool ReadTag(NbtBinaryReader readStream)
        {
            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative length given in TAG_Int_Array");
            }

            if (readStream.Selector != null && !readStream.Selector(this))
            {
                readStream.Skip(length * sizeof(int));
                return(false);
            }

            Value = new int[length];
            for (int i = 0; i < length; i++)
            {
                Value[i] = readStream.ReadInt32();
            }
            return(true);
        }
Beispiel #7
0
        internal override void ReadTag(NbtBinaryReader readStream)
        {
            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative length given in TAG_Byte_Array");
            }

            Value = readStream.ReadBytes(length);
            if (Value.Length < length)
            {
                throw new EndOfStreamException();
            }
        }
Beispiel #8
0
        internal override bool ReadTag(NbtBinaryReader readStream)
        {
            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative length given in TAG_Byte_Array");
            }

            if (readStream.Selector != null && !readStream.Selector(this))
            {
                readStream.Skip(length);
                return(false);
            }
            Value = readStream.ReadBytes(length);
            return(true);
        }
Beispiel #9
0
        internal override void ReadTag(NbtBinaryReader readStream)
        {
            ListType = readStream.ReadTagType();

            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative list size given.");
            }

            for (int i = 0; i < length; i++)
            {
                NbtTag newTag = NbtTag.Construct(ListType);
                newTag.ReadTag(readStream);
                Tags.Add(newTag);
            }
        }
Beispiel #10
0
        void ReadTagHeader(bool readName)
        {
            TagsRead++;
            TagName = (readName ? reader.ReadString() : null);

            valueCache = null;
            TagLength  = 0;
            atValue    = false;
            ListType   = NbtTagType.Unknown;

            switch (TagType)
            {
            case NbtTagType.Byte:
            case NbtTagType.Short:
            case NbtTagType.Int:
            case NbtTagType.Long:
            case NbtTagType.Float:
            case NbtTagType.Double:
            case NbtTagType.String:
                atValue = true;
                break;

            case NbtTagType.IntArray:
            case NbtTagType.ByteArray:
                TagLength = reader.ReadInt32();
                atValue   = true;
                break;

            case NbtTagType.List:
                ListType  = reader.ReadTagType();
                TagLength = reader.ReadInt32();
                state     = NbtParseState.AtListBeginning;
                break;

            case NbtTagType.Compound:
                state = NbtParseState.AtCompoundBeginning;
                break;

            default:
                throw new NbtFormatException("Trying to read tag of unknown type.");
            }
        }
Beispiel #11
0
        internal override bool ReadTag(NbtBinaryReader readStream)
        {
            if (readStream.Selector != null && !readStream.Selector(this))
            {
                SkipTag(readStream);
                return(false);
            }

            ListType = readStream.ReadTagType();

            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative list size given.");
            }

            for (int i = 0; i < length; i++)
            {
                NbtTag newTag;
                switch (ListType)
                {
                case NbtTagType.Byte:
                    newTag = new NbtByte();
                    break;

                case NbtTagType.Short:
                    newTag = new NbtShort();
                    break;

                case NbtTagType.Int:
                    newTag = new NbtInt();
                    break;

                case NbtTagType.Long:
                    newTag = new NbtLong();
                    break;

                case NbtTagType.Float:
                    newTag = new NbtFloat();
                    break;

                case NbtTagType.Double:
                    newTag = new NbtDouble();
                    break;

                case NbtTagType.ByteArray:
                    newTag = new NbtByteArray();
                    break;

                case NbtTagType.String:
                    newTag = new NbtString();
                    break;

                case NbtTagType.List:
                    newTag = new NbtList();
                    break;

                case NbtTagType.Compound:
                    newTag = new NbtCompound();
                    break;

                case NbtTagType.IntArray:
                    newTag = new NbtIntArray();
                    break;

                default:
                    // should never happen, since ListType is checked beforehand
                    throw new NbtFormatException("Unsupported tag type found in a list: " + ListType);
                }
                newTag.Parent = this;
                if (newTag.ReadTag(readStream))
                {
                    tags.Add(newTag);
                }
            }
            return(true);
        }
Beispiel #12
0
 internal override void SkipTag(NbtBinaryReader readStream)
 {
     readStream.ReadInt32();
 }
Beispiel #13
0
 internal override void ReadTag(NbtBinaryReader readStream)
 {
     Value = readStream.ReadInt32();
 }
Beispiel #14
0
 internal override void SkipTag(NbtBinaryReader readStream)
 {
     readStream.ReadInt32();
 }
Beispiel #15
0
 internal override void SkipTag(NbtBinaryReader readStream)
 {
     int length = readStream.ReadInt32();
     if (length < 0) {
         throw new NbtFormatException("Negative length given in TAG_Int_Array");
     }
     readStream.Skip(length*sizeof(int));
 }
Beispiel #16
0
        internal override bool ReadTag(NbtBinaryReader readStream)
        {
            int length = readStream.ReadInt32();
            if (length < 0) {
                throw new NbtFormatException("Negative length given in TAG_Int_Array");
            }

            if (readStream.Selector != null && !readStream.Selector(this)) {
                readStream.Skip(length*sizeof(int));
                return false;
            }

            Value = new int[length];
            for (int i = 0; i < length; i++) {
                Value[i] = readStream.ReadInt32();
            }
            return true;
        }
Beispiel #17
0
        internal override void SkipTag(NbtBinaryReader readStream)
        {
            // read list type, and make sure it's defined
            ListType = readStream.ReadTagType();

            int length = readStream.ReadInt32();

            if (length < 0)
            {
                throw new NbtFormatException("Negative list size given.");
            }

            switch (ListType)
            {
            case NbtTagType.Byte:
                readStream.Skip(length);
                break;

            case NbtTagType.Short:
                readStream.Skip(length * sizeof(short));
                break;

            case NbtTagType.Int:
                readStream.Skip(length * sizeof(int));
                break;

            case NbtTagType.Long:
                readStream.Skip(length * sizeof(long));
                break;

            case NbtTagType.Float:
                readStream.Skip(length * sizeof(float));
                break;

            case NbtTagType.Double:
                readStream.Skip(length * sizeof(double));
                break;

            default:
                for (int i = 0; i < length; i++)
                {
                    switch (listType)
                    {
                    case NbtTagType.ByteArray:
                        new NbtByteArray().SkipTag(readStream);
                        break;

                    case NbtTagType.String:
                        readStream.SkipString();
                        break;

                    case NbtTagType.List:
                        new NbtList().SkipTag(readStream);
                        break;

                    case NbtTagType.Compound:
                        new NbtCompound().SkipTag(readStream);
                        break;

                    case NbtTagType.IntArray:
                        new NbtIntArray().SkipTag(readStream);
                        break;
                    }
                }
                break;
            }
        }
Beispiel #18
0
        internal override bool ReadTag( NbtBinaryReader readStream )
        {
            int length = readStream.ReadInt32();
            if( length < 0 ) {
                throw new NbtFormatException( "Negative length given in TAG_Byte_Array" );
            }

            if( readStream.Selector != null && !readStream.Selector( this ) ) {
                readStream.Skip( length );
                return false;
            }
            Value = readStream.ReadBytes( length );
            return true;
        }