Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def normalize_jp_controller_tokens(text: str) -> str:
for code, token in SCJP.items():
if code < 0x10000:
REVERSE_MAP_JP[code] = token
json.dump([CHARACTER_MAP_JP, REVERSE_MAP_JP], open(data_path('generated/jp_char_map.otrx'), mode="w"))
with open(data_path('generated/jp_char_map.otrx'), mode="w", encoding="utf-8") as stream:
json.dump([CHARACTER_MAP_JP, REVERSE_MAP_JP], stream)

for code, token in SCJP.items():
if code < len(REVERSE_MAP_JP):
Expand Down
9 changes: 7 additions & 2 deletions Patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ def patch_rom(spoiler: Spoiler, world: World, rom: Rom) -> Rom:
lang = world.language

# Binary patches of certain assets.
with open(data_path("bin_patch.json"), mode="r", encoding="utf-8") as stream:
bin_patch_data = json.load(stream)

bin_patches = [
(os.path.join(lang.path, x), int(y[0], base=16)) for x, y in json.load(open(data_path("bin_patch.json"))).items() if x in lang.data.keys()
]
(os.path.join(lang.path, x), int(y[0], base=16))
for x, y in bin_patch_data.items()
if x in lang.data.keys()
]

for (bin_path, write_address) in bin_patches:
with open(bin_path, 'rb') as stream:
Expand Down
10 changes: 8 additions & 2 deletions Unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,19 @@ def extract_first_second_level_keys(data: dict) -> list:
class TestLanguageFile(unittest.TestCase):
def test_langfiles(self):
base_keys = extract_first_second_level_keys(data.lang.property_build.lang_info)
bin_patch = list(json.load(open(data_path("bin_patch.json"), encoding='utf-8')).keys()) + ["blue_fire_arrow_item_name_jap.ia4", "blue_fire_arrow_item_name_eng.ia4"]
with open(data_path("bin_patch.json"), mode="r", encoding="utf-8") as stream:
bin_patch = list(json.load(stream).keys()) + [
"blue_fire_arrow_item_name_jap.ia4",
"blue_fire_arrow_item_name_eng.ia4",
]
for lang in os.listdir(lang_path()):
if os.path.isdir(os.path.join(lang_path(), lang)) and lang != "__pycache__":
lang_files = os.listdir(os.path.join(lang_path(), lang))
self.assertIn("property.json", lang_files, msg = "\n{}: property.json is not included".format(lang))
lang_files.remove("property.json")
property_keys = extract_first_second_level_keys(json.load(open(os.path.join(lang_path(), lang, "property.json"), encoding='utf-8')))
property_path = os.path.join(lang_path(), lang, "property.json")
with open(property_path, mode="r", encoding="utf-8") as stream:
property_keys = extract_first_second_level_keys(json.load(stream))
only_in_base = list(sorted(set(base_keys) - set(property_keys)))
only_in_lang = list(sorted(set(property_keys) - set(base_keys)))
diff_keys = []
Expand Down
Loading