Files
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

84 lines
3.8 KiB
Python

#!/usr/bin/env python3
"""Map source emote semantics against strictly extracted installed client DB2s."""
import argparse
import hashlib
import json
from pathlib import Path
from turtle_data import DBC
ROOT = Path(__file__).resolve().parents[1]
def generate(source, native):
animations = DBC(source / 'Emotes.dbc', 7)
texts = DBC(source / 'EmotesText.dbc', 19)
target = json.loads((native / 'Emotes-actual.json').read_text())
target_text = json.loads((native / 'EmotesText-actual.json').read_text())
mapped = {0: 0}
blocked = []
for row in animations.rows:
name = animations.string(row[1])
matches = [r for r in target if
(r['EmoteSlashCommand'], r['AnimID'], r['EmoteSpecProc'],
r['EmoteSpecProcParam']) == (name, row[2], row[4], row[5])]
same = [r for r in matches if r['ID'] == row[0]]
if len(same or matches) == 1:
mapped[row[0]] = (same or matches)[0]['ID']
else:
blocked.append(dict(id=row[0], name=name, reason='No unique semantic native animation/state match'))
text_map = {}
for row in texts.rows:
name = texts.string(row[1])
matches = [r for r in target_text if r['Name'] == name and
row[2] in mapped and r['EmoteID'] == mapped[row[2]]]
same = [r for r in matches if r['ID'] == row[0]]
if len(same or matches) == 1:
text_map[row[0]] = (same or matches)[0]['ID']
else:
blocked.append(dict(text_id=row[0], name=name, reason='No unique semantic native text-emote match'))
if len(set(text_map.values())) != len(text_map):
raise ValueError('Ambiguous reverse text-emote mapping')
header = '// Generated source/native emote semantic identities; unknown IDs are not guessed.\n#pragma once\n#include <cstdint>\nnamespace gateway::emote_profile {\nstruct Mapping {uint32_t source,native;};\n'
for name, mapping in (('Animations', mapped), ('Texts', text_map)):
header += 'inline constexpr Mapping ' + name + '[]={\n'
header += ''.join(f' {{{a},{b}}},\n' for a, b in sorted(mapping.items())) + '};\n'
header += '''constexpr uint32_t animation(uint32_t source) {
for(auto row:Animations)if(row.source==source)return row.native;
return 0;
}
constexpr bool has_animation(uint32_t source) {
for(auto row:Animations)if(row.source==source)return true;
return false;
}
constexpr uint32_t source_text(uint32_t native) {
for(auto row:Texts)if(row.native==native)return row.source;
return 0;
}
constexpr uint32_t native_text(uint32_t source) {
for(auto row:Texts)if(row.source==source)return row.native;
return 0;
}
}
'''
report = dict(kind='source-native-emote-semantic-profile', build='1.60.1.70334',
source_sha256={t: hashlib.sha256((source / (t + '.dbc')).read_bytes()).hexdigest()
for t in ('Emotes', 'EmotesText')},
native_sha256={t: hashlib.sha256((native / (t + '-actual.json')).read_bytes()).hexdigest()
for t in ('Emotes', 'EmotesText')},
animations=mapped, texts=text_map, blocked=blocked,
asset_payloads_or_playback_verified=False)
return header, report
if __name__ == '__main__':
p = argparse.ArgumentParser(description=__doc__)
p.add_argument('--source', type=Path, required=True)
p.add_argument('--native', type=Path, required=True)
p.add_argument('--header', type=Path, required=True)
p.add_argument('--report', type=Path, required=True)
a = p.parse_args()
header, report = generate(a.source, a.native)
a.header.write_text(header)
a.report.write_text(json.dumps(report, indent=2) + '\n')
print('Reviewed', len(report['animations']), 'animation/state and', len(report['texts']), 'text identities;', len(report['blocked']), 'explicit dependencies.')