mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-07 07:03:44 -08:00
LttP: use world_version for rom name
This commit is contained in:
@@ -33,7 +33,6 @@ class AutoWorldRegister(type):
|
||||
zip_path: Optional[str]
|
||||
settings_key: str
|
||||
__settings: Any
|
||||
__manifest: Any
|
||||
|
||||
@property
|
||||
def settings(cls) -> Any: # actual type is defined in World
|
||||
@@ -46,38 +45,6 @@ class AutoWorldRegister(type):
|
||||
return None
|
||||
return cls.__settings
|
||||
|
||||
@property
|
||||
def _manifest(cls) -> Dict[str, Any]:
|
||||
if cls.__manifest is None:
|
||||
if cls.zip_path:
|
||||
import zipfile
|
||||
from .Files import APWorldContainer
|
||||
container = APWorldContainer(str(cls.zip_path))
|
||||
with zipfile.ZipFile(container.path, "r") as zf:
|
||||
cls.__manifest = container.read_contents(zf)
|
||||
else:
|
||||
import json
|
||||
import os
|
||||
# look for manifest
|
||||
manifest_path = None
|
||||
world_dir = pathlib.Path(cls.__file__).parent
|
||||
for dirpath, dirnames, filenames in os.walk(world_dir):
|
||||
for file in filenames:
|
||||
if file.endswith("archipelago.json"):
|
||||
manifest_path = os.path.join(dirpath, file)
|
||||
break
|
||||
if manifest_path:
|
||||
break
|
||||
|
||||
if manifest_path:
|
||||
with open(manifest_path, "r", encoding="utf-8-sig") as f:
|
||||
cls.__manifest = json.load(f)
|
||||
elif version_tuple < (0, 7, 0):
|
||||
cls.__manifest = {}
|
||||
else:
|
||||
raise RuntimeError(f"Could not find manifest for {cls.__name__} in {world_dir}.")
|
||||
return cls.__manifest
|
||||
|
||||
def __new__(mcs, name: str, bases: Tuple[type, ...], dct: Dict[str, Any]) -> AutoWorldRegister:
|
||||
if "web" in dct:
|
||||
assert isinstance(dct["web"], WebWorld), "WebWorld has to be instantiated."
|
||||
@@ -134,7 +101,6 @@ class AutoWorldRegister(type):
|
||||
world_folder_name = mod_name[7:].lower() if mod_name.startswith("worlds.") else mod_name.lower()
|
||||
new_class.settings_key = world_folder_name + "_options"
|
||||
new_class.__settings = None
|
||||
new_class.__manifest = None
|
||||
return new_class
|
||||
|
||||
|
||||
@@ -400,10 +366,6 @@ class World(metaclass=AutoWorldRegister):
|
||||
return getattr(self.__class__, item)
|
||||
raise AttributeError
|
||||
|
||||
@property
|
||||
def version(self) -> Version:
|
||||
"""World version loaded from archipelago.json"""
|
||||
return tuplize_version(self._manifest.get("world_version", "0.0.0"))
|
||||
|
||||
# overridable methods that get called by Main.py, sorted by execution order
|
||||
# can also be implemented as a classmethod and called "stage_<original_name>",
|
||||
|
||||
@@ -1699,7 +1699,7 @@ def patch_rom(multiworld: MultiWorld, rom: LocalRom, player: int, enemized: bool
|
||||
|
||||
# set rom name
|
||||
# 21 bytes
|
||||
rom.name = bytearray(f'AP{local_world.version.as_simple_string().replace(".", "")[0:3]}_{player}_{multiworld.seed:11}\0', 'utf8')[:21]
|
||||
rom.name = bytearray(f'AP{local_world.world_version.as_simple_string().replace(".", "")[0:3]}_{player}_{multiworld.seed:11}\0', 'utf8')[:21]
|
||||
rom.name.extend([0] * (21 - len(rom.name)))
|
||||
rom.write_bytes(0x7FC0, rom.name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user