Files

34 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Write include/gateway/baked_hotfix_pushes.hpp from push digests of the shipped codec.
Usage: baked_hotfix_pushes.py <digests.txt> <DBCache.bin used for the bake> <out.hpp>
digests.txt: lines "push_id fnv64hex bytes" from push_digests.exe run on the same codec DLL.
Only pushes present in that DBCache (so their rows are in the baked DB2s) are listed.
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from dbcache_pushes import pushes
digests = {int(a): b for a, b, *_ in (l.split() for l in open(sys.argv[1]) if l.strip())}
cached = pushes(sys.argv[2])
# SpellAuraRestrictions is served as an overlay. Its FDID 981566 is outside
# the native bake, even after a client has cached all seven records.
overlay_only = {1294782901}
baked = sorted((digests.keys() & cached.keys()) - overlay_only)
pending = sorted(digests.keys() - set(baked))
rows = ''.join(f' {{{p}, 0x{digests[p]}ull}},\n' for p in baked)
Path(sys.argv[3]).write_text(f'''// Hotfix pushes whose rows are baked into the installed client DB2s (content
// stage). Generated by ops/db2-bake-20261123/baked_hotfix_pushes.py from the shipped
// codec's own reply digests. A push is left out of the login AvailableHotfixes only
// while its current reply digest equals the baked one, so any push changed after the
// bake is served again until it is re-baked.
#pragma once
#include <cstdint>
namespace gateway::baked_hotfix_pushes {{
struct Push {{ int32_t id; uint64_t digest; }};
inline constexpr Push Pushes[] = {{
{rows}}};
}}
''')
print('baked', len(baked), 'still pushed', pending)