883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
69 lines
4.0 KiB
Python
69 lines
4.0 KiB
Python
"""Only newly retained62 liquid-role integration; no prior terrain tests."""
|
|
import hashlib
|
|
import json
|
|
import math
|
|
from pathlib import Path
|
|
import struct
|
|
import sys
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from map_asset_preflight import _adt_split_records,adt_root_flat_ocean_candidate
|
|
|
|
J=Path('runtime/rea-system-jobs-20261022/continent-Source-only62-20261025')
|
|
OUT=J/'private-new-liquid-ROOT';OUT.mkdir(exist_ok=True)
|
|
manifest=json.loads((J/'Source-only62-candidate-manifest.json').read_text())
|
|
inventory={r['source_reference']:r for r in json.loads((J/'qualified-new62/preflight-checkpoint.json').read_text())}
|
|
rows=[];held=[];native_instances=dark_quads=0
|
|
for row in manifest['results']:
|
|
path=row['source_reference']
|
|
if inventory[path]['terrain']['MH2O_present']:
|
|
held.append(dict(source_reference=path,reason='Existing Source MH2O role retained, not replaced by legacy Ocean.'))
|
|
continue
|
|
raw=Path(row['files']['root']['file']).read_bytes()
|
|
try:new,audit=adt_root_flat_ocean_candidate(raw)
|
|
except ValueError as exc:
|
|
held.append(dict(source_reference=path,reason=str(exc)))
|
|
continue
|
|
before,after=_adt_split_records(raw),_adt_split_records(new)
|
|
liquid=next(d for t,d,x in after if t=='MH2O')
|
|
assert [(t,d,x) for t,d,x in before if t not in ('MHDR','MCNK')]==[
|
|
(t,d,x) for t,d,x in after if t not in ('MHDR','MCNK','MH2O')]
|
|
cells=0
|
|
for old,encoded in zip([d for t,d,x in before if t=='MCNK'],[d for t,d,x in after if t=='MCNK']):
|
|
a,b=struct.unpack_from('<32I',old),struct.unpack_from('<32I',encoded)
|
|
assert b[0]==a[0]&~0x3c and b[24:26]==(0,0)
|
|
assert all(a[i]==b[i] for i in range(1,32) if i not in (22,24,25,29))
|
|
ca,cb=_adt_split_records(old[128:]),_adt_split_records(encoded[128:])
|
|
assert [(t,d,x) for t,d,x in ca if t!='MCLQ']==cb
|
|
x,y=a[1:3];offset,count,attrs=struct.unpack_from('<3I',liquid,(y*16+x)*12)
|
|
if not a[0]&0x3c:
|
|
assert (offset,count,attrs)==(0,0,0);continue
|
|
source=next(d for t,d,x in ca if t=='MCLQ');assert count==1
|
|
# Original Source per-quad existence and dark-water predicates.
|
|
exists=deep=0
|
|
for n,flag in enumerate(source[656:720]):
|
|
if flag&15==15:continue
|
|
sy,sx=divmod(n,8);vertices=(sy*9+sx,sy*9+sx+1,(sy+1)*9+sx,(sy+1)*9+sx+1)
|
|
heights=[struct.unpack_from('<f',source,12+v*8)[0] for v in vertices]
|
|
if any(not math.isfinite(h) or abs(h)>=1e9 for h in heights):continue
|
|
assert flag in (65,193) and all(h==0 for h in heights)
|
|
exists|=1<<n
|
|
if flag&128:deep|=1<<n
|
|
typ,lvf,lo,hi,ox,oy,w,h,bits,depths=struct.unpack_from('<HHffBBBBII',liquid,offset)
|
|
assert (typ,lvf,lo,hi,ox,oy,w,h)==(2,42,0.,0.,0,0,8,8)
|
|
assert struct.unpack_from('<QQ',liquid,attrs)==(exists,deep)
|
|
assert struct.unpack_from('<Q',liquid,bits)[0]==exists
|
|
assert liquid[depths:depths+81]==bytes(source[8+v*8] for v in range(81))
|
|
cells+=1;dark_quads+=deep.bit_count()
|
|
assert cells==audit['Ocean_cells'];native_instances+=cells
|
|
filename=OUT/(Path(path).stem+'.root.adt');filename.write_bytes(new)
|
|
rows.append(dict(source_reference=path,output_ROOT=str(filename),bytes=len(new),sha256=hashlib.sha256(new).hexdigest(),audit=audit))
|
|
assert len(rows)+len(held)==62
|
|
report=dict(status='PASS_NEW_SOURCE_ONLY62_LIQUID_ROLE_INTEGRATION',Source_new_tiles=62,
|
|
admitted_whole_Ocean_tiles=len(rows),held_tiles=len(held),native_instances=native_instances,
|
|
dark_wet_quads=dark_quads,Source_geometry_alpha_or_nativeSDK_checks_repeated=False,
|
|
existing20_67_or562_checks_repeated=False,all_nonliquid_ROOT_payloads_and_fields_preserved=True,
|
|
new_production_changes=False,actual_client_or_9344_asset_acceptance=False)
|
|
(J/'new62-liquid-focused-check.json').write_text(json.dumps(report,indent=2)+'\n')
|
|
(J/'new62-liquid-candidate-manifest.json').write_text(json.dumps(dict(status=report['status'],rows=rows,held=held),indent=2)+'\n')
|
|
print(json.dumps(report))
|