367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
76 lines
5.4 KiB
Python
76 lines
5.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Controlled source GM visibility test of the shared native object-update path.
|
|
|
|
Actual private client and original GM commands only. Restores the original GM
|
|
visibility/whisper flags; no account permission, health, position or item edits.
|
|
Screenshots require review: successful packet observation never asserts opacity.
|
|
"""
|
|
import argparse,json
|
|
from pathlib import Path
|
|
import client_ui as ui
|
|
from client_session import Session
|
|
from local_tortoise import db
|
|
from native_engine_character_test import Controller,ROOT,local_listeners
|
|
from native_test_guard import require_local_turtle_ports,require_authenticated_turtle_realm,require_native_gameplay_policy,require_solo_test_character
|
|
from native_vendor_buy_test import inventory
|
|
from native_world_trace import WorldTrace
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--character',type=int,required=True);p.add_argument('--output',type=Path,required=True);a=p.parse_args();out=a.output.resolve()
|
|
if a.character!=4509 or out.suffix!='.json' or not out.is_relative_to(ROOT/'runtime') or out.exists() or not out.parent.is_dir():p.error('Require designated disposable character and new runtime report')
|
|
require_local_turtle_ports(local_listeners());c=Controller(int((ROOT/'runtime/native-client.pid').read_text()))
|
|
require_authenticated_turtle_realm(c.rpc('inspect-wire-account'));require_native_gameplay_policy(c.rpc('inspect-native-channel-policy'));require_solo_test_character(a.character,db('SELECT guid FROM tw_char.characters WHERE online<>0 ORDER BY guid;'))
|
|
state=lambda:db(f'SELECT health,power2,money,extra_flags FROM tw_char.characters WHERE guid={a.character};')
|
|
position=lambda:db(f'SELECT position_x,position_y,position_z,orientation FROM tw_char.characters WHERE guid={a.character};')
|
|
# LoadFromDB::SetGMVisible persists flags before later login-time social/
|
|
# whisper settings finish. Persist the live baseline before comparing it;
|
|
# a post-login saved row alone is not a live GM-state snapshot.
|
|
old=ui.KEY_DELAY
|
|
try:
|
|
with Session(c.pid) as s:
|
|
s.wait_world();ui.KEY_DELAY=.06;ui.key(s.d,'F1');s.macro('/s .save')
|
|
finally:ui.KEY_DELAY=old
|
|
before=state();flags=int(before.split('\t')[3]);items=inventory(a.character)
|
|
if flags&17!=17:raise RuntimeError('Require original GM-on/invisible baseline; no setup permissions changed')
|
|
r=dict(pid=c.pid,character=a.character,external_gateway_running=False,before_state=before,before_position=position(),restoration_pending=False,packet_path_observed=False,model_transparency_verified=False,ui_review_required=True)
|
|
def save():out.write_text(json.dumps(r,indent=2)+'\n');out.chmod(0o600)
|
|
old=ui.KEY_DELAY;save()
|
|
with WorldTrace(c) as trace:
|
|
with Session(c.pid) as s:
|
|
try:
|
|
s.wait_world();ui.KEY_DELAY=.06;ui.key(s.d,'F1')
|
|
r['restoration_pending']=True;save()
|
|
anchor=trace.bookmark()
|
|
s.macro('/s .gm visible on')
|
|
r['visible_update']=trace.wait(3,0x5e0000,5,after_index=anchor)
|
|
c.wait(lambda:int(state().split('\t')[3])==flags&~16,8)
|
|
s.shot(out.with_name(out.stem+'-visible.png'))
|
|
anchor=trace.bookmark()
|
|
s.macro('/s .gm visible off')
|
|
r['invisible_update']=trace.wait(3,0x5e0000,5,after_index=anchor)
|
|
# Capture immediately: the visual aura is distinct from the
|
|
# durable source GM visibility flag and may change afterward.
|
|
s.shot(out.with_name(out.stem+'-invisible.png'))
|
|
s.macro('/s .gm visible')
|
|
s.macro('/run local a=C_UnitAuras.GetPlayerAuraBySpellID(16380);print("GW presentation aura",a and a.spellId)')
|
|
s.shot(out.with_name(out.stem+'-diagnostic.png'))
|
|
pipe=c.rpc('inspect-engine-pipe');r.update(pipe_error=pipe['error'],pipe_closed=pipe['closed'],packet_path_observed=not pipe['error'] and not pipe['closed'])
|
|
except Exception as error:r['failure']=type(error).__name__+': '+str(error)
|
|
finally:
|
|
try:
|
|
if r['restoration_pending']:
|
|
s.wait_world();ui.key(s.d,'F1')
|
|
# Same Session retains/cancels a partial edit after a
|
|
# focus failure instead of submitting a truncated command.
|
|
if not int(state().split('\t')[3])&16:s.macro('/s .gm visible off')
|
|
s.macro('/s .whispers '+('on' if flags&4 else 'off'));s.macro('/s .save')
|
|
c.wait(lambda:state()==before,8)
|
|
if inventory(a.character)!=items:raise RuntimeError('Unexpected inventory change; preserve fixture journal')
|
|
r.update(restoration_pending=False,after_state=state(),after_position=position(),inventory_unchanged=True)
|
|
except Exception as error:r['restoration_error']=type(error).__name__+': '+str(error)
|
|
ui.KEY_DELAY=old
|
|
r.update(trace.report());save()
|
|
print(json.dumps({k:r.get(k) for k in ('pid','packet_path_observed','model_transparency_verified','restoration_pending','inventory_unchanged','lost_metadata_rows','observer_error','failure','restoration_error')}))
|
|
return 0 if r['packet_path_observed'] and not r['restoration_pending'] and not r.get('failure') and not trace.error else 2
|
|
if __name__=='__main__':raise SystemExit(main())
|