367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
83 lines
4.4 KiB
Python
83 lines
4.4 KiB
Python
"""Source ordinary-body textures with exact original native visual witnesses.
|
|
|
|
Octo 0x478ad0 dispatches attachment slots separately; ordinary armor consumes
|
|
Texture[0..7], not ModelName. Armor subclass remains item metadata, whereas
|
|
these visual controls are witnessed independently of armor's stat category.
|
|
"""
|
|
from copy import deepcopy
|
|
|
|
POLICY = 'source-ordinary-body-exact-native-visual-witness-v1'
|
|
BODY_INVENTORIES = frozenset((4, 5, 6, 7, 8, 9, 10, 19, 20))
|
|
|
|
|
|
def body_contract(source):
|
|
if (source.get('source_class') != 4 or
|
|
source.get('inventory_type') not in BODY_INVENTORIES):
|
|
raise ValueError('Source ordinary-body inventory required')
|
|
c = source['composition']
|
|
if (len(c['Texture']) != 8 or not any(c['Texture']) or
|
|
any(not isinstance(x, str) for x in c['Texture'] + c['ModelName'] + c['ModelTexture']) or
|
|
len(c['ModelName']) != 2 or len(c['ModelTexture']) != 2 or
|
|
c['Flags'] != [0] or c['HelmetGeosetVisID'] != [0, 0] or
|
|
len(c['GeosetGroup']) != 3 or
|
|
any(type(x) is not int or x < 0 for x in c['GeosetGroup'])):
|
|
raise ValueError('Unreviewed source body visual fields')
|
|
return (source['inventory_type'], tuple(c['GeosetGroup']),
|
|
tuple(i for i, name in enumerate(c['Texture']) if name))
|
|
|
|
|
|
def review_binding(binding, own, native, basics, sparse, item, item_sparse, item_sparse_id):
|
|
proof = binding.get('native_body_witness')
|
|
if not isinstance(proof, dict) or proof.get('policy') != POLICY:
|
|
raise ValueError('Explicit ordinary-body witness policy required')
|
|
source = proof['source']
|
|
contract = body_contract(source)
|
|
ident = binding['item_id']
|
|
if (source['item_id'] != ident or item['ID'] != ident or item_sparse_id != ident or
|
|
item['ClassID'] != source['source_class'] or
|
|
item['SubclassID'] != source['source_subclass'] or
|
|
item['InventoryType'] != contract[0] or
|
|
item_sparse['InventoryType'] != contract[0] or
|
|
item_sparse['Display_lang'] != source['source_name'] or
|
|
binding['source_display_id'] != source['source_display_id']):
|
|
raise ValueError('Published source body identity differs')
|
|
if (own['ModelResourcesID'] != [0, 0] or own['ModelMaterialResourcesID'] != [0, 0] or
|
|
own['GeosetGroup'] != list(contract[1]) + [0, 0, 0] or
|
|
own['Flags'] != 0 or own['HelmetGeosetVis'] != [0, 0]):
|
|
raise ValueError('Source body display geometry differs')
|
|
displays = {r['ID']: r for r in native['ItemDisplayInfo']}
|
|
apps = {r['ID']: r for r in native['ItemAppearance']}
|
|
links = {r['ID']: r for r in native['ItemModifiedAppearance']}
|
|
types = set()
|
|
witnesses = proof.get('witnesses', [])
|
|
if not witnesses:
|
|
raise ValueError('Original native body witness required')
|
|
seen = set()
|
|
for w in witnesses:
|
|
src = w['source']
|
|
if body_contract(src) != contract:
|
|
raise ValueError('Source witness slot, sections or geosets differ')
|
|
b = basics.get(src['item_id']); s = sparse.get(src['item_id'])
|
|
link = links.get(w['native_link_id']); app = apps.get(w['native_appearance_id'])
|
|
d = displays.get(w['native_display_id'])
|
|
if (not b or not s or not link or not app or not d or
|
|
b['ClassID'] != 4 or b['SubclassID'] != src['source_subclass'] or
|
|
b['InventoryType'] != contract[0] or s['InventoryType'] != contract[0] or
|
|
s['Display_lang'] != src['source_name'] or
|
|
link['ItemID'] != src['item_id'] or link['ItemAppearanceModifierID'] != 0 or
|
|
link['ItemAppearanceID'] != app['ID'] or app['TransmogPlayerConditionID'] != 0 or
|
|
app['ItemDisplayInfoID'] != d['ID']):
|
|
raise ValueError('Original native body witness identity differs')
|
|
if w['native_link_id'] in seen:
|
|
raise ValueError('Duplicate original native witness')
|
|
seen.add(w['native_link_id'])
|
|
ignored = {'ID', 'ModelResourcesID'}
|
|
if set(own) != set(d) or any(own[k] != d[k] for k in own if k not in ignored):
|
|
raise ValueError('Native body visual controls differ')
|
|
if d['ModelResourcesID'] != [0, 0]:
|
|
raise ValueError('Attached native model is not a body texture witness')
|
|
types.add(app['DisplayType'])
|
|
if len(types) != 1:
|
|
raise ValueError('Native body DisplayType is ambiguous')
|
|
return next(iter(types)), len(witnesses)
|