From de860623d17d274289e3e4ab13650f2382e2e0b8 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Thu, 28 Mar 2024 22:21:56 +0100 Subject: [PATCH] Core: differentiate between unknown worlds and broken worlds in error message (#2903) --- Generate.py | 7 ++++++- worlds/__init__.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Generate.py b/Generate.py index 56979334b54..f646e994dca 100644 --- a/Generate.py +++ b/Generate.py @@ -26,6 +26,7 @@ from worlds.alttp.Text import TextTable from worlds.AutoWorld import AutoWorldRegister from worlds.generic import PlandoConnection +from worlds import failed_world_loads def mystery_argparse(): @@ -458,7 +459,11 @@ def roll_settings(weights: dict, plando_options: PlandoOptions = PlandoOptions.b ret.game = get_choice("game", weights) if ret.game not in AutoWorldRegister.world_types: - picks = Utils.get_fuzzy_results(ret.game, AutoWorldRegister.world_types, limit=1)[0] + picks = Utils.get_fuzzy_results(ret.game, list(AutoWorldRegister.world_types) + failed_world_loads, limit=1)[0] + if picks[0] in failed_world_loads: + raise Exception(f"No functional world found to handle game {ret.game}. " + f"Did you mean '{picks[0]}' ({picks[1]}% sure)? " + f"If so, it appears the world failed to initialize correctly.") raise Exception(f"No world found to handle game {ret.game}. Did you mean '{picks[0]}' ({picks[1]}% sure)? " f"Check your spelling or installation of that world.") diff --git a/worlds/__init__.py b/worlds/__init__.py index 168bba7abf4..53b0c5ceb94 100644 --- a/worlds/__init__.py +++ b/worlds/__init__.py @@ -20,9 +20,13 @@ "user_folder", "GamesPackage", "DataPackage", + "failed_world_loads", } +failed_world_loads: List[str] = [] + + class GamesPackage(TypedDict, total=False): item_name_groups: Dict[str, List[str]] item_name_to_id: Dict[str, int] @@ -87,6 +91,7 @@ def load(self) -> bool: file_like.seek(0) import logging logging.exception(file_like.read()) + failed_world_loads.append(os.path.basename(self.path).rsplit(".", 1)[0]) return False