File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -202,12 +202,13 @@ def write_var_int(self, value: int) -> None:
202202 data : bytes = b""
203203 value &= 0xffffffff
204204 for i in range (0 , 5 ):
205- if (value >> 7 ) != 0 :
206- self .write_unsigned_byte (value | 0x80 )
205+ to_write : int = value & 0x7f
206+ value >>= 7
207+ if value != 0 :
208+ self .write_unsigned_byte (to_write | 0x80 )
207209 else :
208- self .write_unsigned_byte (value & 0x7f )
210+ self .write_unsigned_byte (to_write )
209211 break
210- value >>= 7
211212
212213 def read_signed_var_int (self ) -> int :
213214 raw : int = self .read_var_int ()
@@ -230,12 +231,13 @@ def read_var_long(self) -> int:
230231
231232 def write_var_long (self , value : int ) -> None :
232233 for i in range (0 , 10 ):
233- if (value >> 7 ) != 0 :
234- self .write_unsigned_byte (value | 0x80 )
234+ to_write : int = value & 0x7f
235+ value >>= 7
236+ if value != 0 :
237+ self .write_unsigned_byte (to_write | 0x80 )
235238 else :
236- self .write_unsigned_byte (value & 0x7f )
239+ self .write_unsigned_byte (to_write )
237240 break
238- value >>= 7
239241
240242 def read_signed_var_long (self ) -> int :
241243 raw : int = self .read_var_long ()
You can’t perform that action at this time.
0 commit comments