Files
WoW-Hybrid-gateway/ops/quest_poi_60141_geometry.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

96 lines
7.0 KiB
Python

#!/usr/bin/env python3
"""Generate an explicitly approximate offline quest 60141 region candidate.
This does not send data to a client and does not establish native blob/flag
semantics. Each region is the outward integer envelope of one Source grid cell's
static creature anchors expanded only by their recorded wander radii.
"""
import argparse
import hashlib
import json
import math
from pathlib import Path
def _digest(path):
data=path.read_bytes()
return data,hashlib.sha256(data).hexdigest()
def generate(dataset,source):
if dataset.get('schema')!='source-quest-objective-locations-v2' or source.get('schema')!='tortoise-quest-location-snapshot-v2':
raise ValueError('expected finalized version-2 Source data')
qs=[q for q in dataset['quests'] if q['quest_id']==60141]
ss=[q for q in source['quests'] if q['id']==60141]
if len(qs)!=1 or len(ss)!=1:raise ValueError('quest identity')
q=qs[0];s=ss[0]
if q['holds'] or len(q['objectives'])!=1 or s['creature_or_go']!=[0]*4 or s['required_spells']!=[0]*4 or s['items']!=[51868,0,0,0] or s['item_count']!=[8,0,0,0]:
raise ValueError('source objective drift')
o=q['objectives'][0]
if o['kind']!='item' or (o['target'],o['required_count'],o['native_storage_index'],o['presentation_index'],o['candidate_presentation_id'])!=(51868,8,4,0,481128):
raise ValueError('objective identity')
sources=o['supported_sources']
if len(sources)!=1 or sources[0]['creature']!=524 or sources[0]['phase_quest_id'] or sources[0]['condition_id'] or sources[0]['evidence']!='direct_creature_loot':
raise ValueError('unsupported Source loot or template scope')
templates=[t for t in source['templates'] if t['creature']==524]
direct=[l for l in source['direct_loot_rows'] if l['creature']==524 and l['item']==51868 and l['min_or_ref']>0]
if len(templates)!=1 or templates[0]['phase_quest_id'] or len(direct)!=1 or direct[0]['condition'] or templates[0]['loot_id']!=direct[0]['loot_id']:
raise ValueError('Source template or loot evidence mismatch')
if any(p['creature']==524 for p in source['template_pools']):raise ValueError('Source template is pooled')
original={s['guid']:s for s in source['spawns']};seen=set();regions=[]
if len(original)!=len(source['spawns']):raise ValueError('duplicate raw Source GUID')
for cluster in o['clusters']:
pts=cluster['points']
if cluster['source_map']!=0 or not pts or cluster['point_count']!=len(pts):raise ValueError('cluster scope')
for p in pts:
if p['guid'] in seen or p['guid'] not in original:raise ValueError('duplicate or missing Source spawn')
seen.add(p['guid']);raw=original[p['guid']]
if p['source_map']!=raw['map'] or any(p[k]!=raw[k] for k in ('x','y','z')) or p['wander_radius']!=raw['wander']:
raise ValueError('Source point mismatch')
if p['spawn_pools'] or p['template_pools'] or p['events'] or p['spawn_flags'] or p['visibility_mod'] not in (0,0.0) or p['spawn_template_choices']!=[524,0,0,0]:
raise ValueError('unreviewed Source spawn condition')
if any(x['guid']==p['guid'] for x in source['spawn_pools']) or any(x['guid']==p['guid'] for x in source['events']):
raise ValueError('Source spawn pool or event mismatch')
if raw['entries']!=[524,0,0,0] or raw['spawn_flags'] or raw['visibility_mod'] not in (0,0.0):
raise ValueError('raw Source spawn condition mismatch')
if any(not math.isfinite(float(p[k])) for k in ('x','y','z','wander_radius')) or p['wander_radius']<0:
raise ValueError('invalid Source position')
cell=[math.floor(p['x']/128.0),math.floor(p['y']/128.0)]
if cluster['cell']!=cell or cluster['cell_size_world_units']!=128.0:raise ValueError('cluster membership mismatch')
x0=math.floor(min(p['x']-p['wander_radius'] for p in pts));x1=math.ceil(max(p['x']+p['wander_radius'] for p in pts))
y0=math.floor(min(p['y']-p['wander_radius'] for p in pts));y1=math.ceil(max(p['y']+p['wander_radius'] for p in pts))
z=round(sum(p['z'] for p in pts)/len(pts))
if any(v < -32768 or v > 32767 for v in (x0,x1,y0,y1,z)):raise ValueError('native integer field bound')
regions.append({'source_cell':cluster['cell'],'x_min':x0,'y_min':y0,'x_max':x1,'y_max':y1,'z':z,
'source_spawn_guids':sorted(p['guid'] for p in pts),'source_spawn_count':len(pts)})
expected={x['guid'] for x in source['spawns'] if 524 in x['entries'] and not (x['spawn_flags']&(0x02|0x80))}
if seen!=expected:raise ValueError('Source spawn coverage mismatch')
if not regions or len(regions)>128:raise ValueError('candidate region bound')
return {'quest_id':60141,'item_id':51868,'objective_index':0,'candidate_objective_id':481128,'storage_index':4,
'source_map':0,'candidate_uimap':1429,'regions':regions,
'geometry_rule':'Per 128-unit Source XY grid cell, envelope each static anchor by its recorded wander radius; floor minima and ceil maxima. Z is Python round of mean Source Z. No extra padding.',
'limitations':['Approximate derived envelopes, not Source-authored quest polygons.','Source world event, phase and current spawn presence are unverified.',
'POI objective/flags, UiMap assignment and native decoder/application are candidate semantics, not accepted behavior.']}
def main():
p=argparse.ArgumentParser(description=__doc__)
p.add_argument('--dataset',type=Path,required=True);p.add_argument('--source',type=Path,required=True)
p.add_argument('--expected-dataset-sha256',required=True);p.add_argument('--expected-source-sha256',required=True)
p.add_argument('--output-json',type=Path,required=True);p.add_argument('--output-header',type=Path,required=True)
a=p.parse_args();dataset_data,dataset_hash=_digest(a.dataset);source_data,source_hash=_digest(a.source)
if dataset_hash!=a.expected_dataset_sha256 or source_hash!=a.expected_source_sha256:raise ValueError('frozen Source input hash mismatch')
dataset=json.loads(dataset_data);source=json.loads(source_data)
if dataset['source_snapshot_sha256']!=source_hash:raise ValueError('dataset/source provenance mismatch')
out=generate(dataset,source);out['dataset_sha256']=dataset_hash;out['source_snapshot_sha256']=source_hash
a.output_json.parent.mkdir(parents=True,exist_ok=True);a.output_header.parent.mkdir(parents=True,exist_ok=True)
a.output_json.write_text(json.dumps(out,indent=2,sort_keys=True,allow_nan=False)+'\n')
lines=['#pragma once','#include "gateway/quest_poi_60141_prototype.hpp"','#include <array>',
'inline constexpr std::array<gateway::QuestPoi60141Region,%d> quest_poi_60141_regions{{'%len(out['regions'])]
lines+=[' {%d,%d,%d,%d,%d},'%(r['x_min'],r['y_min'],r['x_max'],r['y_max'],r['z']) for r in out['regions']]
lines+=['}};','']
a.output_header.write_text('\n'.join(lines))
print('Offline quest 60141 candidate geometry prepared')
if __name__=='__main__':main()