"""Q16: the equip path -- callers of the itemState serializer.

Q15 found FUN_18012ee20: itemState code -> atom name, with
    1->free 2->inGame 5->0x1f8 6->offered 100->activeBadge 0x65->activeHomeKit
    0x66->activeAwayKit 0x67->activeBall 0x68->activeStadium 0xff->active
Whoever CALLS it with 0x64..0x68 is the equip path, and the code that picks which of
those five to pass must know the item's family.

Dump: every caller of FUN_18012ee20 in full, plus FUN_18012ddf0 (the club URL
builder) in full, plus FUN_18012ec50's caller chain context.

CONTROL: FUN_18012ddf0 must contain the five-way if/else on *(param_1+0x30) that
Q15 printed (0xa badge, 0xb kit, 0x15 stadium, 0x16 ball, else equippables). If the
full decompile lacks it, this is not the same function.
"""
import traceback

try:
    ents = {}
    for frm, typ, fn, ent in xrefs_to(0x18012EE20):
        if ent:
            ents[ent] = fn
    print("callers of FUN_18012ee20 (itemState->atom): %d -> %s" %
          (len(ents), ["%s(%#x)" % (v, k) for k, v in ents.items()]))
    for ent in sorted(ents):
        src = dec(ent)
        print("=" * 78)
        print("CALLER %s @%#x len=%d" % (ents[ent], ent, len(src)))
        print(src)
    print("=" * 78)
    src = dec(0x18012DDF0)
    print("CLUB URL BUILDER FUN_18012ddf0 len=%d" % len(src))
    print(src)
except Exception:
    traceback.print_exc()
