Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BizhawkClient: set metadata from patch file #4346

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions worlds/_bizhawk/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,14 @@ async def _run_game(rom: str):
)


async def _patch_and_run_game(patch_file: str):
def _patch_and_run_game(patch_file: str):
try:
metadata, output_file = Patch.create_rom_file(patch_file)
Utils.async_start(_run_game(output_file))
return metadata
except Exception as exc:
logger.exception(exc)
return {}


def launch(*launch_args) -> None:
Expand All @@ -245,16 +247,18 @@ async def main():
parser.add_argument("patch_file", default="", type=str, nargs="?", help="Path to an Archipelago patch file")
args = parser.parse_args(launch_args)

if args.patch_file != "":
metadata = _patch_and_run_game(args.patch_file)
if "server" in metadata:
args.connect = metadata["server"]

ctx = BizHawkClientContext(args.connect, args.password)
ctx.server_task = asyncio.create_task(server_loop(ctx), name="ServerLoop")

if gui_enabled:
ctx.run_gui()
ctx.run_cli()

if args.patch_file != "":
Utils.async_start(_patch_and_run_game(args.patch_file))

watcher_task = asyncio.create_task(_game_watcher(ctx), name="GameWatcher")

try:
Expand Down
Loading