From 3bfc9cc84591d4334de7dd7988e2e32ae4582de9 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Wed, 10 Jan 2024 12:51:40 -0500 Subject: [PATCH] sao: stub give_free_ticket --- titles/sao/base.py | 8 ++++++++ titles/sao/handlers/base.py | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/titles/sao/base.py b/titles/sao/base.py index 09a9f88..af6a1d4 100644 --- a/titles/sao/base.py +++ b/titles/sao/base.py @@ -42,6 +42,14 @@ class SaoBase: resp = SaoGetMaintResponse(header.cmd +1) return resp.make() + def handle_c12a(self, header: SaoRequestHeader, request: bytes) -> bytes: + #common/give_free_ticket + req = SaoGiveFreeTicketRequest(header, request) + self.logger.info(f"Give {req.give_num} free tickets (id {req.ticket_id}) to user {req.user_id}") + resp = SaoGiveFreeTicketResponse(header.cmd +1) + return resp.make() + + def handle_c12e(self, header: SaoRequestHeader, request: bytes) -> bytes: #common/ac_cabinet_boot_notification resp = SaoCommonAcCabinetBootNotificationResponse(header.cmd +1) diff --git a/titles/sao/handlers/base.py b/titles/sao/handlers/base.py index 4178640..81f30f8 100644 --- a/titles/sao/handlers/base.py +++ b/titles/sao/handlers/base.py @@ -3230,3 +3230,25 @@ class GetMResEarnCampaignShopsResponse(SaoBaseResponse): self.header.length = len(ret) return super().make() + ret + +class SaoGiveFreeTicketRequest(SaoBaseRequest): + def __init__(self, header: SaoRequestHeader, data: bytes) -> None: + super().__init__(header, data) + off = 0 + self.ticket_id, new_off = decode_str(data, off) + off += new_off + + self.user_id, new_off = decode_str(data, off) + off += new_off + + self.give_num = decode_byte(data, off) + off += BYTE_OFF + +class SaoGiveFreeTicketResponse(SaoBaseResponse): + def __init__(self, cmd_id: int) -> None: + super().__init__(cmd_id) + self.result = 1 # byte + + def make(self) -> bytes: + ret = encode_byte(self.result) + return super().make() + ret