import re
# 1. consumables panel provider: which type ids does mode 6 read?
c = dec(0x180043b90)
open("/tmp/gf_prov.c", "w").write(c)
print("### FUN_180043b90 provider len", len(c))
i = c.find("case 6")
print("--- case-6 region ---")
print(c[i-200:i+3000] if i > 0 else "case 6 NOT FOUND; switch text:\n" + "\n".join(
    l for l in c.splitlines() if "case" in l or "switch" in l))

# 2. who calls the /consumables/%s builder, /sets, /squadBuildingSets
for nm, a in (("/consumables/%s builder FUN_1801308c0", 0x1801308c0),
              ("/sets builder FUN_18017a980", 0x18017a980)):
    print("\n### callers of %s" % nm)
    for (fr, ty, fn, en) in xrefs_to(a):
        print("   %#x %-12s %s @%#x" % (fr, ty, fn, en))

# 3. the base URL used with those builders: decompile one caller each
print("\n### FUN_1801308c0 caller decompile")
xs = xrefs_to(0x1801308c0)
for (fr, ty, fn, en) in xs[:2]:
    if en:
        d = dec(en)
        print("--- %s @%#x len %d ---" % (fn, en, len(d)))
        print(d[:5000])
