fix: double implementation for position type
This commit is contained in:
parent
152dda2f2c
commit
9928ea7a46
1 changed files with 23 additions and 11 deletions
|
@ -216,20 +216,32 @@ class PositionType(Type):
|
||||||
pytype : type = tuple
|
pytype : type = tuple
|
||||||
MAX_SIZE : int = 8
|
MAX_SIZE : int = 8
|
||||||
|
|
||||||
# TODO THIS IS FOR 1.12.2!!! Make a generic version-less?
|
|
||||||
|
|
||||||
def write(self, data:tuple, buffer:io.BytesIO, ctx:Context):
|
def write(self, data:tuple, buffer:io.BytesIO, ctx:Context):
|
||||||
packed = ((0x3FFFFFF & data[0]) << 38) \
|
if ctx._proto <= 441:
|
||||||
| ((0xFFF & data[1]) << 26) \
|
packed = ((0x3FFFFFF & data[0]) << 38) \
|
||||||
| (0x3FFFFFF & data[2])
|
| ((0xFFF & data[1]) << 26) \
|
||||||
UnsignedLong.write(packed, buffer, ctx=ctx)
|
| (0x3FFFFFF & data[2])
|
||||||
|
UnsignedLong.write(packed, buffer, ctx=ctx)
|
||||||
|
else:
|
||||||
|
packed = ((0x3FFFFFF & data[0]) << 38) \
|
||||||
|
| ((0xFFF & data[2]) << 12) \
|
||||||
|
| (0x3FFFFFF & data[1])
|
||||||
|
UnsignedLong.write(packed, buffer, ctx=ctx)
|
||||||
|
pass
|
||||||
|
|
||||||
def read(self, buffer:io.BytesIO, ctx:Context) -> tuple:
|
def read(self, buffer:io.BytesIO, ctx:Context) -> tuple:
|
||||||
packed = UnsignedLong.read(buffer, ctx)
|
if ctx._proto <= 441:
|
||||||
x = twos_comp(packed >> 38, 26)
|
packed = UnsignedLong.read(buffer, ctx)
|
||||||
y = (packed >> 26) & 0xFFF
|
x = twos_comp(packed >> 38, 26)
|
||||||
z = twos_comp(packed & 0x3FFFFFF, 26)
|
y = (packed >> 26) & 0xFFF
|
||||||
return (x, y, z)
|
z = twos_comp(packed & 0x3FFFFFF, 26)
|
||||||
|
return (x, y, z)
|
||||||
|
else:
|
||||||
|
packed = UnsignedLong.read(buffer, ctx)
|
||||||
|
x = twos_comp(packed >> 38, 26)
|
||||||
|
z = twos_comp((packed >> 12) & 0x3FFFFFF, 26)
|
||||||
|
y = packed & 0xFFF
|
||||||
|
return (x, y, z)
|
||||||
|
|
||||||
Position = PositionType()
|
Position = PositionType()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue