From 6ba973c5d11e43c0e1edc348bd8cdfc2143a7f40 Mon Sep 17 00:00:00 2001 From: qwint Date: Wed, 4 Dec 2024 12:47:22 -0600 Subject: [PATCH] move client to apworld note: the pkgutil call seems to currently not be working, probably because the surrounding functions want a different format than bytes it returns --- worlds/LauncherComponents.py | 2 -- .../rusted_moss/RustedMossClient.py | 3 ++- worlds/rusted_moss/__init__.py | 11 +++++++++++ .../data/RandomizerLogicFlatlandsOnly.csv | 0 .../rusted_moss/data}/rusted_moss_patch.bsdiff | Bin 5 files changed, 13 insertions(+), 3 deletions(-) rename RustedMossClient.py => worlds/rusted_moss/RustedMossClient.py (98%) rename RandomizerLogicFlatlandsOnly.csv => worlds/rusted_moss/data/RandomizerLogicFlatlandsOnly.csv (100%) rename {data => worlds/rusted_moss/data}/rusted_moss_patch.bsdiff (100%) diff --git a/worlds/LauncherComponents.py b/worlds/LauncherComponents.py index 4e4ab05958bc..57d2a931abd8 100644 --- a/worlds/LauncherComponents.py +++ b/worlds/LauncherComponents.py @@ -192,8 +192,6 @@ def install_apworld(apworld_path: str = "") -> None: #MegaMan Battle Network 3 Component('MMBN3 Client', 'MMBN3Client', file_identifier=SuffixIdentifier('.apbn3')), - # Rusted Moss - Component('Rusted Moss Client', 'RustedMossClient') ] diff --git a/RustedMossClient.py b/worlds/rusted_moss/RustedMossClient.py similarity index 98% rename from RustedMossClient.py rename to worlds/rusted_moss/RustedMossClient.py index cde25a89eb38..138dcf162b3f 100644 --- a/RustedMossClient.py +++ b/worlds/rusted_moss/RustedMossClient.py @@ -3,6 +3,7 @@ import typing import bsdiff4 import hashlib +import pkgutil import Utils @@ -37,7 +38,7 @@ def _cmd_patch(self, directory: str = ""): if RAWDATAHASH != basemd5.hexdigest(): self.output("ERROR: MD5 hash of data.win file does not match correct hash. Make sure you have downpatched to the correct version (1.47)") else: - bsdiff4.file_patch_inplace(dataWinPath, os.path.join(os.getcwd(), "data/rusted_moss_patch.bsdiff")) + bsdiff4.file_patch_inplace(dataWinPath, pkgutil.get_data(__name__, "data/rusted_moss_patch.bsdiff")) moddedmd5 = hashlib.md5() with open(dataWinPath, "rb") as file: modded_data_bytes = bytes(file.read()) diff --git a/worlds/rusted_moss/__init__.py b/worlds/rusted_moss/__init__.py index cddd1c55c2b4..8af22f46fe69 100644 --- a/worlds/rusted_moss/__init__.py +++ b/worlds/rusted_moss/__init__.py @@ -1,6 +1,7 @@ from dataclasses import asdict from typing import Dict, Any from worlds.AutoWorld import World +from worlds.LauncherComponents import components, Component, launch_subprocess from BaseClasses import ItemClassification, Region from .Items import RustedMossItem, item_dict @@ -9,6 +10,16 @@ from .LogicExtractor import extract_logic from ..generic.Rules import set_rule + +def launch_client(*args): + from .RustedMossClient import main + launch_subprocess(main, name="Rusted Moss Client") + + +# Add component to Launcher +components.append(Component('Rusted Moss Client', func=launch_client)) + + class RustedMossWorld(World): """ Rusted Moss is a metroidvania featuring an elastic physics-based grappling hook. diff --git a/RandomizerLogicFlatlandsOnly.csv b/worlds/rusted_moss/data/RandomizerLogicFlatlandsOnly.csv similarity index 100% rename from RandomizerLogicFlatlandsOnly.csv rename to worlds/rusted_moss/data/RandomizerLogicFlatlandsOnly.csv diff --git a/data/rusted_moss_patch.bsdiff b/worlds/rusted_moss/data/rusted_moss_patch.bsdiff similarity index 100% rename from data/rusted_moss_patch.bsdiff rename to worlds/rusted_moss/data/rusted_moss_patch.bsdiff