sao: fix both unanalyzed log fixed requests

This commit is contained in:
Hay1tsme 2023-11-12 17:35:06 -05:00
parent ff48438b85
commit 9026c25fcc
2 changed files with 36 additions and 26 deletions

View File

@ -874,40 +874,18 @@ class SaoBase:
def handle_c90a(self, header: SaoRequestHeader, request: bytes) -> bytes: def handle_c90a(self, header: SaoRequestHeader, request: bytes) -> bytes:
#quest/episode_play_end_unanalyzed_log_fixed #quest/episode_play_end_unanalyzed_log_fixed
req = bytes.fromhex(request)[24:] req = SaoEpisodePlayEndUnanalyzedLogFixedRequest(header, request)
req_struct = Struct( end_session_data = self.game_data.item.get_end_session(req.user_id)
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)
resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(header.cmd +1, end_session_data[4]) resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(header.cmd +1, end_session_data[4])
return resp.make() return resp.make()
def handle_c91a(self, header: SaoRequestHeader, request: bytes) -> bytes: # handler is identical to the episode def handle_c91a(self, header: SaoRequestHeader, request: bytes) -> bytes: # handler is identical to the episode
#quest/trial_tower_play_end_unanalyzed_log_fixed #quest/trial_tower_play_end_unanalyzed_log_fixed
req = bytes.fromhex(request)[24:] req = TrialTowerPlayEndUnanalyzedLogFixed(header, request)
req_struct = Struct( end_session_data = self.game_data.item.get_end_session(req.user_id)
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)
resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(header.cmd +1, end_session_data[4]) resp = SaoEpisodePlayEndUnanalyzedLogFixedResponse(header.cmd +1, end_session_data[4])
return resp.make() return resp.make()

View File

@ -1798,6 +1798,20 @@ class SaoTrialTowerPlayEndResponse(SaoBaseResponse):
class SaoEpisodePlayEndUnanalyzedLogFixedRequest(SaoBaseRequest): class SaoEpisodePlayEndUnanalyzedLogFixedRequest(SaoBaseRequest):
def __init__(self, header: SaoRequestHeader, data: bytes) -> None: def __init__(self, header: SaoRequestHeader, data: bytes) -> None:
super().__init__(header, data) 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): class SaoEpisodePlayEndUnanalyzedLogFixedResponse(SaoBaseResponse):
def __init__(self, cmd, end_session_data) -> None: def __init__(self, cmd, end_session_data) -> None:
@ -2989,3 +3003,21 @@ class SaoChangePartyRequest(SaoBaseRequest):
tmp = PartyData(data, off) tmp = PartyData(data, off)
self.party_data_list.append(tmp) self.party_data_list.append(tmp)
off += tmp.get_size() 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