Files
aevolution/tools/world_snapshot_reference.py
T

27 lines
846 B
Python

"""Independent empty world-snapshot v1 fixture, derived from schemas/world-snapshot.md.
Prints C++ bytes only; never changes a golden file.
"""
import struct
payload = bytearray()
def put(value, code):
payload.extend(struct.pack('<' + code, value))
put(0x31504e5357564541, 'Q')
put(1, 'I')
put(132, 'I')
for value in [7, 9, 0]: # world, frame, seed
put(value, 'Q')
for value in [1, 1, 1, 16, 4, 0]: # versions, edge, slots, chunks
put(value, 'I')
for value in [0, 0, 0, 1000000, 1000000, 0, 0]:
put(value, 'Q')
put(0, 'I') # retained records
assert len(payload) == 124
checksum = 14695981039346656037
for byte in payload:
checksum = ((checksum ^ byte) * 1099511628211) & ((1 << 64) - 1)
put(checksum, 'Q')
for start in range(0, len(payload), 16):
print(', '.join(f'0x{b:02x}' for b in payload[start:start+16]) + ',')