diff --git a/worlds/dkc3/Rom.py b/worlds/dkc3/Rom.py index 82114309..7e83589f 100644 --- a/worlds/dkc3/Rom.py +++ b/worlds/dkc3/Rom.py @@ -1,5 +1,5 @@ import Utils -from Patch import read_rom +from Patch import read_rom, APDeltaPatch from .Locations import lookup_id_to_name, all_locations from .Levels import level_list, level_dict @@ -529,6 +529,15 @@ def patch_rom(world, rom, player, active_level_list): rom.write_byte(0x3B97EA, 0xEA) +class DKC3DeltaPatch(APDeltaPatch): + hash = USHASH + game = "Donkey Kong Country 3" + patch_file_ending = ".apdkc3" + + @classmethod + def get_source_data(cls) -> bytes: + return get_base_rom_bytes() + def get_base_rom_bytes(file_name: str = "") -> bytes: base_rom_bytes = getattr(get_base_rom_bytes, "base_rom_bytes", None) diff --git a/worlds/dkc3/__init__.py b/worlds/dkc3/__init__.py index d9e73a7e..42369347 100644 --- a/worlds/dkc3/__init__.py +++ b/worlds/dkc3/__init__.py @@ -12,7 +12,7 @@ from .Levels import level_list from .Rules import set_rules from .Names import ItemName, LocationName from ..AutoWorld import WebWorld, World -from .Rom import LocalRom, patch_rom, get_base_rom_path +from .Rom import LocalRom, patch_rom, get_base_rom_path, DKC3DeltaPatch import Patch @@ -138,19 +138,23 @@ class DKC3World(World): patch_rom(self.world, rom, self.player, self.active_level_list) self.active_level_list.append(LocationName.rocket_rush_region) - + outfilepname = f'_P{player}' outfilepname += f"_{world.player_name[player].replace(' ', '_')}" \ if world.player_name[player] != 'Player%d' % player else '' rompath = os.path.join(output_directory, f'AP_{world.seed_name}{outfilepname}.sfc') rom.write_to_file(rompath) - Patch.create_patch_file(rompath, player=player, player_name=world.player_name[player], game=Patch.GAME_DKC3) - os.unlink(rompath) self.rom_name = rom.name + + patch = DKC3DeltaPatch(os.path.splitext(rompath)[0]+DKC3DeltaPatch.patch_file_ending, player=player, + player_name=world.player_name[player], patched_path=rompath) + patch.write() except: raise finally: + if os.path.exists(rompath): + os.unlink(rompath) self.rom_name_available_event.set() # make sure threading continues and errors are collected def modify_multidata(self, multidata: dict):