From 6a08064a520fb4a1a1f9d83fe0280c22e8c3d95b Mon Sep 17 00:00:00 2001 From: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> Date: Sat, 4 Oct 2025 03:04:23 +0200 Subject: [PATCH] Core: Assert that if an apworld manifest file exists, it has a game field (#5478) * Assert that if an apworld manifest file exists, it has a game field * god damnit * Update worlds/LauncherComponents.py Co-authored-by: Fabian Dill * Update setup.py Co-authored-by: Fabian Dill --------- Co-authored-by: Fabian Dill --- setup.py | 9 +++++++++ worlds/LauncherComponents.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/setup.py b/setup.py index 98b9dd60..0233c247 100644 --- a/setup.py +++ b/setup.py @@ -383,6 +383,15 @@ class BuildExeCommand(cx_Freeze.command.build_exe.build_exe): world_directory = self.libfolder / "worlds" / file_name if os.path.isfile(world_directory / "archipelago.json"): manifest = json.load(open(world_directory / "archipelago.json")) + + assert "game" in manifest, ( + f"World directory {world_directory} has an archipelago.json manifest file, but it" + "does not define a \"game\"." + ) + assert manifest["game"] == worldtype.game, ( + f"World directory {world_directory} has an archipelago.json manifest file, but value of the" + f"\"game\" field ({manifest['game']} does not equal the World class's game ({worldtype.game})." + ) else: manifest = {} # this method creates an apworld that cannot be moved to a different OS or minor python version, diff --git a/worlds/LauncherComponents.py b/worlds/LauncherComponents.py index 5d50cdef..527208cc 100644 --- a/worlds/LauncherComponents.py +++ b/worlds/LauncherComponents.py @@ -274,6 +274,15 @@ if not is_frozen(): world_directory = os.path.join("worlds", file_name) if os.path.isfile(os.path.join(world_directory, "archipelago.json")): manifest = json.load(open(os.path.join(world_directory, "archipelago.json"))) + + assert "game" in manifest, ( + f"World directory {world_directory} has an archipelago.json manifest file, but it" + "does not define a \"game\"." + ) + assert manifest["game"] == worldtype.game, ( + f"World directory {world_directory} has an archipelago.json manifest file, but value of the" + f"\"game\" field ({manifest['game']} does not equal the World class's game ({worldtype.game})." + ) else: manifest = {}