mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 15:23:48 +01:00
Fix binary.write_int
This commit is contained in:
parent
9d221a890d
commit
c823ca9533
@ -84,12 +84,12 @@ function write_uint(write_byte, uint, bytes)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function write_int(write_byte, int, bytes)
|
function write_int(write_byte, int, bytes)
|
||||||
local max = 0x100 ^ bytes / 2
|
local max = 0x100 ^ bytes
|
||||||
if int < 0 then
|
if int < 0 then
|
||||||
-- No bound checking is needed: If the int is too small, the uint will be too big
|
assert(-int <= max / 2)
|
||||||
int = max - int
|
int = max + int
|
||||||
else
|
else
|
||||||
assert(int < max)
|
assert(int < max / 2)
|
||||||
end
|
end
|
||||||
return write_uint(write_byte, int, bytes)
|
return write_uint(write_byte, int, bytes)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user