Skip to content

Commit b372ab0

Browse files
authored
BitStream Boolean Type Fix
1 parent e759653 commit b372ab0

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

lua/bstream.lua

+1-12
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ bstream_class.read_ptr = 1
1111
function bstream_class:write(v_type, v)
1212
if type(v_type) ~= 'string' then return false end
1313

14-
if v_type == BS_BOOLEAN then
15-
v_type = BS_UINT8
16-
v = v and 1 or 0
17-
end
18-
1914
local before = self.bytes:sub(1, self.write_ptr - 1)
2015
local after = self.bytes:sub(self.write_ptr, #self.bytes)
2116

@@ -29,18 +24,12 @@ end
2924
function bstream_class:read(v_type, v_len)
3025
if type(v_type) ~= 'string' then return false end
3126

32-
local was_bool = false
33-
if v_type == BS_BOOLEAN then
34-
v_type = BS_UINT8
35-
was_bool = true
36-
end
37-
3827
local result = 0
3928
if v_type == BS_STRING then result = self.bytes:sub(self.read_ptr, self.read_ptr + v_len - 1)
4029
else result = bcoder.decode(v_type, self.bytes:sub(self.read_ptr, self.read_ptr + ffi.sizeof(v_type) - 1)) end
4130

4231
self.read_ptr = self.read_ptr + (v_type == BS_STRING and v_len or ffi.sizeof(v_type))
43-
return was_bool and (result == 1) or result
32+
return result
4433
end
4534

4635
function bstream.new(bytes)

0 commit comments

Comments
 (0)