internal override bool ReadTag(NbtBinaryReader readStream) { if (readStream.Selector != null && !readStream.Selector(this)) { readStream.ReadInt32(); return false; } Value = readStream.ReadInt32(); return true; }
internal override bool ReadTag(NbtBinaryReader readStream) { if (readStream.Selector != null && !readStream.Selector(this)) { readStream.ReadInt32(); return(false); } Value = readStream.ReadInt32(); return(true); }
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(); } }
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."); } }
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)); }
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); }
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(); } }
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); }
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); } }
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."); } }
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); }
internal override void SkipTag(NbtBinaryReader readStream) { readStream.ReadInt32(); }
internal override void ReadTag(NbtBinaryReader readStream) { Value = readStream.ReadInt32(); }
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)); }
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; }
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; } }
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; }