Skip to content

Commit f385b6d

Browse files
Berserker66EmilyV99
authored andcommitted
Core: differentiate between unknown worlds and broken worlds in error message (ArchipelagoMW#2903)
1 parent 42a23b4 commit f385b6d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Generate.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from worlds.alttp.Text import TextTable
2727
from worlds.AutoWorld import AutoWorldRegister
2828
from worlds.generic import PlandoConnection
29+
from worlds import failed_world_loads
2930

3031

3132
def mystery_argparse():
@@ -458,7 +459,11 @@ def roll_settings(weights: dict, plando_options: PlandoOptions = PlandoOptions.b
458459

459460
ret.game = get_choice("game", weights)
460461
if ret.game not in AutoWorldRegister.world_types:
461-
picks = Utils.get_fuzzy_results(ret.game, AutoWorldRegister.world_types, limit=1)[0]
462+
picks = Utils.get_fuzzy_results(ret.game, list(AutoWorldRegister.world_types) + failed_world_loads, limit=1)[0]
463+
if picks[0] in failed_world_loads:
464+
raise Exception(f"No functional world found to handle game {ret.game}. "
465+
f"Did you mean '{picks[0]}' ({picks[1]}% sure)? "
466+
f"If so, it appears the world failed to initialize correctly.")
462467
raise Exception(f"No world found to handle game {ret.game}. Did you mean '{picks[0]}' ({picks[1]}% sure)? "
463468
f"Check your spelling or installation of that world.")
464469

worlds/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@
2020
"user_folder",
2121
"GamesPackage",
2222
"DataPackage",
23+
"failed_world_loads",
2324
}
2425

2526

27+
failed_world_loads: List[str] = []
28+
29+
2630
class GamesPackage(TypedDict, total=False):
2731
item_name_groups: Dict[str, List[str]]
2832
item_name_to_id: Dict[str, int]
@@ -87,6 +91,7 @@ def load(self) -> bool:
8791
file_like.seek(0)
8892
import logging
8993
logging.exception(file_like.read())
94+
failed_world_loads.append(os.path.basename(self.path).rsplit(".", 1)[0])
9095
return False
9196

9297

0 commit comments

Comments
 (0)