mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
use unsigned integers for nbt lengths
probably not an optimization, just makes more sense
This commit is contained in:
parent
c64f10605b
commit
029ae0e567
2 changed files with 7 additions and 7 deletions
|
@ -39,7 +39,7 @@ impl Tag {
|
|||
// A length-prefixed array of signed bytes. The prefix is a signed
|
||||
// integer (thus 4 bytes)
|
||||
7 => {
|
||||
let length = stream.read_i32::<BE>()?;
|
||||
let length = stream.read_u32::<BE>()?;
|
||||
let mut bytes = vec![0; length as usize];
|
||||
stream.read_exact(&mut bytes)?;
|
||||
Tag::ByteArray(bytes)
|
||||
|
@ -84,7 +84,7 @@ impl Tag {
|
|||
// signed integer (thus 4 bytes) and indicates the number of 4 byte
|
||||
// integers.
|
||||
11 => {
|
||||
let length = stream.read_i32::<BE>()?;
|
||||
let length = stream.read_u32::<BE>()?;
|
||||
let mut ints = Vec::with_capacity(length as usize);
|
||||
for _ in 0..length {
|
||||
ints.push(stream.read_i32::<BE>()?);
|
||||
|
@ -94,7 +94,7 @@ impl Tag {
|
|||
// A length-prefixed array of signed longs. The prefix is a signed
|
||||
// integer (thus 4 bytes) and indicates the number of 8 byte longs.
|
||||
12 => {
|
||||
let length = stream.read_i32::<BE>()?;
|
||||
let length = stream.read_u32::<BE>()?;
|
||||
let mut longs = Vec::with_capacity(length as usize);
|
||||
for _ in 0..length {
|
||||
longs.push(stream.read_i64::<BE>()?);
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::io::Write;
|
|||
|
||||
#[inline]
|
||||
fn write_string(writer: &mut dyn Write, string: &str) -> Result<(), Error> {
|
||||
writer.write_i16::<BE>(string.len() as i16)?;
|
||||
writer.write_u16::<BE>(string.len() as u16)?;
|
||||
writer.write_all(string.as_bytes())?;
|
||||
|
||||
Ok(())
|
||||
|
@ -142,14 +142,14 @@ fn write_list(writer: &mut dyn Write, value: &[Tag]) -> Result<(), Error> {
|
|||
|
||||
#[inline]
|
||||
fn write_bytearray(writer: &mut dyn Write, value: &Vec<u8>) -> Result<(), Error> {
|
||||
writer.write_i32::<BE>(value.len() as i32)?;
|
||||
writer.write_u32::<BE>(value.len() as u32)?;
|
||||
writer.write_all(value)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_intarray(writer: &mut dyn Write, value: &Vec<i32>) -> Result<(), Error> {
|
||||
writer.write_i32::<BE>(value.len() as i32)?;
|
||||
writer.write_u32::<BE>(value.len() as u32)?;
|
||||
for &int in value {
|
||||
writer.write_i32::<BE>(int)?;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ fn write_intarray(writer: &mut dyn Write, value: &Vec<i32>) -> Result<(), Error>
|
|||
|
||||
#[inline]
|
||||
fn write_longarray(writer: &mut dyn Write, value: &Vec<i64>) -> Result<(), Error> {
|
||||
writer.write_i32::<BE>(value.len() as i32)?;
|
||||
writer.write_u32::<BE>(value.len() as u32)?;
|
||||
for &long in value {
|
||||
writer.write_i64::<BE>(long)?;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue