40 lines
1.9 KiB
Python
40 lines
1.9 KiB
Python
"""Recover native Item identities from the full public server catalogue.
|
|
|
|
The Item record owns the output icon independently of ItemSparse metadata.
|
|
Only source display tokens with verified installed or staged FDIDs are usable.
|
|
"""
|
|
from item_basic_compat import DEFAULTS, REVIEWED_SUBCLASSES, TABLE, encode
|
|
from item_sparse_compat import native_item_material
|
|
|
|
|
|
def catalogue_rows(templates, occupied, display_tokens, icon_fids):
|
|
rows = []
|
|
held = []
|
|
for proto in sorted(templates, key=lambda v: v['entry']):
|
|
ident = proto['entry']
|
|
if ident <= 0 or ident in occupied:
|
|
continue
|
|
display = proto['display_id']
|
|
token = display_tokens.get(display)
|
|
if display and token is None:
|
|
held.append((ident, 'missing source display'))
|
|
if token and token not in icon_fids:
|
|
held.append((ident, 'missing source icon binding'))
|
|
cls, sub = proto['class'], proto['subclass']
|
|
# Octo food bags use subclass 8, which denotes inscription in 70334.
|
|
# Use the native cooking/food and tackle bag subclasses for these cases.
|
|
if cls == 1 and proto['inventory_type'] == 18 and sub in (8, 9):
|
|
sub = 10 if sub == 8 else 9
|
|
elif sub not in REVIEWED_SUBCLASSES.get(cls, ()):
|
|
held.append((ident, 'unmapped source subclass'))
|
|
continue
|
|
row = dict(DEFAULTS, ID=ident, ClassID=cls, SubclassID=sub,
|
|
Material=native_item_material(proto), InventoryType=proto['inventory_type'],
|
|
SheatheType=proto['sheath'], AmmunitionType=proto['ammo_type'],
|
|
IconFileDataID=icon_fids.get(token, 0))
|
|
wire = encode(row)
|
|
rows.append(dict(table='Item', table_hash=hex(TABLE), id=ident, action='add',
|
|
wire_hex=wire.hex(), source_display_id=display, icon_token=token,
|
|
icon_fdid=row['IconFileDataID']))
|
|
return rows, held
|