From 808203a50f6fd9383c89e29fdee223fb0248d5ec Mon Sep 17 00:00:00 2001 From: zig-for Date: Fri, 14 Apr 2023 22:47:45 -0700 Subject: [PATCH] LADX: fix egg sprite in non-patched gfx mode (#1699) --- worlds/ladx/LADXR/generator.py | 5 ----- worlds/ladx/__init__.py | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/worlds/ladx/LADXR/generator.py b/worlds/ladx/LADXR/generator.py index 08552081cc1b..90670c02584f 100644 --- a/worlds/ladx/LADXR/generator.py +++ b/worlds/ladx/LADXR/generator.py @@ -64,9 +64,6 @@ def generateRom(args, settings, ap_settings, auth, seed_name, logic, rnd=None, multiworld=None, player_name=None, player_names=[], player_id = 0): rom_patches = [] - if ap_settings["ap_title_screen"]: - rom_patches.append(pkgutil.get_data(__name__, "patches/title_screen.bdiff4")) - rom = ROMWithTables(args.input_filename, rom_patches) rom.player_names = player_names pymods = [] @@ -416,9 +413,7 @@ def clamp(x, min, max): assert(len(auth) == 12) rom.patch(0x00, SEED_LOCATION, None, binascii.hexlify(auth)) - for pymod in pymods: pymod.postPatch(rom) - return rom diff --git a/worlds/ladx/__init__.py b/worlds/ladx/__init__.py index 0ec22e38cc04..d64b950e3894 100644 --- a/worlds/ladx/__init__.py +++ b/worlds/ladx/__init__.py @@ -1,5 +1,8 @@ import binascii +import bsdiff4 import os +import pkgutil +import tempfile from BaseClasses import Entrance, Item, ItemClassification, Location, Tutorial from Fill import fill_restrictive @@ -406,10 +409,18 @@ def generate_output(self, output_directory: str): player_names=all_names, player_id = self.player) - handle = open(out_path, "wb") - rom.save(handle, name="LADXR") + with open(out_path, "wb") as handle: + rom.save(handle, name="LADXR") + + # Write title screen after everything else is done - full gfxmods may stomp over the egg tiles + if self.player_options["ap_title_screen"]: + with tempfile.NamedTemporaryFile(delete=False) as title_patch: + title_patch.write(pkgutil.get_data(__name__, "LADXR/patches/title_screen.bdiff4")) + + bsdiff4.file_patch_inplace(out_path, title_patch.name) + os.unlink(title_patch.name) + - handle.close() patch = LADXDeltaPatch(os.path.splitext(out_path)[0]+LADXDeltaPatch.patch_file_ending, player=self.player, player_name=self.multiworld.player_name[self.player], patched_path=out_path) patch.write()