Skip to content

Commit

Permalink
YGO06: fix client not loading if another game already loaded the bizh…
Browse files Browse the repository at this point in the history
…awk client
  • Loading branch information
Rensen3 committed Nov 21, 2023
1 parent e818f04 commit 4715286
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
19 changes: 0 additions & 19 deletions worlds/yugioh06/Client_bh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,6 @@

from worlds.yugioh06 import item_to_index

# This imports the bizhawk apworld if it's not already imported. This code block should be removed for a PR.
if "worlds._bizhawk" not in sys.modules:
import importlib
import os
import zipimport

bh_apworld_path = os.path.join(os.path.dirname(sys.modules["worlds"].__file__), "_bizhawk.apworld")
if os.path.isfile(bh_apworld_path):
importer = zipimport.zipimporter(bh_apworld_path)
spec = importer.find_spec(os.path.basename(bh_apworld_path).rsplit(".", 1)[0])
mod = importlib.util.module_from_spec(spec)
mod.__package__ = f"worlds.{mod.__package__}"
mod.__name__ = f"worlds.{mod.__name__}"
sys.modules[mod.__name__] = mod
importer.exec_module(mod)
elif not os.path.isdir(os.path.splitext(bh_apworld_path)[0]):
raise AssertionError("Did not find _bizhawk.apworld required to play Yu-Gi-Oh! 2006.")


from NetUtils import ClientStatus, NetworkItem
import worlds._bizhawk as bizhawk
from worlds._bizhawk.client import BizHawkClient
Expand Down
2 changes: 2 additions & 0 deletions worlds/yugioh06/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
logging.warning("Did not find _bizhawk.apworld required to play Yu-Gi-Oh! 2006. Still able to generate.")
else:
from .Client_bh import YuGiOh2006Client # Unused, but required to register with BizHawkClient
else:
from .Client_bh import YuGiOh2006Client # Unused, but required to register with BizHawkClient


class Yugioh06Web(WebWorld):
Expand Down

0 comments on commit 4715286

Please sign in to comment.