LADX: Fix gen failures with non-ascii player names, fix missing custom (#1619)

This commit is contained in:
zig-for 2023-03-29 05:41:11 -07:00 committed by GitHub
parent f50e85b401
commit d14ab97849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -17,18 +17,24 @@ class ShopItem(ItemInfo):
def patch(self, rom, option, *, multiworld=None):
mw_text = ""
if multiworld:
mw_text = f" for player {rom.player_names[multiworld - 1]}"
mw_text = f" for player {rom.player_names[multiworld - 1].encode('ascii', 'replace').decode()}"
if self.custom_item_name:
name = self.custom_item_name
else:
name = "{"+option+"}"
if self.__index == 0:
# Old index, maybe not needed any more
rom.patch(0x04, 0x37C5, "08", "%02X" % (CHEST_ITEMS[option]))
rom.texts[0x030] = formatText(f"Deluxe {{%s}} 200 {{RUPEES}}{mw_text}!" % (option), ask="Buy No Way")
rom.texts[0x030] = formatText(f"Deluxe {name} 200 {{RUPEES}}{mw_text}!", ask="Buy No Way")
rom.banks[0x3E][0x3800 + 0x2A1] = CHEST_ITEMS[option]
if multiworld:
rom.banks[0x3E][0x3300 + 0x2A1] = multiworld
elif self.__index == 1:
rom.patch(0x04, 0x37C6, "02", "%02X" % (CHEST_ITEMS[option]))
rom.texts[0x02C] = formatText(f"{{%s}} Only 980 {{RUPEES}}{mw_text}!" % (option), ask="Buy No Way")
rom.texts[0x02C] = formatText(f"{name} only 980 {{RUPEES}}{mw_text}!", ask="Buy No Way")
rom.banks[0x3E][0x3800 + 0x2A7] = CHEST_ITEMS[option]
if multiworld: