mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 20:25:57 +00:00
The cheat, ExeFS patch and plugin tools read and write their patch files as UTF-8, the encoding recomp/patches.py load now reads them in
Without Python's UTF-8 mode these tools used the locale code page, so a plugin image path with non-ASCII characters (tools/exefs_plugins.py plugin_lines) would reach the generator in a code page it no longer reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f780b3d216
commit
a7f24442b6
3 files changed
+7
-7
No files matched your search
+3
-3
@@ -349,7 +349,7 @@ def main():
|
||||
args = ap.parse_args()
|
||||
sys.stdout.reconfigure(errors='replace') # cheat names in a console without their characters
|
||||
m = Main(args.exefs / 'main')
|
||||
text = args.patches.read_text()
|
||||
text = args.patches.read_text(encoding='utf-8')
|
||||
files = cheat_files(args.mods, build_id(args.exefs / 'main'))
|
||||
cheats = [c for mod, f in files for c in parse(f.read_text(encoding='utf-8-sig', errors='replace'), mod)]
|
||||
sets, sites, status = [], [], []
|
||||
@@ -357,7 +357,7 @@ def main():
|
||||
classify(m, c)
|
||||
if c.sites:
|
||||
name = f'cheat_{c.key.lower()}'
|
||||
label = c.name.encode('ascii', 'replace').decode() # recomp/patches.py reads the file as ASCII
|
||||
label = c.name.encode('ascii', 'replace').decode() # a comment only, kept ASCII like the mod labels
|
||||
sets.append(f'set {name} TOTK_CHEAT_{c.key} {1 if c.kind == "master" else 0} # {label}')
|
||||
for a, repl in sorted(c.sites.items()):
|
||||
sites.append(f'site {name} main {a:x} {m.word(a):08x} {" ".join(f"{w:08x}" for w in repl)}')
|
||||
@@ -367,7 +367,7 @@ def main():
|
||||
print(f'cheats: {c.kind:11} {c.name}' + (f' ({note})' if note else ''))
|
||||
if sets:
|
||||
text += ('\n# Cheats of the mods folder (tools/cheats.py)\n' + '\n'.join(sets) + '\n' + '\n'.join(sites) + '\n')
|
||||
args.out.write_text(text)
|
||||
args.out.write_text(text, encoding='utf-8')
|
||||
args.status.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.status.write_text('\n'.join(status) + ('\n' if status else ''), encoding='utf-8')
|
||||
kinds = {}
|
||||
|
||||
@@ -319,7 +319,7 @@ def build(args):
|
||||
m = Main(args.exefs / 'main')
|
||||
md = MainData(m) if args.data else None
|
||||
bid = m.nso.build_id
|
||||
text = args.patches.read_text()
|
||||
text = args.patches.read_text(encoding='utf-8')
|
||||
builtin = builtin_sites(text)
|
||||
files = patch_files(args.mods)
|
||||
sets, sites, status, data_lines, kinds = [], [], [], [], {}
|
||||
@@ -351,7 +351,7 @@ def build(args):
|
||||
if sets:
|
||||
text += ('\n# ExeFS patches of the mods folder (tools/exefs_patches.py)\n' + '\n'.join(sets) + '\n'
|
||||
+ '\n'.join(sites) + '\n')
|
||||
args.out.write_text(text)
|
||||
args.out.write_text(text, encoding='utf-8')
|
||||
args.status.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.status.write_text('\n'.join(status) + ('\n' if status else ''), encoding='utf-8')
|
||||
if args.data:
|
||||
|
||||
@@ -454,7 +454,7 @@ def plugin_files(mods):
|
||||
def emit(results, args):
|
||||
"""--patches-out and --status from the checked plugins. results: one (module, its NSO file, its record or None,
|
||||
the record's directory, hooks, reasons) per plugin of the layout; no reasons: accepted."""
|
||||
text = args.patches.read_text() if args.patches else ''
|
||||
text = args.patches.read_text(encoding='utf-8') if args.patches else ''
|
||||
builtin = builtin_sites(text)
|
||||
status, sets = [], []
|
||||
files = {str(f.resolve()): (m, rel, f) for m, rel, f in plugin_files(args.mods)}
|
||||
@@ -482,7 +482,7 @@ def emit(results, args):
|
||||
if over else ''))
|
||||
if sets:
|
||||
text += '\n# Mod plugins (tools/exefs_plugins.py)\n' + '\n'.join(line for s in sets for line in s) + '\n'
|
||||
args.patches_out.write_text(text)
|
||||
args.patches_out.write_text(text, encoding='utf-8')
|
||||
args.status.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.status.write_text('\n'.join(status) + ('\n' if status else ''), encoding='utf-8')
|
||||
|
||||
|
||||
Reference in new issue
Block a user