handle merge conflicts after plando update
This commit is contained in:
parent
514cd19367
commit
7333a15f1f
4
Fill.py
4
Fill.py
|
@ -2,8 +2,8 @@ import logging
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from BaseClasses import CollectionState, PlandoItem
|
from BaseClasses import CollectionState, PlandoItem
|
||||||
from Items import ItemFactory
|
from worlds.alttp.Items import ItemFactory
|
||||||
from Regions import key_drop_data
|
from worlds.alttp.Regions import key_drop_data
|
||||||
|
|
||||||
|
|
||||||
class FillError(RuntimeError):
|
class FillError(RuntimeError):
|
||||||
|
|
|
@ -18,6 +18,7 @@ from worlds.alttp.Main import main as ERmain
|
||||||
from worlds.alttp.Main import get_seed, seeddigits
|
from worlds.alttp.Main import get_seed, seeddigits
|
||||||
from worlds.alttp.Items import item_name_groups, item_table
|
from worlds.alttp.Items import item_name_groups, item_table
|
||||||
from worlds.alttp import Bosses
|
from worlds.alttp import Bosses
|
||||||
|
from worlds.alttp.Text import TextTable
|
||||||
|
|
||||||
|
|
||||||
def mystery_argparse():
|
def mystery_argparse():
|
||||||
|
|
19
Patch.py
19
Patch.py
|
@ -14,6 +14,7 @@ from worlds.alttp.Rom import JAP10HASH
|
||||||
|
|
||||||
current_patch_version = 1
|
current_patch_version = 1
|
||||||
|
|
||||||
|
|
||||||
def get_base_rom_path(file_name: str = "") -> str:
|
def get_base_rom_path(file_name: str = "") -> str:
|
||||||
options = Utils.get_options()
|
options = Utils.get_options()
|
||||||
if not file_name:
|
if not file_name:
|
||||||
|
@ -43,7 +44,8 @@ def generate_yaml(patch: bytes, metadata: Optional[dict] = None) -> bytes:
|
||||||
patch = yaml.dump({"meta": metadata,
|
patch = yaml.dump({"meta": metadata,
|
||||||
"patch": patch,
|
"patch": patch,
|
||||||
"game": "alttp",
|
"game": "alttp",
|
||||||
"compatible_version": 1, # minimum version of patch system expected for patching to be successful
|
"compatible_version": 1,
|
||||||
|
# minimum version of patch system expected for patching to be successful
|
||||||
"version": current_patch_version,
|
"version": current_patch_version,
|
||||||
"base_checksum": JAP10HASH})
|
"base_checksum": JAP10HASH})
|
||||||
return patch.encode(encoding="utf-8-sig")
|
return patch.encode(encoding="utf-8-sig")
|
||||||
|
@ -64,9 +66,10 @@ def create_patch_file(rom_file_to_patch: str, server: str = "", destination: str
|
||||||
write_lzma(bytes, target)
|
write_lzma(bytes, target)
|
||||||
return target
|
return target
|
||||||
|
|
||||||
def create_rom_bytes(patch_file: str) -> Tuple[dict, str, bytearray]:
|
|
||||||
|
def create_rom_bytes(patch_file: str, ignore_version: bool = False) -> Tuple[dict, str, bytearray]:
|
||||||
data = Utils.parse_yaml(lzma.decompress(load_bytes(patch_file)).decode("utf-8-sig"))
|
data = Utils.parse_yaml(lzma.decompress(load_bytes(patch_file)).decode("utf-8-sig"))
|
||||||
if data["compatible_version"] > current_patch_version:
|
if not ignore_version and data["compatible_version"] > current_patch_version:
|
||||||
raise RuntimeError("Patch file is incompatible with this patcher, likely an update is required.")
|
raise RuntimeError("Patch file is incompatible with this patcher, likely an update is required.")
|
||||||
patched_data = bsdiff4.patch(get_base_rom_bytes(), data["patch"])
|
patched_data = bsdiff4.patch(get_base_rom_bytes(), data["patch"])
|
||||||
rom_hash = patched_data[int(0x7FC0):int(0x7FD5)]
|
rom_hash = patched_data[int(0x7FC0):int(0x7FD5)]
|
||||||
|
@ -74,6 +77,7 @@ def create_rom_bytes(patch_file: str) -> Tuple[dict, str, bytearray]:
|
||||||
target = os.path.splitext(patch_file)[0] + ".sfc"
|
target = os.path.splitext(patch_file)[0] + ".sfc"
|
||||||
return data["meta"], target, patched_data
|
return data["meta"], target, patched_data
|
||||||
|
|
||||||
|
|
||||||
def create_rom_file(patch_file: str) -> Tuple[dict, str]:
|
def create_rom_file(patch_file: str) -> Tuple[dict, str]:
|
||||||
data, target, patched_data = create_rom_bytes(patch_file)
|
data, target, patched_data = create_rom_bytes(patch_file)
|
||||||
with open(target, "wb") as f:
|
with open(target, "wb") as f:
|
||||||
|
@ -143,6 +147,7 @@ if __name__ == "__main__":
|
||||||
for romname in multidata['roms']:
|
for romname in multidata['roms']:
|
||||||
Utils.persistent_store("servers", "".join(chr(byte) for byte in romname[2]), address)
|
Utils.persistent_store("servers", "".join(chr(byte) for byte in romname[2]), address)
|
||||||
from Utils import get_options
|
from Utils import get_options
|
||||||
|
|
||||||
multidata["server_options"] = get_options()["server_options"]
|
multidata["server_options"] = get_options()["server_options"]
|
||||||
multidata = zlib.compress(json.dumps(multidata).encode("utf-8"), 9)
|
multidata = zlib.compress(json.dumps(multidata).encode("utf-8"), 9)
|
||||||
with open(rom + "_updated.archipelago", 'wb') as f:
|
with open(rom + "_updated.archipelago", 'wb') as f:
|
||||||
|
@ -151,7 +156,8 @@ if __name__ == "__main__":
|
||||||
elif rom.endswith(".zip"):
|
elif rom.endswith(".zip"):
|
||||||
print(f"Updating host in patch files contained in {rom}")
|
print(f"Updating host in patch files contained in {rom}")
|
||||||
|
|
||||||
def _handle_zip_file_entry(zfinfo : zipfile.ZipInfo, server: str):
|
|
||||||
|
def _handle_zip_file_entry(zfinfo: zipfile.ZipInfo, server: str):
|
||||||
data = zfr.read(zfinfo)
|
data = zfr.read(zfinfo)
|
||||||
if zfinfo.filename.endswith(".apbp"):
|
if zfinfo.filename.endswith(".apbp"):
|
||||||
data = update_patch_data(data, server)
|
data = update_patch_data(data, server)
|
||||||
|
@ -163,7 +169,8 @@ if __name__ == "__main__":
|
||||||
futures = []
|
futures = []
|
||||||
with zipfile.ZipFile(rom, "r") as zfr:
|
with zipfile.ZipFile(rom, "r") as zfr:
|
||||||
updated_zip = os.path.splitext(rom)[0] + "_updated.zip"
|
updated_zip = os.path.splitext(rom)[0] + "_updated.zip"
|
||||||
with zipfile.ZipFile(updated_zip, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zfw:
|
with zipfile.ZipFile(updated_zip, "w", compression=zipfile.ZIP_DEFLATED,
|
||||||
|
compresslevel=9) as zfw:
|
||||||
for zfname in zfr.namelist():
|
for zfname in zfr.namelist():
|
||||||
futures.append(pool.submit(_handle_zip_file_entry, zfr.getinfo(zfname), address))
|
futures.append(pool.submit(_handle_zip_file_entry, zfr.getinfo(zfname), address))
|
||||||
for future in futures:
|
for future in futures:
|
||||||
|
@ -171,6 +178,6 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
input("Press enter to close.")
|
input("Press enter to close.")
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from worlds.alttp.Dungeons import get_dungeon_item_pool
|
||||||
from worlds.alttp.EntranceShuffle import connect_entrance
|
from worlds.alttp.EntranceShuffle import connect_entrance
|
||||||
from Fill import FillError, fill_restrictive
|
from Fill import FillError, fill_restrictive
|
||||||
from worlds.alttp.Items import ItemFactory
|
from worlds.alttp.Items import ItemFactory
|
||||||
from Rules import forbid_items_for_player
|
from worlds.alttp.Rules import forbid_items_for_player
|
||||||
|
|
||||||
# This file sets the item pools for various modes. Timed modes and triforce hunt are enforced first, and then extra items are specified per mode to fill in the remaining space.
|
# This file sets the item pools for various modes. Timed modes and triforce hunt are enforced first, and then extra items are specified per mode to fill in the remaining space.
|
||||||
# Some basic items that various modes require are placed here, including pendants and crystals. Medallion requirements for the two relevant entrances are also decided.
|
# Some basic items that various modes require are placed here, including pendants and crystals. Medallion requirements for the two relevant entrances are also decided.
|
||||||
|
|
|
@ -124,7 +124,7 @@ class LocalRom(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
if os.path.isfile(local_path('data', 'basepatch.apbp')):
|
if os.path.isfile(local_path('data', 'basepatch.apbp')):
|
||||||
_, target, buffer = Patch.create_rom_bytes(local_path('data', 'basepatch.apbp'))
|
_, target, buffer = Patch.create_rom_bytes(local_path('data', 'basepatch.apbp'), ignore_version=True)
|
||||||
if self.verify(buffer):
|
if self.verify(buffer):
|
||||||
self.buffer = bytearray(buffer)
|
self.buffer = bytearray(buffer)
|
||||||
with open(local_path('basepatch.sfc'), 'wb') as stream:
|
with open(local_path('basepatch.sfc'), 'wb') as stream:
|
||||||
|
|
Loading…
Reference in New Issue