forked from Hay1tsme/artemis
sao: fix erronius length errors
This commit is contained in:
parent
44755d4d0f
commit
a299ba98ac
@ -19,9 +19,7 @@ class SaoRequestHeader:
|
||||
class SaoBaseRequest:
|
||||
def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
|
||||
self.header = header
|
||||
if self.header.data_len != len(data):
|
||||
logging.getLogger('sao').error(f"Expected {self.header.data_len} data bytes byt got {len(data)}!")
|
||||
# TODO: Raise an error here
|
||||
# TODO: Length check
|
||||
|
||||
class SaoResponseHeader:
|
||||
def __init__(self, cmd_id: int) -> None:
|
||||
@ -2047,14 +2045,9 @@ class SaoSynthesizeEnhancementHeroLogRequest(SaoBaseRequest):
|
||||
|
||||
self.material_common_reward_user_data_list: List[MaterialCommonRewardUserData]
|
||||
|
||||
if len(data) <= off:
|
||||
self.material_common_reward_user_data_count = 0
|
||||
return
|
||||
|
||||
self.material_common_reward_user_data_count = decode_int(data, off)
|
||||
off += INT_OFF
|
||||
|
||||
|
||||
for _ in range(self.material_common_reward_user_data_count):
|
||||
mat = MaterialCommonRewardUserData(data, off)
|
||||
off += mat.get_size()
|
||||
|
@ -40,6 +40,21 @@ def decode_str(data: bytes, offset: int) -> Tuple[str, int]:
|
||||
logging.getLogger('sao').error(f"Failed to parse {data[offset:]} as string!")
|
||||
return ("", 0)
|
||||
|
||||
def encode_byte(data: int) -> bytes:
|
||||
return struct.pack("!B", data)
|
||||
|
||||
def encode_short(data: int) -> bytes:
|
||||
return struct.pack("!H", data)
|
||||
|
||||
def encode_int(data: int) -> bytes:
|
||||
return struct.pack("!I", data)
|
||||
|
||||
def encode_long(data: int) -> bytes:
|
||||
return struct.pack("!L", data)
|
||||
|
||||
def encode_bigint(data: int) -> bytes:
|
||||
return struct.pack("!Q", data)
|
||||
|
||||
def encode_str(s: str) -> bytes:
|
||||
try:
|
||||
str_bytes = s.encode("utf-16-le", errors="replace")
|
||||
|
Loading…
Reference in New Issue
Block a user