diff options
author | Joey Sacchini <joey@sacchini.net> | 2020-10-09 18:54:18 -0400 |
---|---|---|
committer | Joey Sacchini <joey@sacchini.net> | 2020-10-09 18:54:18 -0400 |
commit | 10bbcdb2607f25ff9a0702caf7363076af521ec8 (patch) | |
tree | dc23188bfd36228516479b4c27526a250c094f63 /src | |
parent | c07fc2dc3447b1f1a424f460430abd1e0521243a (diff) | |
download | mcproto-rs-10bbcdb2607f25ff9a0702caf7363076af521ec8.tar.gz mcproto-rs-10bbcdb2607f25ff9a0702caf7363076af521ec8.tar.bz2 mcproto-rs-10bbcdb2607f25ff9a0702caf7363076af521ec8.zip |
read/write length prefix for light data arrays
Diffstat (limited to 'src')
-rw-r--r-- | src/v1_15_2.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/v1_15_2.rs b/src/v1_15_2.rs index 1565485..e56bca1 100644 --- a/src/v1_15_2.rs +++ b/src/v1_15_2.rs @@ -2985,7 +2985,14 @@ impl LightingData { fn deserialize(update_mask: VarInt, reset_mask: VarInt, mut data: &[u8]) -> DeserializeResult<Self> { let mut out = Vec::with_capacity(LIGHT_DATA_SECTIONS); for i in 0..LIGHT_DATA_SECTIONS { + // gotta read the var int if update_mask.0 & (1 << i) != 0 { + let Deserialized { value: length, data: rest } = VarInt::mc_deserialize(data)?; + if (length.0 as usize) != LIGHT_DATA_LENGTH { + return Err(DeserializeErr::CannotUnderstandValue(format!("bad data length in light update {}", length))); + } + + data = rest; if data.len() < LIGHT_DATA_LENGTH { return Err(DeserializeErr::Eof); } @@ -3052,6 +3059,7 @@ impl LightingData { fn serialize_data<S: Serializer>(&self, to: &mut S) -> SerializeResult { for item in &self.data { if let Some(contents) = item { + to.serialize_other(&VarInt(2048))?; to.serialize_bytes(&contents[..])?; } } |