From 37e2da205185ded3e3597ea9c734e2bf7e835fd0 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 27 Aug 2023 11:53:29 -0400 Subject: [PATCH 1/6] maimai: fix usbdl endpoints --- titles/mai2/index.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 053c7d4..be756da 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -234,6 +234,10 @@ class Mai2Servlet: if (url_split[0] == "api" and url_split[1] == "movie") or url_split[0] == "movie": if url_split[2] == "moviestart": return json.dumps({"moviestart":{"status":"OK"}}).encode() + + else: + request.setResponseCode(404) + return b"" if url_split[0] == "old": if url_split[1] == "ping": @@ -247,18 +251,35 @@ class Mai2Servlet: elif url_split[1].startswith("friend"): self.logger.info(f"v{version} old server friend inquire") return zlib.compress(b"{}") + + else: + request.setResponseCode(404) + return b"" elif url_split[0] == "usbdl": if url_split[1] == "CONNECTIONTEST": self.logger.info(f"v{version} usbdl server test") - return zlib.compress(b"ok") + return b"" + + elif self.game_cfg.deliver.udbdl_enable and path.exists(f"{self.game_cfg.deliver.content_folder}/usb/{url_split[-1]}"): + with open(f"{self.game_cfg.deliver.content_folder}/usb/{url_split[-1]}", 'rb') as f: + return f.read() + + else: + request.setResponseCode(404) + return b"" elif url_split[0] == "deliver": file = url_split[len(url_split) - 1] self.logger.info(f"v{version} {file} deliver inquire") - if not self.game_cfg.deliver.enable or not path.exists(f"{self.game_cfg.deliver.content_folder}/{file}"): - return zlib.compress(b"") - + if self.game_cfg.deliver.enable and path.exists(f"{self.game_cfg.deliver.content_folder}/{file}"): + with open(f"{self.game_cfg.deliver.content_folder}/deliver/{url_split[-1]}", 'rb') as f: + return f.read() + + else: + request.setResponseCode(404) + return b"" + else: return zlib.compress(b"{}") From dac655b4ae0f36f1addb6d540e229c2366f60a3f Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 27 Aug 2023 19:18:22 -0400 Subject: [PATCH 2/6] adb: add catch for uninitialized amlib requests --- core/aimedb.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/aimedb.py b/core/aimedb.py index f608231..3ac8b9d 100644 --- a/core/aimedb.py +++ b/core/aimedb.py @@ -85,6 +85,9 @@ class AimedbProtocol(Protocol): return + if head.keychip_id == "ABCD1234567" or head.store_id == 0xfff0: + self.logger.warning(f"Request from uninitialized AMLib: {vars(head)}") + handler, resp_code, name = self.request_list.get(head.cmd, (self.handle_default, None, 'default')) if resp_code is None: From 136e47d1e6bf9286259fae81690f958232f0844b Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Wed, 30 Aug 2023 11:19:13 -0400 Subject: [PATCH 3/6] reader: series -> game --- docs/game_specific_info.md | 22 +++++++++++----------- read.py | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/game_specific_info.md b/docs/game_specific_info.md index e2a8296..8f52807 100644 --- a/docs/game_specific_info.md +++ b/docs/game_specific_info.md @@ -54,7 +54,7 @@ Games listed below have been tested and confirmed working. In order to use the importer locate your game installation folder and execute: ```shell -python read.py --series SDBT --version --binfolder /path/to/game/folder --optfolder /path/to/game/option/folder +python read.py --game SDBT --version --binfolder /path/to/game/folder --optfolder /path/to/game/option/folder ``` The importer for Chunithm will import: Events, Music, Charge Items and Avatar Accesories. @@ -105,7 +105,7 @@ After a failed Online Battle the room will be deleted. The host is used for the In order to use the importer you need to use the provided `Export.csv` file: ```shell -python read.py --series SDCA --version --binfolder titles/cxb/data +python read.py --game SDCA --version --binfolder titles/cxb/data ``` The importer for crossbeats REV. will import Music. @@ -160,11 +160,11 @@ For versions pre-dx In order to use the importer locate your game installation folder and execute: DX: ```shell -python read.py --series --version --binfolder /path/to/StreamingAssets --optfolder /path/to/game/option/folder +python read.py --game --version --binfolder /path/to/StreamingAssets --optfolder /path/to/game/option/folder ``` Pre-DX: ```shell -python read.py --series --version --binfolder /path/to/data --optfolder /path/to/patch/data +python read.py --game --version --binfolder /path/to/data --optfolder /path/to/patch/data ``` The importer for maimai DX will import Events, Music and Tickets. @@ -196,7 +196,7 @@ Pre-Dx uses the same database as DX, so only upgrade using the SDEZ game code! In order to use the importer locate your game installation folder and execute: ```shell -python read.py --series SBZV --version --binfolder /path/to/game/data/diva --optfolder /path/to/game/data/diva/mdata +python read.py --game SBZV --version --binfolder /path/to/game/data/diva --optfolder /path/to/game/data/diva/mdata ``` The importer for Project Diva Arcade will all required data in order to use @@ -243,7 +243,7 @@ python dbutils.py --game SBZV upgrade In order to use the importer locate your game installation folder and execute: ```shell -python read.py --series SDDT --version --binfolder /path/to/game/folder --optfolder /path/to/game/option/folder +python read.py --game SDDT --version --binfolder /path/to/game/folder --optfolder /path/to/game/option/folder ``` The importer for O.N.G.E.K.I. will all all Cards, Music and Events. @@ -299,19 +299,19 @@ In order to use the importer you need to use the provided `.csv` files (which ar option folders: ```shell -python read.py --series SDED --version --binfolder titles/cm/cm_data --optfolder /path/to/cardmaker/option/folder +python read.py --game SDED --version --binfolder titles/cm/cm_data --optfolder /path/to/cardmaker/option/folder ``` **If you haven't already executed the O.N.G.E.K.I. importer, make sure you import all cards!** ```shell -python read.py --series SDDT --version --binfolder /path/to/game/folder --optfolder /path/to/game/option/folder +python read.py --game SDDT --version --binfolder /path/to/game/folder --optfolder /path/to/game/option/folder ``` Also make sure to import all maimai DX and CHUNITHM data as well: ```shell -python read.py --series SDED --version --binfolder /path/to/cardmaker/CardMaker_Data +python read.py --game SDED --version --binfolder /path/to/cardmaker/CardMaker_Data ``` The importer for Card Maker will import all required Gachas (Banners) and cards (for maimai DX/CHUNITHM) and the hardcoded @@ -404,7 +404,7 @@ Gacha IDs up to 1140 will be loaded for CM 1.34 and all gachas will be loaded fo In order to use the importer locate your game installation folder and execute: ```shell -python read.py --series SDFE --version --binfolder /path/to/game/WindowsNoEditor/Mercury/Content +python read.py --game SDFE --version --binfolder /path/to/game/WindowsNoEditor/Mercury/Content ``` The importer for WACCA will import all Music data. @@ -478,7 +478,7 @@ Below is a list of VIP rewards. Currently, VIP is not implemented, and thus thes In order to use the importer locate your game installation folder and execute: ```shell -python read.py --series SDEW --version --binfolder /path/to/game/extractedassets +python read.py --game SDEW --version --binfolder /path/to/game/extractedassets ``` The importer for SAO will import all items, heroes, support skills and titles data. diff --git a/read.py b/read.py index 14c5cc2..fa34314 100644 --- a/read.py +++ b/read.py @@ -43,11 +43,11 @@ class BaseReader: if __name__ == "__main__": parser = argparse.ArgumentParser(description="Import Game Information") parser.add_argument( - "--series", + "--game", action="store", type=str, required=True, - help="The game series we are importing.", + help="The game we are importing.", ) parser.add_argument( "--version", @@ -109,7 +109,7 @@ if __name__ == "__main__": logger.setLevel(log_lv) coloredlogs.install(level=log_lv, logger=logger, fmt=log_fmt_str) - if args.series is None or args.version is None: + if args.game is None or args.version is None: logger.error("Game or version not specified") parser.print_help() exit(1) @@ -134,7 +134,7 @@ if __name__ == "__main__": titles = Utils.get_all_titles() for dir, mod in titles.items(): - if args.series in mod.game_codes: + if args.game in mod.game_codes: handler = mod.reader(config, args.version, bin_arg, opt_arg, args.extra) handler.read() From 3a6cfedccad79fdc71634cf66d0e5193869d914a Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Thu, 31 Aug 2023 01:24:41 -0400 Subject: [PATCH 4/6] maimai: fix net deliver paths --- titles/mai2/config.py | 2 +- titles/mai2/index.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/titles/mai2/config.py b/titles/mai2/config.py index d63c0b2..850e0c1 100644 --- a/titles/mai2/config.py +++ b/titles/mai2/config.py @@ -38,7 +38,7 @@ class Mai2DeliverConfig: @property def content_folder(self) -> int: return CoreConfig.get_config_field( - self.__config, "mai2", "server", "content_folder", default="" + self.__config, "mai2", "deliver", "content_folder", default="" ) class Mai2UploadsConfig: diff --git a/titles/mai2/index.py b/titles/mai2/index.py index be756da..329c1f6 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -228,7 +228,7 @@ class Mai2Servlet: return zlib.compress(json.dumps(resp, ensure_ascii=False).encode("utf-8")) def render_GET(self, request: Request, version: int, url_path: str) -> bytes: - self.logger.info(f"v{version} GET {url_path}") + self.logger.debug(f"v{version} GET {url_path}") url_split = url_path.split("/") if (url_split[0] == "api" and url_split[1] == "movie") or url_split[0] == "movie": @@ -272,9 +272,10 @@ class Mai2Servlet: elif url_split[0] == "deliver": file = url_split[len(url_split) - 1] self.logger.info(f"v{version} {file} deliver inquire") + self.logger.debug(f"{self.game_cfg.deliver.content_folder}/net_deliver/{file}") - if self.game_cfg.deliver.enable and path.exists(f"{self.game_cfg.deliver.content_folder}/{file}"): - with open(f"{self.game_cfg.deliver.content_folder}/deliver/{url_split[-1]}", 'rb') as f: + if self.game_cfg.deliver.enable and path.exists(f"{self.game_cfg.deliver.content_folder}/net_deliver/{file}"): + with open(f"{self.game_cfg.deliver.content_folder}/net_deliver/{file}", 'rb') as f: return f.read() else: From 5499d38bb4110fc7ba922085e9ebcb02c07ce7ae Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Tue, 5 Sep 2023 17:32:51 -0400 Subject: [PATCH 5/6] mucha: streamline mucha_postprocess (thanks Bottersnike!) --- core/mucha.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/mucha.py b/core/mucha.py index 185dd2d..7793f4b 100644 --- a/core/mucha.py +++ b/core/mucha.py @@ -140,9 +140,7 @@ class MuchaServlet: def mucha_postprocess(self, data: dict) -> Optional[bytes]: try: - urlencode = "" - for k, v in data.items(): - urlencode += f"{k}={v}&" + urlencode = "&".join(f"{k}={v}" for k, v in data.items()) return urlencode.encode() From 238e39f415c425273c16ba931428947b6215f2aa Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Wed, 6 Sep 2023 22:47:37 -0400 Subject: [PATCH 6/6] adb: properly handle an incorrect adb status value --- core/adb_handlers/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/adb_handlers/base.py b/core/adb_handlers/base.py index 5523a29..0f208dd 100644 --- a/core/adb_handlers/base.py +++ b/core/adb_handlers/base.py @@ -78,7 +78,10 @@ class ADBHeader: self.protocol_ver = protocol_ver # u16 self.cmd = cmd # u16 self.length = length # u16 - self.status = ADBStatus(status) # u16 + try: + self.status = ADBStatus(status) # u16 + except ValueError as e: + raise ADBHeaderException(f"Status is incorrect! {e}") self.game_id = game_id # 4 char + \x00 self.store_id = store_id # u32 self.keychip_id = keychip_id# 11 char + \x00