From 9026c25fcc7d18dcc6d29ef0eeee35de0ddcbe0f Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 12 Nov 2023 17:35:06 -0500 Subject: [PATCH] sao: fix both unanalyzed log fixed requests --- titles/sao/base.py | 30 ++++-------------------------- titles/sao/handlers/base.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/titles/sao/base.py b/titles/sao/base.py index a73cb25..b7d814e 100644 --- a/titles/sao/base.py +++ b/titles/sao/base.py @@ -874,40 +874,18 @@ class SaoBase: def handle_c90a(self, header: SaoRequestHeader, request: bytes) -> bytes: #quest/episode_play_end_unanalyzed_log_fixed - req = bytes.fromhex(request)[24:] + req = SaoEpisodePlayEndUnanalyzedLogFixedRequest(header, request) - req_struct = Struct( - Padding(16), - "ticket_id_size" / Rebuild(Int32ub, len_(this.ticket_id) * 2), # calculates the length of the ticket_id - "ticket_id" / PaddedString(this.ticket_id_size, "utf_16_le"), # ticket_id is a (zero) padded string - "user_id_size" / Rebuild(Int32ub, len_(this.user_id) * 2), # calculates the length of the user_id - "user_id" / PaddedString(this.user_id_size, "utf_16_le"), # user_id is a (zero) padded string - ) - - req_data = req_struct.parse(req) - user_id = req_data.user_id - - end_session_data = self.game_data.item.get_end_session(user_id) + end_session_data = self.game_data.item.get_end_session(req.user_id) resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(header.cmd +1, end_session_data[4]) return resp.make() def handle_c91a(self, header: SaoRequestHeader, request: bytes) -> bytes: # handler is identical to the episode #quest/trial_tower_play_end_unanalyzed_log_fixed - req = bytes.fromhex(request)[24:] + req = TrialTowerPlayEndUnanalyzedLogFixed(header, request) - req_struct = Struct( - Padding(16), - "ticket_id_size" / Rebuild(Int32ub, len_(this.ticket_id) * 2), # calculates the length of the ticket_id - "ticket_id" / PaddedString(this.ticket_id_size, "utf_16_le"), # ticket_id is a (zero) padded string - "user_id_size" / Rebuild(Int32ub, len_(this.user_id) * 2), # calculates the length of the user_id - "user_id" / PaddedString(this.user_id_size, "utf_16_le"), # user_id is a (zero) padded string - ) - - req_data = req_struct.parse(req) - user_id = req_data.user_id - - end_session_data = self.game_data.item.get_end_session(user_id) + end_session_data = self.game_data.item.get_end_session(req.user_id) resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(header.cmd +1, end_session_data[4]) return resp.make() diff --git a/titles/sao/handlers/base.py b/titles/sao/handlers/base.py index db6e98f..836372b 100644 --- a/titles/sao/handlers/base.py +++ b/titles/sao/handlers/base.py @@ -1798,6 +1798,20 @@ class SaoTrialTowerPlayEndResponse(SaoBaseResponse): class SaoEpisodePlayEndUnanalyzedLogFixedRequest(SaoBaseRequest): def __init__(self, header: SaoRequestHeader, data: bytes) -> None: super().__init__(header, data) + off = 0 + ticket_id = decode_str(data, off) + self.ticket_id = ticket_id[0] + off += ticket_id[1] + + user_id = decode_str(data, off) + self.user_id = user_id[0] + off += user_id[1] + + self.episode_id = decode_int(data, off) + off += INT_OFF + + self.rarity_up_exec_flag = decode_byte(data, off) + off += BYTE_OFF class SaoEpisodePlayEndUnanalyzedLogFixedResponse(SaoBaseResponse): def __init__(self, cmd, end_session_data) -> None: @@ -2989,3 +3003,21 @@ class SaoChangePartyRequest(SaoBaseRequest): tmp = PartyData(data, off) self.party_data_list.append(tmp) off += tmp.get_size() + +class TrialTowerPlayEndUnanalyzedLogFixed(SaoBaseRequest): + def __init__(self, header: SaoRequestHeader, data: bytes) -> None: + super().__init__(header, data) + off = 0 + ticket_id = decode_str(data, off) + self.ticket_id = ticket_id[0] + off += ticket_id[1] + + user_id = decode_str(data, off) + self.user_id = user_id[0] + off += user_id[1] + + self.trial_tower_id = decode_int(data, off) + off += INT_OFF + + self.rarity_up_exec_flag = decode_byte(data, off) + off += BYTE_OFF