Skip to content

Commit

Permalink
Core: differentiate between unknown worlds and broken worlds in error…
Browse files Browse the repository at this point in the history
… message (#2903)
  • Loading branch information
Berserker66 authored Mar 28, 2024
1 parent 74b2bf5 commit de86062
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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.")

Expand Down
5 changes: 5 additions & 0 deletions worlds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit de86062

Please sign in to comment.