Travel <o/
This commit is contained in:
parent
59b30ed591
commit
4acb1adeb4
|
@ -75,8 +75,8 @@ class PlayerClient(BaseClient):
|
||||||
async def on_player_packet(self, packet: bytes):
|
async def on_player_packet(self, packet: bytes):
|
||||||
bitstream = Bitstream(packet)
|
bitstream = Bitstream(packet)
|
||||||
|
|
||||||
has_acks = bitstream.read(0x01)
|
_, has_acks = bitstream.read(0x01)
|
||||||
if has_acks:
|
if has_acks[0]:
|
||||||
logger.debug("Unfinished code hit; has_acks: True")
|
logger.debug("Unfinished code hit; has_acks: True")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -86,28 +86,28 @@ class PlayerClient(BaseClient):
|
||||||
logger.debug("Internal packet were not handled")
|
logger.debug("Internal packet were not handled")
|
||||||
|
|
||||||
async def handle_internal_packet(self, bitstream: Bitstream) -> bool:
|
async def handle_internal_packet(self, bitstream: Bitstream) -> bool:
|
||||||
if (len(bitstream.buffer) * 8) - bitstream.offset < 0x10:
|
if (bitstream.length * 8) - bitstream.offset < 0x10:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
message_number = bitstream.read(0x10)
|
_, message_number = bitstream.read(0x10)
|
||||||
reliability = bitstream.read(0x04)
|
_, reliability = bitstream.read(0x04)
|
||||||
isSplitPacket = bitstream.read(0x01)
|
_, is_split_packet = bitstream.read(0x01)
|
||||||
|
|
||||||
if isSplitPacket:
|
if is_split_packet[0]:
|
||||||
logger.warning("Skipping split packet")
|
logger.warning("Skipping split packet")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Something I dont understand yet
|
# Something I dont understand yet
|
||||||
# TODO: ReadCompressed
|
# TODO: ReadCompressed
|
||||||
bitstream.offset += 1
|
bitstream.offset += 1
|
||||||
unknown = bitstream.read(0x01)
|
_, unknown = bitstream.read(0x01)
|
||||||
bit_length = bitstream.read(0x08)
|
_, bit_length = bitstream.read(0x08)
|
||||||
##
|
##
|
||||||
|
|
||||||
logger.debug("bit_length: %d" % bit_length)
|
logger.debug("bit_length: %d" % bit_length)
|
||||||
logger.debug("bitstream: %s" % bitstream)
|
logger.debug("bitstream: %s" % bitstream)
|
||||||
|
|
||||||
# TODO: ReadAlignedBytes
|
# TODO: ReadAlignedBytes
|
||||||
data = bitstream.read(bit_length)
|
_, data = bitstream.read(bit_length)
|
||||||
|
|
||||||
logger.debug("data: %s" % data)
|
logger.debug("data: %s" % data)
|
|
@ -2,7 +2,7 @@ import ctypes as c
|
||||||
|
|
||||||
from array import array
|
from array import array
|
||||||
|
|
||||||
from typing import *
|
from typing import Tuple
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -13,6 +13,14 @@ class Bitstream:
|
||||||
self._offset = 0
|
self._offset = 0
|
||||||
self._buffer = bytearray(data) # array("B", data)
|
self._buffer = bytearray(data) # array("B", data)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def offset(self) -> int:
|
||||||
|
return self._offset
|
||||||
|
|
||||||
|
@property
|
||||||
|
def length(self) -> int:
|
||||||
|
return len(self._buffer)
|
||||||
|
|
||||||
def _can_access_bits(self, bits_to_access: int) -> bool:
|
def _can_access_bits(self, bits_to_access: int) -> bool:
|
||||||
return self._offset + bits_to_access <= len(self._buffer) << 3
|
return self._offset + bits_to_access <= len(self._buffer) << 3
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from ..shared import glob
|
from ..shared import glob
|
||||||
from ..struct.server import ServerConfig
|
from ..struct.server import ServerConfig
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -55,5 +57,5 @@ class StringCompressor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def decode_string(self, data: bytes) -> (str, int):
|
def decode_string(self, data: bytes) -> Tuple[str, int]:
|
||||||
pass
|
pass
|
Loading…
Reference in New Issue
Block a user