Files

29 lines
1.6 KiB
Python

"""Generate include/gateway/item_auction_subclass.hpp: native (retail Classic) auction subclass for every
Turtle consumable (class 0) and trade good (class 7). Source of truth: the pristine Forever base client
Item.db2 (forever-base-item-class.tsv: ID, ClassID, SubclassID, InventoryType) vs tw_world.item_template
(tw-world-item-class.tsv: entry, class, subclass, inventory_type, quality, required_level).
Rule: base class == Turtle class -> base subclass; Turtle trade good 1..3 (Parts/Explosives/Devices) kept;
everything else -> Other (consumable 8, trade goods 11)."""
from pathlib import Path
H=Path(__file__).resolve().parent
base={}
for l in open(H/'forever-base-item-class.tsv'):
i,c,s,t=l.split('\t');base[int(i)]=(int(c),int(s))
rows=[]
for l in open(H/'tw-world-item-class.tsv'):
e,c,s,*_=map(int,l.split('\t'))
if c not in (0,7):continue
b=base.get(e)
if b and b[0]==c and not (c==0 and b[1]==0) and not (c==7 and b[1]==0):sub=b[1]
elif c==7 and s in (1,2,3):sub=s
else:sub=8 if c==0 else 11
rows.append((e,sub))
rows.sort()
out=['// Generated by ops/ah-subclass/gen.py — do not edit.','#pragma once','#include <cstdint>','namespace gateway {',
'struct ItemAuctionSubclass {uint32_t item;uint8_t subclass;};',f'inline constexpr ItemAuctionSubclass item_auction_subclasses[{len(rows)}]={{']
for i in range(0,len(rows),8):out.append(' '+''.join(f'{{{e},{s}}},' for e,s in rows[i:i+8]))
out+=['};','}','']
(H.parents[1]/'include/gateway/item_auction_subclass.hpp').write_text('\n'.join(out))
from collections import Counter
print(len(rows),sorted(Counter((e//1 and 0,s) for e,s in rows).items()))