77 lines
4.6 KiB
Python
77 lines
4.6 KiB
Python
"""#75 (2026-11-26): in SD mode the client shows the wrong skin for many Turtle skin values. Turtle/Octo order their player
|
|
skins differently from Blizzard's Classic lists (Turtle exposed NPC skins, e.g. forest troll, Death Knight, Grimtotem).
|
|
The HD conversion profile maps Turtle value v to native HD choice v; ChrModelAltVariantChoice then sends that HD choice
|
|
to native SD choice v, which is not Octo's texture for v (Troll 6-20, Gnome 5-8, Tauren 19/20/21, ...).
|
|
|
|
Rule over every race/sex/value of Octo CharSections skins (BaseSection 0, variation 0; flags-0 rows in ColorIndex order,
|
|
then flags-1 rows appended, the way Turtle numbers shop skins: Tauren male 21 = Grimtotem): take the HD choice the
|
|
profile converts v to, the SD option its variant option targets, and the SD choice in that option whose base skin texture
|
|
(target 1) has Octo's texture name. Point the variant row there. Octo textures no SD choice carries are listed in
|
|
needs-import.json (step 2 imports them).
|
|
|
|
Usage: octo_sd_skins.py <dump dir> <CharSections.octo.tsv> <profile.hpp> <listfile> <out dir>"""
|
|
import collections, json, re, sys
|
|
from pathlib import Path
|
|
|
|
|
|
def rows(path):
|
|
for line in open(path, encoding='utf-8', errors='replace'):
|
|
f = line.rstrip('\n').split('\t')
|
|
yield dict(x.split('=', 1) for x in f[1:] if '=' in x)
|
|
|
|
|
|
def norm(name):
|
|
return name.lower().replace('\\', '/').split('/')[-1].replace(' ', '')
|
|
|
|
|
|
def main(dump, octo_cs, profile, listfile, out):
|
|
d = Path(dump); out = Path(out); out.mkdir(parents=True, exist_ok=True)
|
|
name = {}
|
|
for line in open(listfile, encoding='utf-8', errors='replace'):
|
|
a, _, b = line.rstrip('\n').partition(';')
|
|
if b.startswith('character/'): name[int(a)] = norm(b)
|
|
mat = {int(r['ID']): r for r in rows(d / 'ChrCustomizationMaterial.tsv')}
|
|
tfd = {}
|
|
for r in rows(d / 'TextureFileData.tsv'): tfd.setdefault(int(r['MaterialResourcesID']), int(r['FileDataID']))
|
|
base = {}
|
|
for r in rows(d / 'ChrCustomizationElement.tsv'):
|
|
m = int(r['ChrCustomizationMaterialID'])
|
|
if m in mat and r['RelatedChrCustomizationChoiceID'] == '0' and mat[m]['ChrModelTextureTargetID'] == '1':
|
|
base.setdefault(int(r['ChrCustomizationChoiceID']), name.get(tfd.get(int(mat[m]['MaterialResourcesID'])), ''))
|
|
choice_opt = {int(r['ID']): int(r['ChrCustomizationOptionID']) for r in rows(d / 'ChrCustomizationChoice.tsv')}
|
|
by_opt = collections.defaultdict(dict)
|
|
for c, o in choice_opt.items():
|
|
if c in base: by_opt[o].setdefault(base[c], c)
|
|
vopt = {int(r['ID']): (int(r['SourceChrCustomizationOptionID']), int(r['VariantChrCustomizationOptionID'])) for r in rows(d / 'ChrModelAltVariantOption.tsv')}
|
|
src_vo = {s: (i, v) for i, (s, v) in vopt.items()}
|
|
vchoice = {int(r['SourceChrCustomizationChoiceID']): r for r in rows(d / 'ChrModelAltVariantChoice.tsv')}
|
|
conv = {}
|
|
for m in re.finditer(r'\{(\d+),(\d+),(\d+),1,(\d+),(\d+),', open(profile).read()):
|
|
_, r, s, v, c = map(int, m.groups()); conv.setdefault((r, s, v), c)
|
|
seq = collections.defaultdict(list)
|
|
cs = [r for r in rows(octo_cs) if r.get('BaseSection') == '0' and r.get('VariationIndex') == '0']
|
|
for flag in ('0', '1'):
|
|
for r in sorted((r for r in cs if r['Flags'] == flag), key=lambda r: int(r['ColorIndex'])):
|
|
seq[(int(r['RaceID']), int(r['SexID']))].append([norm(t) for t in r['TextureName'].split(',')[:2]])
|
|
sets, need, same = [], [], 0
|
|
for (race, sex), lst in sorted(seq.items()):
|
|
if race > 8: continue # Goblin/High Elf SD rows come from sd_race_customization.py
|
|
for v, (want, extra) in enumerate(lst):
|
|
hd = conv.get((race, sex, v))
|
|
if not hd or hd not in vchoice: continue
|
|
vo, sd_opt = src_vo[choice_opt[hd]]
|
|
cur = int(vchoice[hd]['VariantChrCustomizationChoiceID'])
|
|
hit = by_opt[sd_opt].get(want)
|
|
if hit is None:
|
|
need.append(dict(race=race, sex=sex, value=v, hd_choice=hd, sd_option=sd_opt, variant_row=int(vchoice[hd]['ID']),
|
|
current=cur, octo_base=want, octo_extra=extra)); continue
|
|
if hit == cur: same += 1; continue
|
|
sets.append(dict(ID=int(vchoice[hd]['ID']), VariantChrCustomizationChoiceID=hit))
|
|
print(race, sex, v, 'hd', hd, base.get(cur), '->', want, file=sys.stderr)
|
|
(out / 'set-ChrModelAltVariantChoice.json').write_text(json.dumps(sets, indent=1))
|
|
(out / 'needs-import.json').write_text(json.dumps(need, indent=1))
|
|
print(f'remap {len(sets)} keep {same} needs-import {len(need)}', file=sys.stderr)
|
|
|
|
|
|
if __name__ == '__main__': main(*sys.argv[1:6])
|