53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""Check the native class group against every class in the pinned 70334 export."""
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import struct
|
|
import subprocess
|
|
import tempfile
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
EXPORT = ROOT / 'docs/evidence/gameplay/class-specializations-70334.json'
|
|
PROFILE = ROOT / 'docs/FOREVER_SCHEMA_PROFILE.json'
|
|
|
|
|
|
def main():
|
|
data = EXPORT.read_bytes()
|
|
assert hashlib.sha256(data).hexdigest() == json.loads(PROFILE.read_bytes())['class_spec_export_sha256']
|
|
expected = {}
|
|
for row in json.loads(data):
|
|
cls, spec = row['ClassID'], row['ID']
|
|
if cls:
|
|
assert row['OrderIndex'] == 0 and cls not in expected and spec > 0
|
|
expected[cls] = struct.pack('<B6I', 0, spec, 1, spec, 0, 0, 0)
|
|
assert len(expected) == 9
|
|
|
|
with tempfile.TemporaryDirectory() as folder:
|
|
main_cpp = Path(folder) / 'groups.cpp'
|
|
main_cpp.write_text('''
|
|
#include "gateway/talents.hpp"
|
|
#include <cstdio>
|
|
int main() {
|
|
for (unsigned i = 0; i < 256; ++i) {
|
|
if (auto body = gateway::forever_class_talent_group(i)) {
|
|
std::printf("%u ", i);
|
|
for (unsigned byte : *body) std::printf("%02x", byte);
|
|
std::puts("");
|
|
}
|
|
}
|
|
}
|
|
''')
|
|
exe = Path(folder) / 'groups'
|
|
subprocess.run([os.environ.get('CXX', 'c++'), '-std=c++20', '-O1', '-ffunction-sections',
|
|
'-fdata-sections', '-I', ROOT / 'include', main_cpp, ROOT / 'src/talents.cpp',
|
|
ROOT / 'src/protocol.cpp', '-Wl,--gc-sections', '-o', exe], check=True)
|
|
lines = subprocess.check_output([exe], text=True).splitlines()
|
|
actual = {int(cls): bytes.fromhex(wire) for cls, wire in (line.split() for line in lines)}
|
|
assert len(actual) == len(lines) and actual == expected
|
|
print('PASS 9 stock class talent groups and 247 unsupported class values')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|