From 0949b114367ab1e7c4a1870e69c7572657b03cff Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Thu, 20 Mar 2025 06:48:30 -0700 Subject: [PATCH] ALttP: Don't crash generation if sprite paths don't exist (#4725) --- worlds/alttp/Rom.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/worlds/alttp/Rom.py b/worlds/alttp/Rom.py index f658b930..5ed048e8 100644 --- a/worlds/alttp/Rom.py +++ b/worlds/alttp/Rom.py @@ -515,10 +515,15 @@ def _populate_sprite_table(): logging.debug(f"Spritefile {file} could not be loaded as a valid sprite.") with concurrent.futures.ThreadPoolExecutor() as pool: - for dir in [user_path('data', 'sprites', 'alttpr'), user_path('data', 'sprites', 'custom')]: + sprite_paths = [user_path('data', 'sprites', 'alttpr'), user_path('data', 'sprites', 'custom')] + for dir in [dir for dir in sprite_paths if os.path.isdir(dir)]: for file in os.listdir(dir): pool.submit(load_sprite_from_file, os.path.join(dir, file)) + if "link" not in _sprite_table: + logging.info("Link sprite was not loaded. Loading link from base rom") + load_sprite_from_file(get_base_rom_path()) + class Sprite(): sprite_size = 28672 @@ -554,6 +559,11 @@ class Sprite(): self.sprite = filedata[0x80000:0x87000] self.palette = filedata[0xDD308:0xDD380] self.glove_palette = filedata[0xDEDF5:0xDEDF9] + h = hashlib.md5() + h.update(filedata) + if h.hexdigest() == LTTPJPN10HASH: + self.name = "Link" + self.author_name = "Nintendo" elif filedata.startswith(b'ZSPR'): self.from_zspr(filedata, filename) else: