
    UHj                    X   d Z ddlmZ ddlZddlZddlZddlmZ  ee      j                         j                  d   Zedz  Zddd	d
gg dddddddgg ddddddgg dddddddgg ddddd g d!g d"d#dd$d%g d&g d'd(dgZd0d)Zd0d*Zd1d+Zd1d,Zd2d-Zd3d.Zed/k(  r e        yy)4z;Summarize object+0x61 consumer patterns around opcode 0x24.    )annotationsN)Path   outzlinked object draw/copyz0x0040cc6d..0x0040cc8f
0x0040cc6d
0x0040cc8f)6mov cl,[current+0x61]; object = runtimeObjectTable[cl]ztest linkedObject+0x62 bit 0x20zKcall 0x00402360 with current object+0x88 and linked object resource pointerziConsumes object+0x61 as another runtime object index; no stream pointer or scene record write is visible.)namerangerefsevidencerouteImpactzlinked object replacementz0x0040d006..0x0040d02d
0x0040d006
0x0040d02d)r	   ztest linkedObject+0x62 bit 0x80z<call 0x00433aca and write returned byte back to current+0x61zxUpdates the linked object index when the target object is flagged; this is object state maintenance, not leaf selection.zcollision/action mask testz0x0040d3af..0x0040d4d8
0x0040d3af)zBcurrent object can be replaced by runtimeObjectTable[current+0x61]zreads selected object+0x04 modez2tests object+0x5c masks and sets global 0x0055a1b8zbTests object action/collision masks and advances the current stream by +4 on the non-trigger path.zobject spawn/flag managementz0x0040d5da..0x0040dded
0x0040d5da
0x0040dcc7)z2uses object+0x61 to select a linked runtime objectzDchecks and writes object+0x5b, object+0x5c, object+0x60, object+0x62z8some branches replace context+0x40 with dword [stream+4]zCan branch the current script stream, but through the active handler's stream operand, not through the save-selector leaf table.zstatus sync helperz0x0040de28..0x0040ef09)
0x0040de28
0x0040e240
0x0040eaf4
0x0040ee6c
0x0040ef09)zFselects linked runtime objects through runtimeObjectTable[object+0x61]zHcopies object flags/position/status fields into other object-side tableszOdoes not directly reference map1_01a, map2_02d, or save-selector leaf addresseszdRuntime object synchronization; useful for VM semantics, weak evidence for map transition promotion.zgeneric object helpersz0x004334a3..0x004355f0)
0x004334a3
0x00433ad8
0x00433afe
0x00433b0b
0x00433db3
0x00433efe
0x004355e5
0x004355f0)zJhelper routines read/write object+0x61 while scanning runtime object slotszNcalled by several object VM handlers including opcode 0x24 mode 0 support codez@acts on object relationships rather than field-map scene recordszcConfirms object+0x61 is a general linked-object slot, not a dedicated save-selector route selector.c                V    | dz  }t        j                  |j                  d            S )N$save_selector_object_field_refs.jsonutf-8encoding)jsonloads	read_text)out_dirpaths     G/home/exedev/hwanse/tools/summarize_save_selector_object61_consumers.pyload_object_refsr,   T   s'    ;;D::dnngn677    c           
     2   t        |       }|j                  d      xs g D ci c]  }|j                  d      | }}g }t        D ]>  }|d   D cg c]  }|j                  ||dd       }}|j                  i |d|i       @ d}d||dS c c}w c c}w )	Nobject61RefsvaHexr   T)r0   missingaO  The opcode 0x24 mode 1 write to object+0x61 feeds runtime object-link consumers. Those consumers dereference runtimeObjectTable[object+0x61] or maintain object flags; they do not provide a direct map1_01a->map2_02d save-selector leaf jump. Continue route work from branch-state/stream control-flow evidence, not from object+0x61 alone.r"   )sourcegroups
conclusion)r,   getGROUPSappend)	r)   object_refsrow
refs_by_varowsgrouprefr   r4   s	            r+   build_summaryr>   Y   s    "7+K3>??>3R3XVXYC#'''"C'YJYD 5PUV\P]^
scd$CD^^3u3nd345	&  9   Z _s   BBc                   ddd| j                  d       dd| j                  d       ddd	g}| j                  d
      xs g D ]  }dj                  d |j                  d      xs g D              }dj                  d |j                  d      xs g D              }|j                  d|j                  d       d|j                  d       d| d| d|j                  d       d        |j                  d       dj                  |      S )Nz%# Save Selector object+0x61 Consumers z- source: `r2   `z- conclusion: r4   z2| group | range | refs | evidence | route impact |z| --- | --- | --- | --- | --- |r3   , c              3  F   K   | ]  }d |j                  d       d   yw)rA   r0   N)r5   .0r9   s     r+   	<genexpr>zmarkdown.<locals>.<genexpr>x   s#     \S1SWWW-.a0\   !r/   <br>c              3  F   K   | ]  }t        j                  |        y wN)htmlescaperE   items     r+   rF   zmarkdown.<locals>.<genexpr>y   s     YTt{{40YrG   r   z| r
   z | `r   z` | z | r   z |
)r5   joinr7   )summarylinesr<   r   r   s        r+   markdownrS   m   s   /

gkk(+,A.
\234
<)E X&," 
yy\EIIn<U<[Y[\\;;YUYYz=R=XVXYY6"#4		'(:';4vS
RUV[V_V_`mVnUooqr	

 
LL99Ur-   c                F   dj                  d | j                  d      xs g D              }dj                  ddddt        j                  t	        | j                  d                   d	d
t        j                  t	        | j                  d                   dd|dg      S )NrO   c              3    K   | ]  }d t        j                  t        |j                  d                   dt        j                  t        |j                  d                   ddj	                  d |j                  d      xs g D               dd	j	                  d
 |j                  d      xs g D               dt        j                  t        |j                  d                   d  yw)z<tr><td>r
   z</td><td><code>r   z</code></td><td>rB   c           	   3     K   | ]7  }d t        j                  t        |j                  d                  z   dz    9 yw)z<code>r0   z</code>N)rK   rL   strr5   rD   s     r+   rF   z&html_page.<locals>.<genexpr>.<genexpr>   s2     ~WZDKKCGGG4D0E$FFR~s   =?r/   z	</td><td>rH   c              3  X   K   | ]"  }t        j                  t        |             $ y wrJ   )rK   rL   rW   rM   s     r+   rF   z&html_page.<locals>.<genexpr>.<genexpr>   s     Zd4;;s4y1Zs   (*r   r   z
</td></tr>N)rK   rL   rW   r5   rP   )rE   r<   s     r+   rF   zhtml_page.<locals>.<genexpr>   s      	 	{{3uyy0123 4[[UYYw%7!89: ;yy~^c^g^ghv^w^}{}~~ @{{Zeii
>S>YWYZZ[ \{{3uyy789: ;		s   C/C1r3   zW<!doctype html><meta charset="utf-8"><title>Save Selector object+0x61 Consumers</title>z<style>body{font-family:system-ui,sans-serif;background:#111;color:#eee}table{border-collapse:collapse;max-width:1400px}td,th{border:1px solid #444;padding:6px 8px;vertical-align:top}code{color:#9bd4ff}</style>z,<h1>Save Selector object+0x61 Consumers</h1>z<p>Source: <code>r2   z</code></p>z<p>r4   z</p>zu<table><thead><tr><th>group</th><th>range</th><th>refs</th><th>evidence</th><th>route impact</th></tr></thead><tbody>z</tbody></table>)rP   r5   rK   rL   rW   )rQ   r;   s     r+   	html_pagerY      s    99 	 [[*0b	 	D 99c 	]6
DKKGKK,A(BCDKP
dkk#gkk,789:$?	 	 	r-   c                    |j                  dd       |dz  j                  t        j                  | dd      dz   d	       y )
NT)parentsexist_ok%save_selector_object61_consumers.jsonF   )ensure_asciiindentrO   r#   r$   )mkdir
write_textr&   dumps)rQ   r)   s     r+   write_outputsrd      sD    MM$M.66BB

7q9D@ C r-   c                    t        j                         } | j                  dt        t               | j                         }t        |j                        }t        ||j                         t        d|j                  dz          y )Nz	--out-dir)typedefaultz&wrote object+0x61 consumer summary -> r]   )
argparseArgumentParseradd_argumentr   OUT
parse_argsr>   r)   rd   print)parserargsrQ   s      r+   mainrp      sj    $$&F
$<DDLL)G'4<<(	24<<Bi3i2j
klr-   __main__)r)   r   returndict)rQ   rs   rr   rW   )rQ   rs   r)   r   rr   None)rr   rt   )__doc__
__future__r   rh   rK   r&   pathlibr   __file__resolver[   ROOTrk   r6   r,   r>   rS   rY   rd   rp   __name__ r-   r+   <module>r}      s2   A "     H~''*
Ul *)|,

 C
 ,)|,

 R
 -)

 |
 /)|,

 Z
 %)V

 ~
 )) A

 }
qC
L8
((.m zF r-   