883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
96 lines
5.4 KiB
Python
96 lines
5.4 KiB
Python
"""Only the new67 Source dark-water attribute boundary; reuse completed20."""
|
|
import hashlib
|
|
import json
|
|
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_chunk,_adt_split_records,adt_root_flat_ocean_candidate
|
|
|
|
J=Path('runtime/rea-system-jobs-20261022/terrain-liquid-closure-20261025')
|
|
OUT=J/'private-Deep-Ocean67-ROOT';OUT.mkdir(exist_ok=True)
|
|
water=json.loads((J/'legacy139-water-operand-leaves.json').read_text())['rows']
|
|
selected=[r for r in water if r['all_blocks_original_ocean_depth_profile_candidate']
|
|
and all(set(map(int,b['Source_cell_flag_values']))<={15,65,193} for b in r['blocks'])
|
|
and any('193' in b['Source_cell_flag_values'] for b in r['blocks'])]
|
|
assert len(selected)==67
|
|
|
|
|
|
def encode(rows):return b''.join(_adt_split_chunk(t,d)+x for t,d,x in rows)
|
|
|
|
|
|
def verify(raw,new,expected):
|
|
before,after=_adt_split_records(raw),_adt_split_records(new)
|
|
h2o=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 ('MCNK','MHDR')]==[
|
|
(t,d,x) for t,d,x in after if t not in ('MCNK','MHDR','MH2O')]
|
|
ha=next(d for t,d,x in before if t=='MHDR');hb=next(d for t,d,x in after if t=='MHDR')
|
|
assert ha[:40]+ha[44:]==hb[:40]+hb[44:]
|
|
sourceblocks={tuple(b['cell']):b for b in expected['blocks']}
|
|
ac=[d for t,d,x in before if t=='MCNK'];bc=[d for t,d,x in after if t=='MCNK']
|
|
assert len(ac)==len(bc)==256
|
|
deep_cells=0
|
|
for a,b in zip(ac,bc):
|
|
wa,wb=struct.unpack_from('<32I',a),struct.unpack_from('<32I',b)
|
|
assert wb[0]==wa[0]&~0x3c and wb[24:26]==(0,0)
|
|
assert all(wa[i]==wb[i] for i in range(1,32) if i not in (22,24,25,29))
|
|
ca,cb=_adt_split_records(a[128:]),_adt_split_records(b[128:])
|
|
assert [(t,d,x) for t,d,x in ca if t!='MCLQ']==cb
|
|
x,y=wa[1:3];offset,count,attrs=struct.unpack_from('<3I',h2o,(y*16+x)*12)
|
|
expectedblock=sourceblocks.get((x,y))
|
|
if expectedblock is None:
|
|
assert (offset,count,attrs)==(0,0,0)
|
|
continue
|
|
assert count==1
|
|
source=next(d for t,d,x in ca if t=='MCLQ')
|
|
flags=source[656:720]
|
|
exists=int.from_bytes(bytes.fromhex(expectedblock['wet_bitmap_hex']),'little')
|
|
# Exact Source0x80 wet-cell predicate, not a material/name mapping.
|
|
expecteddeep=sum(1<<n for n,v in enumerate(flags) if v&0x80)&exists
|
|
fish,deep=struct.unpack_from('<QQ',h2o,attrs)
|
|
assert fish==exists and deep==expecteddeep and not deep&~exists
|
|
typ,lvf,lo,hi,ox,oy,w,h,bits,vertices=struct.unpack_from('<HHffBBBBII',h2o,offset)
|
|
assert (typ,lvf,lo,hi,ox,oy,w,h)==(2,42,0.,0.,0,0,8,8)
|
|
assert struct.unpack_from('<Q',h2o,bits)[0]==exists
|
|
assert h2o[vertices:vertices+81]==bytes.fromhex(expectedblock['depth_bytes_hex'])
|
|
deep_cells+=deep.bit_count()
|
|
assert deep_cells>0
|
|
return deep_cells
|
|
|
|
|
|
progress=J/'Deep67-completed-candidate-rows.jsonl'
|
|
rows=[json.loads(l) for l in progress.read_text().splitlines()] if progress.exists() else []
|
|
done={r['source_reference'] for r in rows}
|
|
for row in selected:
|
|
if row['source_reference'] in done:continue
|
|
raw=Path(row['input_ROOT']).read_bytes();new,audit=adt_root_flat_ocean_candidate(raw)
|
|
cells=verify(raw,new,row);filename=OUT/(Path(row['source_reference']).stem+'.root.adt');filename.write_bytes(new)
|
|
result=dict(source_reference=row['source_reference'],input_ROOT=row['input_ROOT'],output_ROOT=str(filename),
|
|
bytes=len(new),sha256=hashlib.sha256(new).hexdigest(),dark_wet_quad_count=cells,audit=audit)
|
|
rows.append(result)
|
|
with progress.open('a') as stream:stream.write(json.dumps(result,separators=(',',':'))+'\n')
|
|
|
|
sample=selected[0];top=_adt_split_records(Path(sample['input_ROOT']).read_bytes())
|
|
ci=next(i for i,(t,d,x) in enumerate(top) if t=='MCNK' and struct.unpack_from('<I',d)[0]&0x3c)
|
|
cell=top[ci][1];children=_adt_split_records(cell[128:]);bi=next(i for i,r in enumerate(children) if r[0]=='MCLQ')
|
|
block=children[bi][1];wet=next(i for i,v in enumerate(block[656:720]) if v in (65,193))
|
|
for flag in (33,161,225,197):
|
|
changedblock=bytearray(block);changedblock[656+wet]=flag
|
|
changedchildren=list(children);changedchildren[bi]=('MCLQ',bytes(changedblock),b'')
|
|
changed=list(top);changed[ci]=('MCNK',cell[:128]+encode(changedchildren),b'')
|
|
try:adt_root_flat_ocean_candidate(encode(changed))
|
|
except ValueError:pass
|
|
else:raise AssertionError('Nonfishable/unknown high-bit Source attribute accepted')
|
|
|
|
report=dict(status='PASS_NEW67_FISHABLE_DARK_OCEAN_ATTRIBUTE_BOUNDARY',flat_Ocean_denominator=89,
|
|
prior20_reused_without_rerun=True,new_67_passed=len(rows),nonfishable_held=2,
|
|
complete_fishable_flat_Ocean_family=87,dry_previous=562,remaining_liquid=357,
|
|
dark_wet_quad_count=sum(r['dark_wet_quad_count'] for r in rows),
|
|
target_profile=dict(LiquidType=2,LVF_field=42,Fishable='Source wet bitmap',Deep='Source0x80 wet-cell bitmap'),
|
|
PBR1250_used_as_material_identity=False,refusals=4,
|
|
all_other_ROOT_payloads_and_fields_byte_exact=True,Source_geometry_alpha_SDK_tests_repeated=False,
|
|
client_Deep_fatigue_activation_or_render_acceptance=False,publishable=False)
|
|
(J/'Deep67-focused-check.json').write_text(json.dumps(report,indent=2)+'\n')
|
|
(J/'Deep67-candidate-manifest.json').write_text(json.dumps(dict(status=report['status'],rows=rows),indent=2)+'\n')
|
|
print(json.dumps(report))
|