version and write_varint fixed

This commit is contained in:
MeexReay 2024-11-14 13:49:38 +03:00
parent abe738aad5
commit 40145cb553

View File

@ -51,17 +51,16 @@ macro_rules! write_varint {
let mut value: $type = $value; let mut value: $type = $value;
if value == 0 { if value == 0 {
DataBufferWriter::write_byte($self, 0).or(Err(ProtocolError::VarIntError)) DataBufferWriter::write_byte($self, 0)
} else { } else {
while value >= 0b10000000 { while value >= 0b10000000 {
let next: u8 = ((value & 0b01111111) as u8) | 0b10000000; let next: u8 = ((value & 0b01111111) as u8) | 0b10000000;
value >>= 7; value >>= 7;
DataBufferWriter::write_byte($self, next).or(Err(ProtocolError::VarIntError))?; DataBufferWriter::write_byte($self, next)?;
} }
DataBufferWriter::write_byte($self, (value & 0b01111111) as u8) DataBufferWriter::write_byte($self, (value & 0b01111111) as u8)
.or(Err(ProtocolError::VarIntError))
} }
}}; }};
} }