* feat(text): inline |T...|t texture escapes in chat and display text
Backport modern inline-texture markup to the 1.12 text engine: |Tpath:h|t
renders an icon inline in FontStrings / chat, for BLP and uncompressed TGA.
- Rendering primitive: resolve a path to a resident CGxTexture via FUN_0044acf0
and draw it as a textured quad through the UI text VB path.
- Positioning: co-hook the per-line glyph emitter (FUN_005ccbe0); render plain
runs by delegating to the original per segment (threading the pen through
linkState[4], read as a float), record icon quads at the pen, and flush them
in the paint pass (FUN_005c8fe0) translated by each node origin. Handles the
FontString pipe-doubling (|T -> ||T), the bit-3 per-call batch-clear mode,
multi-icon and multi-line accumulation, and font-relative vertical centering.
- Measure/wrap: co-hook the shared tokenizer (FUN_005c2810) so an inline-texture
span is one near-zero-width token, so icons no longer force early line wrap.
- Editbox exclusion: read the focused-editbox global (DAT_00cf4dc8) and suppress
icon recording while an input field is focused, so editboxes show raw,
editable markup while cached display text keeps its icons.
Diagnostic scaffolding (stats/capture Lua helpers) is still present. Follow-ups:
exact icon width in measure (hover-box accuracy), texcoords for sprite sheets,
vertex color, and the already-built editbox case. See docs/InlineTextureEscapes.md.
* fix(text): exclude editboxes from inline textures via node flag bit 6
Editable text (node flags [+0x5c] bit 6 / 0x40 -- verified in-game: the macro
editbox is 0x4D vs chat display 0x20D and FontStrings 0x0D) now shows raw,
editable |T...|t markup instead of rendered icons, checked per node in the
tokenizer, emitter, and flush. This is the 1.12 analog of 4.3.4's per-render
texture-disable flag (tokenizer bit 0x1000).
Replaces the earlier focus-global-only exclusion, which only caught single-line
inputs that rebuild on each keystroke; bit 6 also covers multi-line editors
(the macro editor) that build once while un-focused. The keyboard-focus global
(DAT_00cf4dc8) is kept as a fallback. Removes the failed monochrome heuristic.
Diagnostic scaffolding remains; a docs update and cleanup pass follow.
* feat(text): inline-texture texcoords + fix vertical flip
- Add the width / offset / texcoord fields to the escape
(:width:offsetX:offsetY:texW:texH:left:right:top:bottom), so a sprite sheet
such as UI-RaidTargetingIcons can be cropped to a single cell.
- Fix a vertical flip: the UI device backend is OpenGL (bottom-left texture
origin), so top screen corners map to v1 and bottom corners to v0. The flip
was invisible on symmetric icons but obvious on directional ones (raid-target
markers, swords).
* docs(text): document the completed inline-texture RE map
Fold this session's findings into InlineTextureEscapes.md now that the feature
ships: the frame -> renderNode -> group -> node -> line render hierarchy;
segmented-delegation positioning (the float linkState[4] pen read, the bit-3
per-call batch-clear handling, first-line multi-line accumulation); font-relative
vertical centring; the FontString pipe-doubling (|T arrives as ||T); the shared
tokenizer measure/wrap fix; editbox exclusion via node flag bit 6 (0x40), with
the failed focus-global and monochrome attempts recorded so they aren't retried;
and the texcoord fields plus the OpenGL bottom-left vertical flip.
* chore(text): enable inline textures by default on this branch
* feat(text): inline-texture vertex colour tint (:r:g:b)
Parse the trailing r:g:b (0-255) positional fields of the inline-texture
escape and apply them as the quad's vertex colour, so |T...:r:g:b|t tints
the icon (the font stage's default MODULATE COLOROP does texture.rgb x
tint; white = untinted). The bytes pack to 0xFFrrggbb -- the same
0xAARRGGBB order the tokenizer builds for |cAARRGGBB text, verified from
FUN_005c2810's colour branch -- so the value flows straight into the
existing vertex colour slot. Threaded parse -> IconDesc -> IconRecord ->
DrawTexturedQuad. Verified in-game (red/green/blue/white diamonds).
Also record the hover-accuracy (measure-width) verdict in the docs: the
tokenizer reports an icon as ~zero width, so GetStringWidth/wrap/hit-test
undercount it. Scoped by disassembly (FUN_005c6940 width backend,
FUN_005c6b70 per-glyph advance, FUN_005cdc20/FUN_005c7260 wrap): the token
contract has no width field, there is no single cold choke, and the only
fixes are hot per-glyph hooks (against the MinHook-collision guidance) or
~6 parallel measure-loop hooks -- for a mostly-cosmetic gain. Deferred.
* docs(text): record editbox/measure findings; strip inline-texture debug scaffolding
No behavior change — functionally identical to the shipped inline-texture
feature. This captures what a long investigation established and removes the
temporary debug instrumentation added during it.
Comments (src/text/InlineTexture.cpp):
- The tokenizer's `flags & 0x40` gate is load-bearing for RENDER, not just
measure: a suppressed editbox delegates to the ORIGINAL emitter, which
re-enters the tokenizer to lay out glyphs, so bit 0x40 (EDITABLE) must make
the tokenizer stand down or the macro editor draws BLANK instead of raw.
- bit 6 (NodeEditable) and the focus global (InputFocused) are COMPLEMENTARY,
not redundant: bit 6 catches the un-focused macro editor; the focus global is
the only signal for single-line focused inputs (chat box, pfChatCopyBox),
whose nodes lack bit 6 (0x0D/0x20D, indistinguishable from display).
- Removed the tokenizer call/pipe/span counters and the ZZWIDTH TokCap capture
(debug-only), and the now-unused g_lastFocused/g_lastMono stats fields.
Docs (docs/InlineTextureEscapes.md):
- Editbox exclusion: two complementary signals, and VERIFIED against retail —
typing `|T` into a chat box or macro editor shows raw there too; only
addon/system text renders. Our editbox-raw + display-renders split matches.
- Measure gap: added the focus-time caveat (icon ~0 width unfocused; counts the
literal path text while an editbox is focused — the editbox-raw tradeoff).
- Vertex-colour tint documented in the descriptor-fields section.
* feat(chat): strip player-injected |T icon spoofs from chat + bubbles
Vanilla neutralizes player-TYPED escapes in chat (a typed |c/|H/|T shows
raw); only trusted text (addon AddMessage, shift-clicked links) renders
them. Our Text::InlineTexture backport broke that parity for |T alone: it
detects the neutralized ||T form and draws the icon anyway, so a player
could /say |Tpath|t and put a real icon in everyone's chat AND the speech
bubble over their head. This restores vanilla behavior for |T while leaving
|c/|r/|H/|h exactly as vanilla.
It can only be done at the chat source, not the text emitter: addon |T and
player |T reach the emitter as byte-identical ||T (vanilla doubles the
unrecognized |T for both), so the only place they differ is provenance --
server chat flows through the chat dispatcher FUN_0049A870, addon print does
not. That one function copies the message into a single buffer fed to BOTH
the chat frame and the say/yell bubble spawn (FUN_00608AC0), so sanitizing
on entry covers both. (ECX is the MESSAGE, not the "sender name" the old
note claimed -- verified from the call site in FUN_0049D560.)
Structure mirrors Net::PacketDispatch (one hook, fanned out), since MinHook
allows only one hook per target and this choke point already had the
GUID-capture concern on it:
- Chat::Dispatch -- single owner of the FUN_0049A870 hook; orchestrates
- Chat::IconFilter -- pure Sanitize(); no hook, no engine state
- Chat::CurrentGUID -- GUID globals + getter + DispatchScope RAII (no
longer owns a hook)
Defang detail (the subtle bit): the message arrives doubled (||T). Blanking
the PIPE would leave a lone `|` + space -- an INVALID escape the chat frame
tolerates but the bubble text setter chokes on, producing an empty bubble
that fades instantly. So we keep the `||` (a valid literal-pipe escape) and
blank the `T`; for a lone |T we blank both chars. No dangling `|`, no |T
opener survives. Verified in-game: typed |T shows raw in chat and bubble,
addon icons still render, colours and links untouched.
* feat(text): per-editbox inline-texture suppression
Inline-texture rendering was globally suppressed whenever any editbox held
focus (VAR_FOCUSED_EDITBOX != 0), so opening the chat box flipped every
rendered icon/emote in chat history to raw |T...|t.
Replace the global check with per-editbox buffer correlation: suppress inline
rendering only for text that belongs to the FOCUSED editbox, matched by
pointer range against its own text buffers. Chat history keeps rendering while
you type.
The editbox keeps its text in two buffers (both verified via Ghidra), and both
must be matched or the field desyncs (raw width but a rendered icon):
- INPUT buffer ([fe+0x32C]/[fe+0x334], selected by [fe+0x318]&8) — the
caret/width MEASURE path reads it in place (FUN_0077da80 -> FUN_00772ae0 ->
FUN_005c6940, which loops the tokenizer).
- DISPLAY buffer (*([fe+0x328]+0xF0)) — a SStrDup'd copy the editbox actually
RENDERS from (FUN_00771d80); the emitter node text and the re-entrant render
tokenizer see this one.
TextInFocusedEditbox() bounds each buffer by a tight strlen (distinct heap
allocations -> no false-match cap) and runs only on pipe-leading tokens after a
null-focus short-circuit, so it stays off the hot path. A display FontString
measured while an editbox is focused matches neither buffer, so its icons now
measure correctly -- an improvement over the old global.
Editbox struct offsets centralized in Offsets.h (OFF_EDITBOX_BUFFER_SELECT /
BUFFER / BUFFER_MASKED / TEXT_FONTSTRING).
* feat(chat): raid-target marker substitutions ({rt1}/{skull}/…)
Expand the modern raid-target marker tokens in chat into inline icons, backported
onto the inline-texture renderer. {rt1}..{rt8} plus the named aliases ({star},
{circle}/{coin}, {diamond}, {triangle}, {moon}, {square}, {cross}/{x}, {skull};
case-insensitive) each become a |T escape cropping Interface\TargetingFrame\
UI-RaidTargetingIcons to the matching 64x64 cell (mapping verified against the
client's UnitPopup.lua: col=(N-1)%4, row=(N-1)/4).
Chat::RaidMarkers::Substitute runs in Chat::Dispatch AFTER the |T anti-spoof
sanitize, so players get the fixed, safe marker icons without a path to inject an
arbitrary texture. It emits the pipe-DOUBLED ||T…||t form: the inline emitter
renders both, but this is what survives into speech bubbles — the vanilla bubble
text builder (FUN_004b1600) truncates a lone |T while preserving ||, and pfUI's
bubble reskin copies the bubble's FontString text into its own FontString, which
then renders the icon through the normal paint path. (This is the form bubbles
rendered before the anti-spoof filter defanged the ||T opener.)
InlineTexture emitter fixes for the standalone-FontString (bit-3, batch-clear)
render path that bubbles/tooltips use — chat lines are unaffected:
- Colour: clearing bit 3 switches the engine to per-glyph colour from
colorState=[node+0x2c], whose alpha byte is a stale ~0x07; force the glyph
alpha opaque (keeping RGB) so a FontString coloured via SetTextColor with plain
text doesn't render near-transparent (which showed only pfUI's dark outline =
"black text"). |c-coloured text already has full alpha, so it's a no-op for chat.
- Horizontal justify: the engine positions centre/right-justified text using the
MEASURED width, which counts inline icons as ~zero (the measure gap), so the
rendered line overflows its box. Pre-sum the line's icon widths and shift the pen
(half for centre, full for right) so text+icons justify as a unit.
- Default centerFrac 0.5 -> 0.6 (better vertical centring across chat + bubbles).
* fix(text): suppress inline textures in editboxes by content match
The per-editbox suppression missed the chat input box: a pasted `|T…|t` rendered
as an icon instead of raw markup. An in-game probe showed why — the editbox
renders its text through a TRANSIENT copy: same bytes as the input buffer, but a
distinct heap allocation with no pointer link to the editbox in either direction
(every offset/back-pointer scan of fe / its FontString / the render node came back
-1). So the prior pointer/node-identity checks (input buffer, SetText copy,
FontString +0x48, node == *(fe+0x328)) could never match the render.
Match on CONTENT instead:
- Emitter: EmitLineIsFocusedEditbox compares the render line's bytes against the
focused editbox's input buffer (the emitter is handed the whole line, so a
bounded strcmp identifies it). Chat-history lines differ, so their icons keep
rendering while an editbox is focused.
- Measure (caret/GetStringWidth): unchanged pointer path — the tokenizer reads the
input buffer in place, so TextInFocusedEditbox still matches by range.
- Re-entrant render: the suppressed emitter brackets its delegated raw layout with
a text range (g_reentryLo/Hi); the tokenizer stands down across the whole span
via TextInReentry, so `|T` isn't eaten as a zero-width token (which drew BLANK).
Drops the dead node-identity/second-and-third-buffer heuristics. Covers any focused
input (chat box, pfChatCopyBox, macro editor).
* fix(text): drop stale icon records for reused chat line FontStrings
Inline-texture icons could paint as a ghost strip at the bottom of the screen
after chat had been busy for a while. The chat frame reuses its line
FontStrings: when a line is cleared (text set empty) or reused for markup-free
text, the draw builder early-returns on it, so the emitter never runs — and so
never erases that node's old icon record. The paint flush still walked the node
and drew its now-stale record at the FontString's parked position.
Gate the flush draw on the node's LIVE text still containing `|T`: if a node has
an icon record but its current text has no markup, the record is stale — drop it
and skip drawing. Kills the bottom-of-screen ghost.
(The separate scroll-freeze — icons only refreshed on the chat's dirty repaints —
is a different, deeper issue tracked next.)
* fix(text): stop chat icons vanishing — suppress only input boxes, not editable chat display
pfUI renders the chat scrollback through EDITABLE nodes (flags 0x45: bit 6
editable, no bit 3). The inline-texture emitter's blanket NodeEditable gate
suppressed inline rendering for ALL editable nodes, so those chat icons blanked
whenever that display was live — during scroll and as messages arrived, which
read as icons "disappearing/reappearing."
Gate suppression on a true INPUT box instead: editable (bit 6) AND bit 3 (0x08).
Macro editor 0x4D and name/chat input 0xC8 all carry 0x08; the chat scrollback
0x45 does not — so real input boxes still show raw |T markup while the chat
display keeps its icons. Also drop the flush's NodeEditable draw-gate: a
suppressed input box never records, so any record reaching the flush is a real
display line.
Pointer/content match alone can't cover a focused input box because its render
form is pipe-doubled (||T) while the input buffer is single-pipe, so the compare
misses.
* feat(text): inline |T icons as fontstring-anchored engine regions
Port 4.3.4's CSimpleEmbeddedTexture model. Each icon the emitter records
becomes a pooled CSimpleTexture ANCHORED TO ITS OWNING FONTSTRING,
configured off-render on the WorldTick, and drawn by the engine's own
region pipeline. 1.12 chat lines are real CSimpleFontStrings (the
ScrollingMessageFrame display refresh FUN_00788750 drives one per visible
line), so a co-hook on CSimpleFontString::RebuildString (0x7724A0) maps
every text node to its owner and one mechanism covers chat, tooltips, and
standalone FontStrings.
This replaces the raw-GxU-quad renderer and every overlay attempt:
- engine-drawn regions keep their textures resident: no flicker, verified
across three concurrent clients
- the anchor system moves icons with their lines: scroll costs nothing
- icons mirror the owner's shown state: faded lines hide their icons
- all engine mutation happens outside the render pass: no pending-layout
corruption, survives /reload (pointers dropped in PrepareForReload)
- placement verified pixel-exact against owner rects
RE landmarks recorded in Offsets.h:
- fs+0xF8 is an HTEXTBLOCK handle; the text node is at handle+8
- Show (0x77FCB0) no-ops unless desired-shown (+0xC4) is set, and
SetParentAndLayer(show=0) clears it on reparent
- the renderer draws the corner array (+0xD4), stored from the rect by
SetTexCoord - realize (0x768060) must run between SetPoint and
SetTexCoord or the corners go stale (the historical invisible-icon and
frozen-top-left-icon bugs)
- pen coords are y-down from the owner fontstring's BOTTOM edge; anchor
offsets use Script_SetPoint's pixel scale (LinePool::PixelToInternal)
* refactor(text): inline |T icons = pixel-perfect quads + residency holders
Replace the fontstring-anchored region approach with a hybrid that
decouples position from residency, because the two live in different
coordinate spaces that no single scale could reconcile:
- POSITION: draw each icon as a raw GxU quad in the text engine's own
render space (pen + node origin), the same coordinate system and
dynamic VB the glyphs use. Pixel-exact by construction — no anchor/
layout-space conversion. This is the original quad math; the region
detour proved pen-space and anchor-space differ by the text paint's
projection, not a scalar, so region anchoring could never be exact.
- RESIDENCY: a raw quad binds an unowned texture the engine evicts under
VRAM pressure (the flicker on scroll / blank on a 2nd client). So for
each distinct texture path, Text::InlineTexturePool creates ONE managed
CSimpleTexture, draws it every frame (a ~2px, alpha 1/255 corner box),
and never touches it again — its engine-managed draw is the live
reference that keeps the texture resident for the quads to bind.
Verified in-game: icons pixel-perfect across chat / bubbles / wrapped
lines / sizes / tint, no flicker on scroll, and two concurrent clients
both render — the residency-holder premise (untested before: the earlier
"disproof" had non-drawing holders) finally validated with a holder that
actually draws. Non-zero holder alpha is load-bearing: a fully
transparent region gets culled and residency is lost.
Diagnostics (probe, perf counters, scale/bias tune knobs) stripped; the
SEH fault guard on the flush stays.
* feat(text): render inline |T icons as engine regions anchored to their fontstring
Replace the raw-quad + residency-holder hybrid as the default renderer with
the 4.3.4 CSimpleEmbeddedTexture model: one pooled CSimpleTexture per visible
icon, anchored RELATIVE TO THE OWNING FONTSTRING. Engine-drawn, so texture
residency (the chat scroll flicker / blank 2nd client) is impossible by
construction; engine-anchored, so icons track their line for free.
The pen<->anchor bridge that unblocked this: RebuildString (0x7724A0)
multiplies every text-unit quantity by fs+0x7C when creating the text node,
and the node origin is the fontstring's justification anchor point mapped by
a single measurable scale K (verified with two-position probes: origin =
rectJustifyRef x K, K ~ 1470 = physical px per anchor unit, both axes, no
drift). Placement pipeline:
- RebuildString co-hook records node -> owning fontstring (a node only
speaks for its fs while it IS fs+0xF8->block+8, killing the stale-node
clear race around rebuilds).
- The paint hook converts each icon's pen-space quad through K and queues
fs-relative placements; regions are keyed BY FONTSTRING (nodes die on
every SetText - node keying orphaned regions into an accumulating wall).
- Placements apply on WorldTick, never mid-render. SetPoint offsets are
divided by the region's effective scale (+0x7C; anchor resolution
multiplies stored offsets by the scale chain - measured 0.0319 stored ->
0.0290 resolved = x0.91), then converged exactly by a per-region rect
readback correction each tick (deterministic, self-healing; a same-call
readback read stale pooled rects and shipped 7.4px crests).
- Engine SetTexCoord (0x770410) takes the 4-float rect Y-FIRST INTERLEAVED
{v0,u0,v1,u1} (diagnosed in-game: {u,v,u,v} rendered the raid-mark moon
as the circle cell); it is absolute, and the +0x124 shrink-by-UV-span
flag stays clear so crops stretch to the rect like modern clients.
- Expired/hidden lines are swept every tick (regions parent to the chat
frame, not the line, so they cannot inherit the line's own hide).
The quad renderer and residency holders remain behind
_classicapi_InlineTexMode (0 = quads, 1 = regions [default], 2 = overlay
A/B) as the bring-up oracle, plus diagnostics (_classicapi_InlineTexProbeFS
/ RegionDump / RegionCal / HolderCfg). Calibrated residual: RegionCal
(3, -1) pen units.
* fix(text): apply the inline-icon LEAD pad at draw time
The emitter reserves w + 1.5x pad in every inline icon's advance (lead 1x,
trail 0.5x), but FlushLayout drew the icon at the raw pen - all reserved gap
landed AFTER the icon, none before. Mid-text icons looked balanced only
because their surplus trailing gap padded the following text; a string-FINAL
icon (the money-string copper coin) sat jammed against its digits, and the
locale format strings had grown per-coin offsetX hacks to compensate.
Draw at pen + w x iconPadFrac (quads and regions share the cx), matching the
emitter's reservation. The coin formats drop to zero offsets - verified
against the texture itself: the three coin arts in UI-MoneyIcons are
byte-identical in alpha (same bounds, same center of mass, measured from the
exported BLP's DXT3 data), so no coin ever needed a positional nudge.
RegionCal's baked x constant drops 3 -> 0: the +3 calibrated pre-fix was
exactly this missing lead pad (user re-calibrated (0,-1) post-fix). The 1px
y residual remains the pen->anchor map's one true constant.
* fix(text): make inline-icon state lifetime-exact; fix every scroll-landing loss
Chat icons randomly landed shown-or-hidden when lines scrolled, and stale
icons ghosted at parked positions. Root causes, each found by in-game
triangulation (FsDump/Broken/Stats diagnostics, included), all fixed:
- Placements are FS-RELATIVE, computed at PAINT time in one coherent
snapshot (icon coords + fs rect in the same flush). The old apply-time fs
rect read raced the chat relayout after SetText and parked icons off
their line, where the dedup froze them.
- The queue tail gate now matches the per-icon build gate EXACTLY (incl.
K); any not-ready input skips-and-retries instead of queueing {} - an
empty queue froze lines iconless via the dedup (early-session K window).
- K (pen->anchor scale) is derived PER NODE from its own fontstring - pen
space scales with each fs's frame-scale chain, so a global chat-derived K
mis-sized icons on differently-scaled fontstrings. Global cache kept as a
+/-10%-clamped fallback.
- Stuck-blockless fontstrings (RebuildString releases the block on a
SetText that lands on an unresolved rect and never rebuilds; the zombie
node keeps painting) are re-dirtied so the engine rebuilds - the icon
pipeline then resumes naturally.
- First-line-of-build detection comes from a draw-builder co-hook
(FUN_005CDC20) build stamp - exact - with the old text-pointer heuristic
only as fallback for emitter paths outside the builder.
- THE LIFETIME FIX: co-hook the gxu text-node free (FUN_005CD950, the
single site where every node dies and its address becomes reusable) and
erase ALL per-node state there. Anything in the maps now refers to a
live node by construction: inherited ghost records on recycled nameplate
fontstrings, orphaned owners (dropNoFs 61k -> 0), and reload leftovers
lose their mechanism of existence.
- Ghost guard rescans the FONTSTRING's text (fs+0xF0, proven trustworthy),
not the node text pointer (which lied on pfUI chat lines and made the old
scan erase LIVE records every frame - the persistent iconless LFG lines).
False matches can only false-keep, never false-erase.
- Freshness TTL: regions stay only while the paint keeps re-queueing their
fontstring (deduped touches count); parked/orphaned fs regions expire in
~1s. Do NOT build-version records against the builder counter - the
builder runs every paint but only emits when dirty, so a version check
erases good records on every clean paint (the all-icons-gone regression).
Diagnostics added (Lua): _classicapi_InlineTexFsDump (pipeline triangulation
with chain classification), _classicapi_InlineTexBroken (names the broken
lines), _classicapi_InlineTexStats gains queued/drop/nudge counters and the
SEH fault address.
Also removes the FrameTick glue-screen attempt (b164d68): hooking the UI
render root regressed in-world chat; glue-screen icon support will be
re-approached without touching the in-world render path. The
FUN_UI_RENDER_ROOT offset stays documented for that retry.
* fix(text): pointer probes must allow Large-Address-Aware heap (>2GB)
LooksReadable capped plausible pointers at 0x7FFF0000. This client is LAA
(VanillaFixes), so heap allocations above 0x80000000 are valid and routine
once the heap grows - and the flush's layout walk BREAKS on an "unreadable"
node, so a single high-heap node silently truncated the walk and every node
AFTER it in the layout list lost its icons. That was the irreducible random
per-ROW missing-chat-icon bug that survived every renderer architecture
since the guard shipped with the first inline-texture commit (aa94ea5): it
fired only when the allocator placed a node/fontstring above 2GB, varying
per session with addon load and uptime. The same check also rejected
high-heap fontstrings (dropNoFs storms, "unreadable" owner chains).
Bound raised to 0xFFFF0000 in both copies.
Diagnosed with the per-node build/emit instrumentation added here: the
smoking-gun Broken() trio was builtKnown=1 (engine built the node),
emitOutcome=8 (emitter recorded its icons), nodeSeenAge=-1 (our walk never
once saw it). _classicapi_InlineTexBroken now reports both new fields.
* feat(text): render inline |T icons on the glue (login) screen
Inline icons never appeared on the login / character-select screens: the
text-pipeline hooks are engine-generic and fire on glue (the |T spans are
consumed there), but InlineTexturePool::Maintain - the step that creates and
shows the icon regions - was driven by Tick::WorldTick, and FUN_WORLD_TICK
(0x0066FD50) is the world-simulation tick, silent on glue. Queued placements
were never applied.
Add Tick::FrameTick, hooked at FUN_UI_RENDER_ROOT (0x00764330) - the
CSimpleTop singleton's per-frame render callback, registered by both the
world-init (FUN_0048FBF0) and glue-boot (FUN_0046A7B0) paths and drained
every frame by the master scene-render pump. Subscribers run at the tail of
the callback (strata walk complete, no frame mid-draw). The pool's Maintain
moves onto FrameTick as its ONLY tick: one driver, fires wherever the UI
renders.
An earlier version of this change was blamed for an in-world chat regression
and reverted. That regression was the Large-Address-Aware pointer-bound bug
(dc61f77) rolling its allocation dice at the moment the tick moved - the
symptom persisted after the revert, which already exonerated the hook.
Glue boot (LoadGlueScriptFunctions_h) now also clears the inline-icon maps:
the world->glue teardown bulk-frees every world fontstring and text node they
reference (glue->world was already covered by FrameScript_Initialize_h, and
the node-free hook covers individual deaths in both states).
WorldTick keeps its world-only subscribers (aura eviction, cast state, raid
targets) - they read world state that is null on glue; the two ticks stay
semantically distinct: WorldTick = "world advanced", FrameTick = "a UI frame
is rendering".
* feat(text): icon-inclusive GetStringWidth + FontString:GetStringHeight backport
GetStringWidth now counts inline |T...|t icons. The old "deliberate
measure gap" analysis was right that the gxu engine has no cold choke
(parallel measure/wrap/hit-test loops, no width field in the token
contract, hot per-glyph helpers) - but the choke sits one level up:
FUN_00772890 = CSimpleFontString::GetStringWidthInternal, a cold,
MinHook-safe funnel for exactly 4 callers (Script_GetStringWidth,
GameTooltip auto-size, editbox caret positioner, effective-width
vmethod). The co-hook calls the original and re-adds the icon advances
the tokenizer hook hid, so measured width matches rendered width - and
tooltips/auto-width layout now size correctly for icon lines.
Shared-source refactor so measure and render can never disagree:
- InlineInterceptActive: the tokenizer's stand-down set factored into
ONE predicate (tokenizer passes gxu flag 0x40; the width hook passes
fs+0x120 & 0x1000, the fs-level bit FUN_0044D670 translates into it,
so editbox carets keep measuring raw markup).
- IconAdvancePen/SumIconAdvances: the emitter's reserved advance
(w + 1.5*pad + positive offsetX) factored out and shared by the
emitter loop, the justify pre-shift, and the width hook. Side fix:
the justify pre-shift previously omitted the positive-offsetX term.
Units (bit us on first flight): escape sizes are UI pixels; convert
px->anchor by the push factor K = [0x832A4C]*1024/[0x832A44] (~1468),
NEVER by fs+0x7C - that's the layout UI scale (~0.68), and dividing by
it measured a 16px icon as +44k px. The hook never writes the fs+0xFC
cache (original may serve cached; the sum is re-added per call).
Verified in-game: delta +19.5 for a 16px icon = 20.32 exact advance
minus the known 0.8 trailing-icon ink-width residual. Wrap-break,
substring measure, and hit-test stay icon-blind (documented).
FontString:GetStringHeight() (2.3.0+ binding) backported in new
src/fontstring/Metrics.cpp: 1.12 already ships the internal wrap-aware
getter FUN_007729B0 (cache fs+0x100, lines*fontH + (lines-1)*spacing,
same wrap engine the render uses, empty -> 0) - it just was never
bound. Registered on the FontString method registry; mirrors
Script_GetStringWidth's resolve + anchor->px push conversion.
Verified in-game: one-line 11.7, wrapped 46.9 (4 lines), empty 0.
* fix(text): wrap lines account for inline icon advances
Wrap decisions measured inline |T icons as ~0 (the tokenizer hook), so
icon-bearing chat lines broke as if the icons weren't there and the
emitter's real advances ran past the frame's right edge.
Choke: FUN_TEXT_WRAP_STEPPER (0x005C7260), the wrap-stepper dispatcher
that lays out one wrapped line per call. Its exactly 4 callers are
every wrap consumer - the draw builder (render breaks), the height
measure (GetStringHeight), the chars-that-fit counter (ellipsis), and
the break-array computer - so one co-hook keeps render, height,
truncation, and break arrays mutually consistent. outBreak and
outNext-text are byte counts (==len means "all fit"); outWidth is the
measured icons-at-zero line width in the caller's units.
The hook shrinks the wrapWidth argument by a minimal feasible shrink,
found by probing the stepper sandboxed (local out-params + a copy of
the p10 first-line state byte): feasible(s) iff the line's icon
advances fit in the shrink plus the spare the break left
(iconSum <= s + probeW - outWidth). s=0 feasible -> no shrink (the
common fits-anyway case); otherwise escalate by the measured deficit,
then bisect the [infeasible, feasible] bracket to a quarter-glyph
(<=8 probes). Never overflows; packs each line to its physical
capacity. Gated on the shared InlineInterceptActive predicate + the
editbox flag bit 0x40 the dispatcher already carries.
Unit trap #2 (cost one flight): each caller passes fontH/wrapWidth in
its OWN space - node text units from the builder, the small
anchor-converted space from the fs-level callers chat wraps through.
px -> caller units = fontH / FUN_TEXT_FONT_HEIGHT(flag, fontH), the
engine's own pixel realization of the fontH param (FUN_005C6940's
final scale proves the convention for every gxu caller).
Rejected en route (documented in docs/InlineTextureEscapes.md): raw-px
subtraction (shredded lines to 2-glyph fragments), whole-remaining-
text sums (8-icon line -> one word per line), icon-count fixed-point
iteration (oscillates - 55-byte zero-width escapes make the
break<->count coupling discontinuous), max/average tiebreaks.
Cross-checked against 4.3.4 (renders |T natively): Blizzard extended
the token contract instead - texture token type 7 + a shared parser
(FUN_00617ba0) called inline by all five layout loops, fontH passed in
for :0 defaults, plain width, no padding. No single-choke trick exists
at source level; the probe search is the 1.12-shaped equivalent.
Diagnostics: _classicapi_InlineTexWrap(n) dumps the last 8
icon-bearing calls (widths, per-probe sums/breaks/raw out-params,
final shrink, floor hits).
* fix(text): wrap-shrink search refinements from in-game shakeout
Three fixes to the minimal-feasible-shrink search (2450522), each from a
live regression the _classicapi_InlineTexWrap diag pinned down:
- Full bracket bisection (<=8 probes, quarter-glyph epsilon). The first
cut abandoned the [infeasible, feasible] bracket after one stale
escalation candidate, costing the Marks harness line a whole
mark+word pair per line (3+5 instead of the optimal 4+4).
- Half-glyph feasibility tolerance. The width hook and the wrap hook
derive the icon sum through different unit chains (FUN_007727B0xK vs
FUN_005C6FA0 ratio, OUTLINE extras, the trailing-glyph ink/advance
quirk); the drift can read "fits exactly" as "1px over" and shrink a
zero-slack line. Genuine icon overflow is >= a full icon, so half a
glyph separates drift from real overflow.
- Auto-width bail (all text fits at s=0 AND slack <= 1.5 glyphs). A
single-anchor, no-width fontstring (pfUI's addon-list labels) wraps
at its own text-only measure plus a ~1-glyph engine margin (measured
1.07xfontH), so icons "never fit" its budget - but the box is
synthetic, icons draw past it harmlessly, and any shrink FABRICATES a
wrap ("Twitch Emotes" split across two lines). Real frames stay
covered: overflowing lines break, fitting lines carry frame-sized
slack (Marks measures ~3.5xfontH). The narrow give-up band - text
within 1.5 glyphs of exactly filling a real frame - reverts to the
pre-hook overflow, bounded by the line's icon sum.
Diag reshaped for /dump's ~30-value print cap: 8 numeric headers plus
ONE pass-summary string (shrink candidate, icon sum, line length, raw
outBreak/outNext/outWidth per probe), so no record truncates.
* feat(texture): add Texture:SetRotation via corner-vertex rotation
Backports the modern texture:SetRotation(angle [, cx, cy]) method, which
vanilla 1.12 lacks entirely.
4.3.4's SetRotation (Script FUN_0052cb50) rotates the four texture
COORDINATES around a centre and feeds the 8-arg SetTexCoord, which clips
the corners of an off-axis square. 1.12 can't mirror that — its
CSimpleTexture::SetTexCoord takes only a min/max UV rect.
1.12 has a cleaner seam: a CSimpleTexture stores its drawn quad as four
independent corner positions at +0xD4, and the draw enqueue (FUN_00772fd0)
hands region+0xD4 straight to the vertex batch as four free vertices — no
axis-aligned rect is re-derived. So rotating those four corner positions
draws a truly rotated quad with no corner clipping.
The engine fills the corners axis-aligned from the layout rect via
FUN_REGION_STORE_CORNERS; a co-hook there re-applies rotation right after
each store, so a static rotation is written once and costs nothing per
frame while moves/resizes re-rotate automatically. Angle is radians
(positive = counter-clockwise); optional (cx, cy) is a normalized pivot
in [0,1], default centre; an angle of 0 clears.
Per-region state keys on the raw region pointer and is cleared on /reload
and world->glue (Texture::Rotation::PrepareForReload). A texture freed and
instantly re-pooled mid-session could briefly carry a stale rotation —
accepted; a destructor-evict hook is the later hardening.
New in Offsets.h (all verified against WoW.exe): OFF_SIMPLETEXTURE_CORNERS,
FUN_REGION_TEXCOORD_CROP, FUN_REGION_GET_RECT.
* feat(texture): add Texture:SetVertexOffset, generalize corner transforms
Backports Texture:SetVertexOffset / GetVertexOffset (plus GetRotation),
generalizing the SetRotation module (texture/Rotation.* -> texture/Transform.*)
into one corner-transform primitive that backs both methods.
Both write the four drawn corner POSITIONS at region+0xD4 — the vertices the
draw enqueue FUN_00772fd0 hands straight to the batch; no stock 1.12 function
exposes them. Per-region state widened from an angle to {rotation, four vertex
offsets}, applied through the same FUN_REGION_STORE_CORNERS co-hook: after the
engine writes the axis-aligned corners, rotate about the pivot, then add the
offsets. The two transforms compose (matching retail) and persist across layout
resolve / move / resize / SetTexture with no per-frame cost.
SetVertexOffset offsets are UI coordinate units (like SetPoint x/y), converted
to the engine's internal layout space with the same factor Tooltip::LinePool
uses; +y is up. vertexIndex maps to a corner via VertexSlot; the
UPPER_LEFT_VERTEX / ... constants are defined FrameXML-style in the embedded
addon's Util/Constants.lua.
Non-inverting warps (perspective, skew, trapezoid, wave) are free; a warp that
mirrors the quad past edge-on inverts its winding and the region draw culls it
(documented).
* feat(texture): add Texture:SetColorTexture
Backports the 7.0 SetColorTexture(colorR, colorG, colorB [, a]) as a second
name on the engine's own Script_Texture_SetTexture handler (0x0079BB40): its
numeric branch already clamps r/g/b/a to [0,1] and fills a solid colour via
FUN_00770360 (the string branch loads a path). So SetColorTexture is exactly
vanilla's numeric SetTexture form under the modern name — zero reimplementation,
with the clamp and opaque-alpha default coming straight from the engine.
The alias also accepts a path string (a harmless superset of the retail
contract). SetDesaturated / IsDesaturated are already native (real Desaturate.bls
pixel shader); SetDesaturation is not addable — vanilla desaturation is a fixed
effect handle with no strength constant in the setter, draw command, or effect
table.
* fix(text): correct the emitter's lazy pen read-back; drop quad render mode
The inline-icon emitter hook threaded the pen between text runs by
reading the engine's linkState[4] after each delegated run. That value
is LAZY (verified in FUN_005ccbe0): the engine places each glyph at
pen + pairAdvance(prev, cur) and its final write re-adds the LAST PAIR
as a stand-in for the last glyph's own advance. For a one-glyph run the
stand-in is 0 (no pair exists), so the run read back as zero-width and
the icon drew on top of the digit — the money-string "coin covers the
lone 0/1" bug. For "] 1" the stand-in was the space's advance, ~3px
short: the single-digit clip. "11" matched by luck (same-glyph pair).
Fix (the 4.3.4 model — FUN_0061ea10 case 7 computes the pending last-
glyph advance explicitly instead of trusting a stored pen): drawRun now
token-walks each run with the engine's own tokenizer and, when it ends
in a glyph, replaces the stand-in with the truth:
pen = linkState[4] - pairAdvance(prev, last)*scale
+ baseAdvance(last)*scale
using the engine's own advance functions (FUN_005ca240 base,
FUN_005ca2d0/FUN_005ca4b0 pair, per the node's kerning flag) and its
per-placement __ftol snap. Runs ending in a non-glyph token (trailing
|c/|r) need no correction — the trailing iteration already folded the
last glyph's base advance into the write.
Also:
- The per-icon breathing pad is now FONT-relative (fontH * padFrac),
not icon-width-relative: the gap no longer scales with icon size, so
a small icon doesn't jam its neighbour while a big one floats.
- Quad render mode is removed entirely (DrawTexturedQuad, residency
holders, _classicapi_InlineTexMode/_InlineTexHolders/_InlineTexHolderCfg).
Engine regions (the 4.3.4 CSimpleEmbeddedTexture model) are the only
render path.
* feat(currency): GetCoinTextureString / C_CurrencyInfo.GetCoinTextureString
The retail coin-icon money string, backported as a C function
(src/currency/CoinText.cpp) the way retail ships it (behaviour from
3.3.5's Script_GetCoinTextureString FUN_00510d00): split copper into
gold/silver/copper, emit only non-zero denominations in that order,
zero shows "0<copper>". Each denomination formats through the
GOLD/SILVER/COPPER_AMOUNT_TEXTURE GlobalStrings, backported in the
embedded addon's locale layer (stock 1.12 doesn't have them), so
locales can override.
1.12 has no per-coin icon textures — the |T markup crops vanilla's
UI-MoneyIcons 4-cell sheet (gold 0:1, silver 1:2, copper 2:3; the
three coin arts are byte-identical in alpha, verified by decoding the
exported BLP's DXT3 data). height/width 0 = size to the display
font's height (the retail default, honoured by the inline-texture
renderer). No offsetX nudges and no separator spaces: correct spacing
comes from the renderer's font-relative pad plus the lazy-pen fix
(550cf5e) — per-coin offsets were compensations for that bug and must
not return.
FormattingUtil.lua comment updates only (GetMoneyString stays the
text-symbol form; the coin form now exists). docs/API.md: new
Currency section.
* docs(readme): list GetCoinTextureString in the API table
* refactor(text): purge the quad-mode leftovers
Follow-through on 550cf5e (quad render mode removed): delete everything
that existed only for the raw-GxU-quad path and no longer has a single
reference.
- Offsets.h: drop the GxU device primitives (dynamic-VB lock/data/
submit/unlock, texture bind, vertex stride/selector), the standalone
path->CGxTexture loader trio (FUN_TEXTURE_LOAD_BY_PATH,
PTR_TEXLOAD_DESC_VTBL, FUN_GX_TEXFLAGS_INIT), the colorop render-state
and direct-D3D state setters, FUN_TEXTURE_FORCE_DECODE, and
FUN_TEXTURE_GET_RENDERABLE. All were quad/residency-era scaffolding;
the VAs stay recorded in docs/InlineTextureEscapes.md and git history.
FUN_TEXT_PAINT (the flush co-hook site) and VAR_TEXTURE_BLEND_DEFAULT
(the pool's SetTexture blend arg) remain, with comments rewritten for
the region path.
- InlineTexture.cpp: drop IconRecord.z / penZ (only the quad draw read
them); rewrite the paint-flush section comments to describe what the
flush actually does now (queue fontstring-relative region placements).
* feat(addon): backport TextureUtil.lua (Blizzard_SharedXMLBase)
The non-atlas slice of the Classic Era reference, ported to Lua 5.0
(string.format instead of string-method syntax):
- SetClampedTextureRotation / ClearClampedTextureRotation — the retail
90-degree-step texcoord shuffle with width/height swap. Works
unchanged because 1.12's Texture:GetTexCoord() natively returns the
8-value corner form and SetTexCoord accepts it (both operate on the
same engine corner array, verified at Script_Texture_GetTexCoord
0x0079BDF0). One deviation, commented in-file: Clear also nils
rotationDegrees — the reference leaves 0 behind, which is truthy in
Lua and breaks the next Set's origTexCoords re-capture.
- GetTexCoordsByGrid — pure math.
- CreateTextureMarkup / CreateSimpleTextureMarkup — |T markup builders;
output renders via the inline-texture backport.
- TextureUtil = {} for namespace parity.
Omitted: everything atlas-based (CreateAtlasMarkup*, the TextureKit
family, CheckSetAtlas, GetAtlasSize, SetTextureWithAddressModeOptions —
1.12 has no atlas system), the LFG role-icon tables, and
GetTextureInfo (reads the atlas/fileID getters).
* refactor(text): remove the inline-texture bring-up diagnostics
The pool's _classicapi_InlineTexRegionDump / _InlineTexFsDump /
_InlineTexBroken were bring-up triage for the scroll-landing /
ghost-icon bug class, which the node-free lifetime hook ended
(b5df20d) — they have no remaining job. Removing them also kills their
entire support tree, none of which had another consumer:
- the five Debug* chain-state exports on Text::InlineTexture
(DebugChainState / NodeFlags / NodeSeenAge / NodeBuiltKnown /
NodeEmitOutcome),
- g_nodeSeen + g_flushSeq (flush visit stamps),
- g_nodeEmit (per-node emitter-outcome tracking — map churn on every
emitted line, purely diagnostic),
- g_nodeBuilt + g_buildCounter + NodeIcons.builtSeq (write-only: the
build-version check they were made for was deliberately REJECTED —
the builder runs every paint but only emits when dirty, so version
mismatches on clean paints erased live records). g_buildNode /
g_buildEmitSeq stay — they are the live firstLine detection.
NodeIcons collapses to a plain std::vector<IconRecord> map value, and
the pool drops its Game.h / InlineTexture.h includes (nothing left
uses them). The stale "versioned by build" struct comment is rewritten
to describe the actual invariant (node-free hook + firstLine erase).
Kept: _classicapi_InlineTexEnable / Suppress / Tune / Stats / ProbeFS /
RegionCal / Wrap — the live control surface and field telemetry.
* refactor(text): reduce the inline-texture Lua surface to the kill switch
Only _classicapi_InlineTexEnable remains — the feature toggle the SEH
latch pairs with. Removed with their entire backing state, none of
which had a non-diagnostic consumer:
- _InlineTexSuppress + g_suppressInline (the manual global override —
editbox exclusion has been per-node/per-buffer for a while) and the
now-unreferenced InputFocused() helper
- _InlineTexTune: g_vBias / g_sizeScale / g_centerFrac / g_iconPadFrac
become constexpr (calibrated during bring-up, fixed now)
- _InlineTexRegionCal: g_regionCalX/Y become constexpr (0 / -1)
- _InlineTexStats + the six flush-gate counters (the queue gate
if/else collapses to the plain condition; the nudge drops its
counter-guard and just sets the dirty bit — idempotent)
- _InlineTexWrap + the WrapDiag ring and every capture site in the
wrap-stepper hook (the minimal-feasible-shrink algorithm is
untouched — it always ran on locals)
- _InlineTexProbeFS (the pen<->anchor bridge verification probe)
- the SEH filter no longer records fault code/address (nothing read
them); the latch still disables the feature on a flush fault
- the Arg() Lua helper and <cstdio> (last users removed)
* feat(text): inline icons fade with their chat line
The one visible seam left in the region renderer: icon regions parent
to the CHAT FRAME (regions cannot parent regions), so they inherited
the frame's alpha but not the LINE's — a fading chat line's text
dimmed while its inline icons stayed opaque until the end-of-fade
hide.
RE (verified in the 1.12 binary): chat fading is engine-side in the
ScrollingMessageFrame's fader FUN_00788460 — gated on the SetFading
flag (smf+0x360; the 40-method SMF registry's SetFading 0x007939A0
writes it), it counts down each visible line's timeVisible then
fadeDuration ({rgba@+4, shown@+8, timeLeft@+0xC, fadeLeft@+0x10} in
the stride-0x10 line array at smf+0x3A4) and animates the LINE
FONTSTRING's color alpha byte through the fs SetColor (0x0077F750)
every frame, hiding the fs at zero. SetColor stores the dword at
(*(u32**)(fs+0xB8))[0] (count fs+0xB4; alpha = byte 3), and the
per-line setter FUN_00788af0 resets alpha to 0xFF on message reset —
so that byte IS the line's live fade state, whoever wrote it.
The mirror (InlineTexturePool): Maintain reads FsColorAlpha(fs) each
tick and, on change only, rewrites the shown regions' colors with the
markup tint's alpha modulated by the line's alpha (RGB preserved).
ApplyPlacement folds the live alpha in at placement time, so a line
placed mid-fade starts at the right opacity. Composition is exact by
construction: the fs's on-screen alpha is frameAlpha(+0xC8) ×
fsColorAlpha, and the regions share the same parent frame, so
mirroring the fs byte alone makes icon and text alpha identical.
Steady state costs one byte compare per icon-bearing fontstring per
tick; scroll-back/un-fade restores (the SMF resets the line color and
the mirror follows). Verified in-game: fade lockstep, reappear on
scroll.
* feat(text): line-height growth for tall inline icons
An inline icon taller than the font (a 32px TwitchEmotes emote in 15px
chat) used to overlap its neighbouring lines — the line box stayed
fontH-sized. Retail grows the line: 4.3.4's measure and wrap loops
export a max-texture-height out-param (FUN_00618b90 / FUN_00618e40
case 7) and the layout takes it.
1.12 equivalent, one cold co-hook: FUN_FONTSTRING_STRING_HEIGHT
(GetStringHeightInternal, cache fs+0x100) gains the tallest icon's
overflow past the font height (MaxIconOverflowPx — explicit |T heights
only; the :0 default IS the font height). Its three binary consumers
(verified via xrefs) split exactly right:
- FUN_00772A60, the anchor effective-height vmethod — chat line
fontstrings get only a SetWidth from the ScrollingMessageFrame
refresh, so their rect height resolves here -> the rect grows;
- FUN_00788750, the SMF display refresh — budgets vertical space and
anchors each line to the previous line's rect -> the stack spaces by
the grown height;
- FUN_0077D4D0, the multi-line editbox self-size — excluded by the
same editbox gate as the width hook (editboxes render raw markup).
Same rules as the width hook: shared InlineInterceptActive predicate,
px->anchor via the push factor (never fs+0x7C), the fs+0x100 cache is
never written (delta re-derived per call — idempotent). The backported
fontstring:GetStringHeight routes through the hooked VA and becomes
icon-inclusive automatically.
Draw side: tall icons CENTRE on the line like any other icon. The text
centres itself inside the grown rect, so the extra space appears half
above and half below — a centred icon fills exactly that, matching
retail. (A bottom-aligned first cut clipped the neighbouring line;
verified in-game against retail's centred, no-clip rendering.)
v1 limit (documented in-code): the delta is the whole text's max
overflow — exact when a message's tall icons share one wrapped line
(the emote case); tall icons on two different wrapped lines of one
message under-grow.
Verified in-game: 32px emotes between normal chat lines each take
their own vertical room, centred, no neighbour overlap.
* fix(text): full-height hyperlink hover for tall inline icons
With line-height growth (49934b0), a tall emote inside a |H...|h link
was only hoverable across its text-high middle band: the hyperlink hit
rect is registered at layout time (FUN_TEXT_LINK_RECT_ADD 0x005CD310,
the GXUFONTHYPERLINKINFO append — record {y,x,y,x} normalized + link
ptr/len pairs) with the TEXT band's y extent, fontH tall.
Consumer geometry (FUN_00788c00 -> FUN_007a3350 decompile + two in-game
experiments): the ScrollingMessageFrame rebuilds a hit-region frame per
record, anchored to the LINE FONTSTRING's top-left with the record's
band as offset/height. The band's y values are Y-UP (numeric max =
screen top — extending the max visibly grew the region into the line
above), and the band is TEXT-relative — but the grown rect's top sits
half the icon overflow above the text (the text centres in the grown
rect), pre-shifting the whole hit band up. Net: the unmodified band
already covered from the icon's top down to textBottom − overflow/2,
and the single correct fix is pushing the screen bottom DOWN by the
full overflow — decreasing the numeric MIN edge.
Co-hook on the append: when the |H...|h escape span contains a |T icon
taller than the line's font (the same MaxIconOverflowPx the
string-height hook grows the line by), decrease the band's min edge by
the overflow before the original stores it. All consumers of the
record (hover, click) inherit the expansion. Gated on the shared
InlineInterceptActive predicate so raw-rendered contexts stay literal.
Known v1 rough edge (commented in-code): a tall icon outside the link
but on the same line grows the line without this hook firing for that
link, leaving its band half-overflow high.
Verified in-game: a 32px emote link hits across its full height, no
bleed into neighbouring lines.
* docs(text): truth-pass on the inline-texture RE docs
InlineTextureEscapes.md and InlineTextureResidency.md described the
removed raw-quad renderer and a bring-up plan as if current. Bring them
in line with the shipped engine-region design.
InlineTextureEscapes.md:
- New "Current design (shipped)" section up front: region renderer, the
three fs-level measure hooks (width/height/wrap), the lazy-pen fix,
chat fade, tall-icon line growth + full-height hover, editbox
exclusion, the payload, and anti-spoof — each with its commit.
- Banner the quad "rendering primitive" section as REMOVED (bring-up
record; the address log for code deleted in 56c2670).
- Fix the DrawTexturedQuad / quad-flush references to region-queue
language; vertical centring is g_centerFrac (0.6) with the tall-icon
grown-rect note; the flip note becomes the region SetTexCoord
Y-first order.
- "Remaining/optional": diagnostics removed (only InlineTexEnable
left), measure/height/wrap DONE, animation is addon-side, the TGA
convert command is -compress none only.
- "Reality check": correct the prediction that we would reimplement the
emitter — the shipped design segment-delegates and co-hooks instead.
InlineTextureResidency.md: rewritten from a "not-yet-implemented plan"
into an accurate reference. States the region design, records the
CSimpleTexture entry points / layout the pool uses (VAs verified
against Offsets.h), and corrects the root cause honestly — the flicker
was the LAA pointer-bound truncation (dc61f77), NOT texture residency;
regions are kept for 4.3.4 parity and are resident by construction as a
bonus. Keeps the D3D "ruled out" notes as a do-not-re-investigate
record.
* fix(text): stop inline-icon Maintain from dereferencing stale fontstrings
A destroyed chat-line fontstring left a dangling key in the icon pool's
per-fontstring map. Its heap memory was reused as a string buffer, and
Maintain's weak LooksReadable() range check waved the reused pointer
through; reading the "parent" field (fs+0x9C) then yielded string bytes
(ASCII "-Rac"), which the engine's region attach (FUN_0076a750)
dereferenced at *(parent+0x1B4) -> ACCESS_VIOLATION (ERROR #132 at
0x0076A7CE).
Two compounding defects, both in Maintain:
- the stale-entry expiry was gated on shown > 0, so a scrolled-off line
(shown == 0) never expired and its dead key was re-dereferenced every
frame, waiting for its memory to be reused;
- LooksReadable is a bare VA-range test that a reused buffer passes.
Fix: verify a key is a LIVE fontstring by its object+0x00 vtable before
using it. The vtable is learned at paint time from fontstrings the engine
is actively drawing (QueuePlacements), so every fontstring class -- chat's
internal ScrollingMessageFrame lines, tooltip/CreateFontString lines,
addon fontstrings -- is recognized without hardcoding (one hardcoded value
filtered live chat icons out entirely). Maintain now iterates with erase:
a key whose memory no longer carries a learned fontstring vtable has its
regions hidden (our tex pointers stay valid, parented to the chat frame)
and the entry erased, so dead keys can neither accumulate nor be
dereferenced.
* fix(text): guard inline-icon pool hide loops against short region vector
CreateRegion can fail when the region pool is exhausted, breaking the
apply loop with fewer regions than `want`. The code still set
`np.shown = want`, so a later tick's freshness-expiry and fs-hidden hide
loops indexed np.regions[i] past regions.size() -- an out-of-bounds
std::vector access.
Clamp np.shown to min(want, regions.size()) so it never exceeds the
vector, and add the same i < regions.size() bound the eviction loop
already carries to the other two hide loops so all three self-guard.
* refactor(text): centralize inline-texture offsets and pointer probe
Enforce the single-source-of-truth offset rule on the inline-texture
files:
- Read the fontstring text pointer via Offsets::OFF_FONTSTRING_TEXT
instead of a raw `fs + 0xF0` in FlushLayout's ghost guard; the symbol
already existed and is used elsewhere in the same file.
- Add OFF_TEXT_NODE_JUSTIFY (0x54) to Offsets.h with a verification note
and use it for the two node-justify reads (DeriveK and the emitter
pre-shift) that previously hardcoded 0x54 in two places.
- Move the LAA-aware LooksReadable probe into a shared text/PtrProbe.h
(namespace Text) so InlineTexture.cpp and InlineTexturePool.cpp share
one definition instead of two copies plus a third raw-bounds copy in
LearnFontStringVtable. The 0xFFFF0000 bound now lives in exactly one
place -- this is the constant whose earlier 0x7FFF0000 form caused the
missing-chat-icon bug, so keeping the copies from drifting matters.
No behavior change; full build compiles and links.
* fix(currency): clamp GetCoinTextureString to the uint32 copper ceiling
An amount above INT_MAX gold copper (e.g. 1e15) made `gold =
(int)(amount / 10000)` overflow: the long long division was truncated to
its low 32 bits, so GetCoinTextureString(1e15) printed a garbage gold
count (1215752192). silver/copper were already bounded by the % math.
Vanilla money is a uint32 copper field, so clamp amount to 0xFFFFFFFF
copper (~429,496 gold) -- the most the game can represent -- which keeps
gold within int range for the "%d" GlobalString format. Can't widen the
type instead: the count is formatted through the retail-compatible "%d"
coin GlobalString, and passing a long long to %d is undefined.
* fix(text): SEH-guard the inline-icon Maintain tick; document region leak
#6 (SEH backstop): Maintain's liveness probe dereferences a fontstring
pointer that may have been freed (the documented IsLiveFontString
residual). The paint path already latches off on a fault via SafeFlush,
but Maintain ran bare under the render-root tick, so a fault there was an
uncaught client crash. Split the body into MaintainImpl (holds the C++
objects) and a thin Maintain() SEH wrapper that latches g_maintainDisabled
on fault -- mirroring the paint latch. Re-armed on /reload.
#7 (region leak): document why the stale-key eviction intentionally drops
np.regions without reclaiming the pooled CSimpleTextures. Any reclaim (a
free list or explicit destroy) would touch a region whose parent frame may
already be gone -- a use-after-free on the very path this liveness check
was added to stop crashing. The leak is bounded and near-zero in practice
(chat/tooltip fontstrings are reused, never evicted).
* fix(chat): stop raid-marker expansion from dropping the message tail
A token inflates ~28x ({rtN} -> ~85-byte |T markup), so a marker-dense
message could fill the 0x800 buffer and silently truncate everything after
it -- a DLL user would see a shorter chat line than a non-DLL user (a mild
content-hiding vector).
Reserve room for the literal tail before expanding a token: only iconify a
marker when the expansion plus the whole remaining input (worst case copied
1:1) still fits. Past that point later tokens stay literal {rtN}, so the
full message text is always preserved -- just with fewer icons.
* fix(text): gate eviction Hide on region liveness to avoid a UAF
The stale-key eviction Hid its regions unconditionally, assuming they
outlive the fontstring. They usually do (regions are parented to the
fontstring's parent FRAME, which persists as lines churn) -- but if the
fontstring became non-live because that parent frame was destroyed, the
frame freed the fontstring AND its child regions together. Hiding a region
pointer there wrote to freed/recycled memory: a use-after-free that could
crash.
Learn the pooled CSimpleTexture vtable in CreateRegion and gate each
eviction Hide on IsLiveRegion (the same vtable-liveness technique
IsLiveFontString already uses). A recycled region is skipped (it needs no
hiding -- it's already gone); a live one is still hidden so it can't ghost.
Factored the shared WoW-image-range check into InWowImage so the two Learn*
functions don't duplicate the constant.
41 KiB
Backporting inline |T…|t texture escape sequences to 1.12
The 1.12 text engine shows |Tpath:height:width:…|t markup as literal text.
This project makes it draw the icon inline in FontStrings, chat, and tooltips —
the way 4.3.4 and later clients do. The feature is complete and shipped
(src/text/InlineTexture.cpp,
src/text/InlineTexturePool.cpp).
This file is the reverse-engineering map. Current design below states what ships today. Everything from Goal & spec down is the historical RE trail — the 4.3.4 study, the 1.12 injection map, and the bring-up plan. It is kept for the addresses and the reasoning, not as a description of the current code.
Current design (shipped)
Each icon renders as an engine-managed region (a pooled CSimpleTexture)
anchored to its owning FontString. The engine draws the region every frame and
moves it with its line, so texture residency and scroll tracking are correct by
construction. (A raw-GxU-quad renderer existed during bring-up and was removed
in 56c2670; its RE is the "REMOVED" section below.)
The DLL hooks the engine's own text pipeline — no companion addon:
- Positioning — a co-hook on the glyph emitter
FUN_005ccbe0records each icon at its pen position and delegates the plain text runs to the engine (segmented delegation, below). The pen read-back needed a fix: the engine's pen is lazy and omits the last glyph's own advance, so a coin sat on its digits; the emitter now adds the true terminal advance from the engine's own glyph-advance helpers (550cf5e). - Rendering — the paint-pass co-hook
FUN_005c8fe0walks the icon records and queues each toText::InlineTexturePool, which places the region on the next frame tick (never mid-render). - Measure — three cold FontString-level co-hooks make measure match the
drawn result: width (
FUN_00772890), height (FUN_007729B0), and wrap (FUN_005C7260).GetStringWidth,fontstring:GetStringHeight, wrap breaks, and line height all count the icon. - Tall icons — an icon taller than the font grows its line height, so it
does not overlap its neighbors, and it centers in the grown line. A hyperlink
that contains a tall icon is hoverable across the whole icon
(
49934b0,b9d0705). - Chat fade — icons fade in lockstep with their chat line (
3ca3b7e). - Editboxes — an editbox keeps the raw markup, so the caret stays aligned (two complementary signals, below).
- Payload — the full
|Tpath:height:width:offsetX:offsetY:texW:texH:left:right:top:bottom:r:g:b|t: size, pen offset, sprite-sheet crop, and vertex tint. BLP and uncompressed TGA. - Anti-spoof — chat strips player-injected
|Ticons.
The one measure path still icon-blind is the substring width (FUN_00772AE0),
which nothing consumes yet. The Lua control surface is one kill switch,
_classicapi_InlineTexEnable (the SEH latch trips it on a flush fault); the
bring-up tune / stat / probe functions were removed (5e5677b, 6800a9a).
REMOVED (bring-up record) — the raw-GxU-quad rendering primitive
This was the FIRST renderer: each icon drawn as a raw textured quad through the
text VB path. It shipped, then was removed in 56c2670 for the engine-region
model (regions are resident by construction; the quad path needed the texture-
residency machinery below and still flickered on VRAM pressure — see
docs/InlineTextureResidency.md). This section is the address record for the
removed code, not a description of the current renderer. LoadTextureByPath,
DrawTexturedQuad, and the GxU device offsets it names are gone from
Offsets.h; the values live here and in git history.
An arbitrary texture draws through the text VB path as a coloured, alpha-blended quad. The end-to-end recipe:
- Load by path —
LoadTextureByPathreplicatesFUN_00770200's load: build flags viaFUN_0058a980(&flags, DAT_00878cf0, 0,0, 0,0,0, 1, 0), thenFUN_00449d90(path, &desc, flags, 0, 1)with a byte-identical 5-dword desc ({PTR_FUN_007ffa10, 8, &self8, (&self8)|1, 0}). Returns the HTEXTURE (0x15c-byte struct; path@+0xc, flags@+0x110, refcount@+4). - THE KEY — residency + correct bind via
FUN_0044acf0(HTEXTURE, 1, 0). This is the engine's own "get renderable texture" call (what the widget render uses every frame). It returns the bindable CGxTexture at[HTEXTURE+0x140]and, with force=1, drives the streaming load (FUN_0044ad50submits/prioritises it via[HTEXTURE+0x138]). Calling it every frame is the live reference that makes the texture resident — no hidden widget, no manual BLP decode. This was the entire multi-session blocker: WoW streams textures and only loads ones a live frame references; a standaloneFUN_00449d90texture never loads on its own. Binding the raw HTEXTURE isSetTexture([HTEXTURE+0x48]=0)= a white quad; the D3D handle lives on the CGxTexture ([CGxTexture+0x48]), not the HTEXTURE. Dead ends that wasted time: manually invoking the decode callbackFUN_0044a260(fills[+0x120]but not the bindable+0x140, and faults); binding[HTEXTURE+0x48]or[HTEXTURE+0x120](both wrong offsets); forcing the streamable flagtex[0x3c]|=0x80(crashes in d3d9 — the bind's stream-in vfunc corrupts the resource). - Bind —
FUN_00589e80(0x17, cgxTex)(selector 0x17 = text texture stage). - Colour — the font stage's default stage-0 COLOROP is already MODULATE, so
texture.rgb × diffuse(white)= the icon's true colours; texture alpha works too. No colorop override is needed for a plain white vertex. (If a tint is wanted later: COLOROP is D3DTSS internal state0x42viaFUN_005a2570; the engine leaves COLORARG1 at the D3D default = TEXTURE. Do NOT poke it directly mid-draw — it leaksMODULATEto the whole UI when a fault skips the restore. Use the engine's selector0x1f(value→COLOROP/ALPHAOP preset table atDAT_0080a25c/DAT_0080a274; value 1 = MODULATE/MODULATE).) - Quad — lock the shared dynamic VB
FUN_0058a140(0, 0x18, 0x800), get the write ptrFUN_0058a080, write 4 verts of the format{float x,y,z; u32 colorBGRA; float u,v}(stride 0x18) in corner order TL, TR, BL, BR (matches the shared quad index buffer{0,1,2, 2,1,3}and the device cull winding), submitFUN_005c8f40(&handle, 4), unlockFUN_0058a0a0(handle, 0). - Where — co-hook the text paint pass
FUN_005c8fe0and draw after the original glyph flush (device is in the correct textured-UI state there). Coordinate space is per-layout pixels, y-down; glyph verts live at small local coords (a probed glyph was at ~(9,33)–(17,50)). Draw coords must be within the layout's rendered area (a fixed (100,100) test lands in chat).
The build-side gotcha: the D3D device (default backend, FUN_0058dd70) is
actually OpenGL (glMaterialfv/glFogi) — the D3D backend is FUN_0058ba70
(FUN_00598ce0, vtable PTR_FUN_00809ef8); its state applier is vtable[1] =
FUN_005a2f00, which maps engine selectors to D3D via FUN_005a2570
(SetRenderState +0xe4, SetTextureStageState +0x10c, SetSamplerState +0x114,
SetTexture +0x104). Selector map (shared across GL/D3D backends): 7=blend,
0x10=depthtest, 0x14=cullface, 0x17-0x1e=texture bind (8 units),
0x1f-0x26=colorop/alphaop preset (unit 0-7).
SOLVED — positioning, measure/wrap, editbox exclusion, texcoords
The primitive draws at arbitrary coords; the rest is knowing WHERE and WHEN. Everything is in src/text/InlineTexture.cpp; offsets under the "Inline texture escape" + positioning blocks in Offsets.h.
The text render hierarchy (verified)
frame → renderNode [frame+0x118] → group [renderNode+0x18]
→ node [group+0x18] → line [node+0x24] ← the emitter's `this`
- Main UI render
FUN_007657d0(DAT_00cf0bd8)walks strata → frames, callsFUN_0076fb00(renderNode)per frame's render node. FUN_0076fb00draws the frame's Texture regions thenFUN_005c1ef0(group)→FUN_005c8b70(group)→FUN_005c8fe0(node)per node.FUN_005c8fe0(node)= the paint pass we co-hook: ensures each line built (FUN_005cd6a0→FUN_005cdc20→ the emitter), then binds each font page and copies the line's per-page glyph batches into the dynamic VB, translated by the line origin[line+0x70]/[+0x74].- The emitter
FUN_005ccbe0(line, text, len, colorState, penXYZ, pageMask, linkState)builds one wrapped line's glyph quads.this(the "line"/node the icon list keys on) owns batches[+0xa0+page*4]and origin[+0x70]. Note the render node the emitter sees has NO back-pointer up to the frame — the editbox discriminator had to be found another way (see below).
Positioning — segmented delegation (co-hook the emitter)
We do NOT reimplement the emitter's intricate glyph vertex math. Instead, in the
FUN_005ccbe0 co-hook, for a line containing an inline texture:
- Split the line at icon boundaries. Render each plain run by calling the ORIGINAL emitter on just that substring — the engine still draws every glyph.
- Thread the pen across runs: on return the emitter leaves the final node-local
pen x in
linkState[4], stored withFSTP dword— a FLOAT bit pattern, not an int. Read it as a float (*(float*)&linkState[4]); an int-cast yields garbage (this bug hid the icon off-screen and dropped the trailing text). - Record an
IconRecordat the pen (node-localx,y) intog_nodeIcons[line]and advance the pen by the icon width. No draw runs during the build — icons are recorded and flushed in theFUN_005c8fe0paint co-hook, which computes each icon's screen rect (line origin[line+0x70]/[+0x74]maps node-local → screen, the same translate the glyph copyFUN_005c8710applies) and queues it toText::InlineTexturePoolas a placement RELATIVE TO THE OWNING FONTSTRING. The pool applies placements on the next frame tick. - Restore
penXYZ[0]on exit (the original never writes it; the draw builder does NOT reset it between left-justified lines, so leaving it mutated cascade-shifts every following line).
FontString pipe-doubling — the escape arrives as ||T…||t
The FontString text sanitizer doubles any pipe that doesn't begin a recognized
escape so it renders as a literal |. 1.12 doesn't know |T, so a caller's
|Tpath:h|t reaches the emitter as ||Tpath:h||t (verified: emitter text length
+2, pipes doubled). The detector therefore matches BOTH the doubled form (the
real-world case) and a clean |T (should one ever arrive undoubled). Normal
doubled pipes (|| ) never match because the next char must be T.
bit-3 batch-clear mode
The emitter clears the line's page batches at its top only when node flag
[line+0x5c] & 0x08 is set (the FontString/static case). Calling the original
per segment would then wipe all but the last run. Handled by doing the clear
ONCE per build (a len==0 original call with bit 3 still set), then clearing
bit 3 so the per-segment calls APPEND, restoring flags on exit. Bit 5 (shadow)
isn't set for these nodes, so the only added work is a harmless colour append.
Multi-line / multi-icon accumulation
The draw builder walks a node's wrapped lines by calling the emitter repeatedly
on the SAME node, advancing the text pointer. So the icon list is cleared ONCE
per build — on the first wrapped line, detected by text == [node+0x48] (the
node's text start) — and icons ACCUMULATE across lines. Multiple icons per line
fall out of the segmentation loop naturally.
Vertical centring — font-relative
penXYZ[1] sits near the text TOP, so the icon centre = penY + fontHeight * g_centerFrac (0.6, calibrated in-game across chat + pfUI's bubble). Font height
comes from the engine's own FUN_005c6fa0(flag, [node+0x1c]) (the emitter's
glyph-sizing call), so centring holds across font sizes without a fixed pixel
nudge. A TALL icon (height > font) centres in its GROWN line (see the tall-icon
sections in Current design) — the string-height co-hook adds the overflow, so
the extra room sits half above and half below the text.
Measure / wrap — co-hook the tokenizer
Line wrap is decided by the measure/fit functions (FUN_005c6940, FUN_005c7470
via FUN_005c7260), which all share the |-tokenizer FUN_005c2810. Left
alone, they count the hidden path text and wrap early. Fix: co-hook the
tokenizer — when it's at an inline-texture span, consume the whole span as ONE
near-zero-width token so every measure/fit caller ignores the path characters.
The emitter detects icons independently (it scans the raw bytes), so the draw
path is unaffected.
Measure width: FIXED at the fs-level choke (GetStringWidth counts icons)
The tokenizer reports an icon span as a near-zero-width token, so at the gxu loop level every measure caller counts the icon as ~0 pixels wide. (The emitter still reserves the render width, so text after an icon positions correctly.) An earlier version of this doc concluded that the gap could not be closed cleanly, because the gxu engine has no single cold choke:
FUN_005c6940(width),FUN_005c7470/FUN_005c7260(wrap), and the hit-test loop each tokenize and accrue width independently.- The token contract has no width field.
- The per-glyph helpers (
FUN_005cabd0/FUN_005c6b70) are the hottest text functions in the engine.
That analysis was right about the gxu level. The choke sits ONE LEVEL UP:
FUN_00772890 = CSimpleFontString::GetStringWidthInternal
(Offsets::FUN_FONTSTRING_STRING_WIDTH) is cold, MinHook-safe, and the single
funnel for exactly 4 callers:
Script_GetStringWidth(0x0079E510)- the GameTooltip auto-size (0x00530640)
- the editbox caret positioner (0x0077DE70)
- the layout effective-width vmethod (
FUN_00772930= fs+0x24 vtbl +0x1C, which feeds auto-width fontstring layout)
It lazily computes into the fs+0xFC cache (anchor units, 0.0 sentinel) via
the measure core FUN_0044D670, then divides the pen-space result by
fs+0x7C.
The co-hook lives in src/text/InlineTexture.cpp. It calls the original,
then adds SumIconAdvances(text) / K when two gates pass:
InlineInterceptActive(text)is true — the same predicate the tokenizer hook stands down on, factored into one function so measure and render can never disagree.- The fs is not an editbox:
fs+0x120 & 0x1000is clear (the fs-level bitFUN_0044D670translates into the gxu editbox flag 0x40).
K = [0x832A4C] × 1024 / [0x832A44] (≈1468) is the anchor→pixel push factor
— the same conversion Script_GetStringWidth applies in reverse when it
pushes. The per-icon advance comes from IconAdvancePen, the same helper
the emitter reserves with (width + 1.5×pad + positive offsetX) — so the
measured width matches the rendered width by construction.
Unit trap (hit on first flight): escape sizes are UI PIXELS. Do NOT divide
the icon sum by fs+0x7C — that field is the layout UI scale (~0.68–1.0).
The original's own out / fs+0x7C applies to a value the measure core
already ran through the FUN_0041AD80 gxu→internal converter, not to raw
pixels. The /0x7C version measured a 16px icon as +44k px.
The hook NEVER writes the fs+0xFC cache: the original can serve the cached
value, so the icon sum is re-derived and re-added per call (idempotent).
The same hook also fixes two layout consumers for free: tooltips auto-size wide enough for icon-bearing lines, and auto-width fontstrings lay out at their true rendered width.
Wrap: FIXED at the shared stepper (FUN_TEXT_WRAP_STEPPER = 0x005C7260)
Wrap decisions also measured icons as ~0, so a chat line with prefix icons
broke as if the icons were not there and the emitter's real advances ran past
the right edge. The choke is the wrap-stepper dispatcher FUN_005C7260: it
lays out one wrapped line per call, and its exactly 4 callers are EVERY wrap
consumer — the draw builder FUN_005CDC20 (render breaks), the height
measure FUN_005C2070, the chars-that-fit counter FUN_005C21C0 (ellipsis),
and the break-array computer FUN_005C2430 (behind FUN_00772B60).
The co-hook shrinks the wrapWidth argument by a minimal feasible
shrink, gated on the same InlineInterceptActive predicate plus the flags
editbox bit 0x40 the dispatcher already carries. The stepper reports each
probe's measured (icons-at-zero) line width in outWidth, which gives a
direct feasibility check: the line renders inside the frame iff its icons
fit in the shrink plus the spare the break left (iconSum ≤ s + (probeW − outWidth)). The hook probes sandboxed (local out-params plus a COPY of the
p10 in/out state byte, so the caller's first-line state is not consumed):
s = 0 first (feasible → no shrink at all — the common short-message case),
escalate by the measured deficit when infeasible, bisect down after the
first feasible hit; ≤8 probes, and with no feasible hit the last escalation
target wins (wraps early rather than overflowing). The feasibility check
carries a HALF-GLYPH tolerance: an auto-width fontstring (single anchor, no
width — e.g. pfUI's addon-list labels) wraps at the icon-inclusive string
width our GetStringWidth hook feeds the effective-width vmethod, so its line
fits with exactly zero slack, and cross-computation drift between the two
hooks' unit chains (plus OUTLINE extras and the trailing-glyph quirk) read
"fits exactly" as "1px over" — shrinking a zero-slack line forces a wrap
that had no business existing. Genuine icon overflow is ≥ a full icon, so
half a glyph separates drift from real overflow. outBreak and
outNext − text are byte counts; outBreak == len means the whole text
fit. Two rejected earlier schemes, for the record: a naive whole-remaining-
text sum shredded an 8-icon line to one word per line, and a fixed-point
iteration on the icon count oscillated (a ~55-byte zero-width escape makes
the break↔icon-count coupling discontinuous — no fixed point exists).
text always points at the REMAINING text, so a continuation line whose
icons are behind it gets sum = 0. Because all four consumers share the hook,
render breaks, GetStringHeight, truncation, and break arrays shift
together. (A _classicapi_InlineTexWrap(n) ring dumped the last 8
icon-bearing calls during bring-up; removed with the other diagnostics in
5e5677b.)
Unit trap #2 (hit on first flight, like the width hook's): each caller passes
fontH/wrapWidth in its OWN space — the draw builder passes node text units
(node+0x1C / node+0x3C), and the fs-level callers (the path chat wraps
through) pass the much smaller anchor-converted space. Subtracting a raw
pixel advance annihilated the small widths to the floor and shredded
icon-bearing chat lines into 2-glyph fragments. The space-agnostic conversion
uses the engine's own convention: the measure loops realize their fontH param
as pixels via FUN_TEXT_FONT_HEIGHT(flag, fontH) (see FUN_005c6940's final
scale), so px → caller units is exactly fontH / fontHPx. The hook computes
the icon sum in true pixels (the same value the emitter reserves) and scales
by that ratio.
Chat hyperlink hover over inline icons works (verified). An emote wrapped in a
hyperlink — |Htel:name|h|T…|t|h, the TwitchEmotes pattern — pops its tooltip when
you hover the icon, not just adjacent text. The hover region is NOT re-measured
on hover: the engine records each hyperlink's screen rect at layout time into a
GXUFONTHYPERLINKINFO array (32-byte entries: rect + link data) via FUN_005cd310,
called from the draw builder FUN_005cdc20 — the same layout pass that runs the
line through our co-hooked tokenizer (FUN_005c2810) and wrap-stepper
(FUN_005c7260). So the recorded rect rides the same icon-aware position
accounting the wrap fix installs; the icon lands inside the hover region for free,
and hovering it fires the frame's OnHyperlinkEnter. This is a consequence of the
wrap fix, not a separate feature. (Ghidra caveat: the decompile of the
FUN_005cd310 call args is mangled — a pointer-as-float + an uninitialized temp —
so this is confirmed by the call path plus in-game test, not the byte-level
formula.)
Still icon-blind (accepted residuals):
- The substring measure (
FUN_00772AE0) still sees icons as ~0. It is a separate function from the hyperlink hover rect above (which works) — nothing consumes it yet; revisit it (also cold) if a consumer needs icon-aware substring widths. - A ~≤1px artifact when an icon is the last token: the gxu width loop ends on
the last glyph's ink width rather than its advance (
FUN_005c6b70gets the remaining-text pointer), and a trailing icon shifts the previous glyph's treatment — the source of the old −0.8px measurement. - An fs whose
fs+0xFCcache was filled while the feature was toggled differently (_classicapi_InlineTexEnable) keeps its old base width until the nextSetText/font change re-dirties it. Debug-toggle-only.
Editbox measure stays raw (by design). The caret/measure path reads the
focused editbox's INPUT buffer in place, and the tokenizer stands down on it
per-editbox (TextInFocusedEditbox pointer-range test — not a global focus
check), so caret math measures the raw |T…|t literal the editbox renders.
The width hook mirrors that with the fs+0x120 & 0x1000 editable gate. One
marginal wobble: the focused single-line chat editbox's display fontstring
carries editable=0 (only multi-line editors set the bit), so the caret
positioner's line-boundary branch (multi-line-only in practice) can see an
icon-adjusted FUN_00772890 on it. Closing that costs a per-token content
compare, which is not worth it.
Editbox exclusion — two COMPLEMENTARY signals (bit 6 + focus global)
Editable text must show raw, editable |T…|t markup, not rendered icons — you
edit macros, tweak icon fields, copy/paste texture strings. This is
retail-correct, verified in-game on a modern client: typing
|TInterface\Icons\INV_Misc_Coin_01:16|t into the chat entry box OR a macro body
shows it raw (no icon) — Blizzard neutralizes player-typed escape sequences
as anti-abuse — while addon/system text (AddMessage, GetCoinTextureString)
renders. Retail's discriminator is the text's SOURCE (trusted vs player-typed),
not editbox-vs-display; a shift-clicked item link renders in the chat box because
it's inserted through the trusted path, but a typed |T/|c does not. Our
editbox-raw + display-renders split reproduces the same observable outcome. (One
mechanism-level divergence we accept: our editbox-raw uses the GLOBAL focus signal
below, so while an editbox is focused OTHER display text that rebuilds also
briefly shows raw; retail suppresses per-source. Cosmetic, and a per-editbox fix
would need hot-path text-buffer matching — not worth it.) 1.12's tokenizer,
unlike 4.3.4's, has no per-render texture-disable bit (4.3.4 uses tokenizer flag
0x1000 to kill only |T, 0x800 to kill all escapes), and editbox text
nodes are NOT distinguishable by class from the render node — the emitter can't
reach the owning frame. It takes two signals together, not one (an earlier
version of this note wrongly called the focus global a redundant "belt-and-
suspenders fallback" — removing it renders the chat/copy boxes' |T as icons):
- Node flag
[node+0x5c]bit 6 (0x40) = EDITABLE — catches the macro editor (MacroFrameText, flags0x4D), which builds its layout once, un-focused, so the focus global never sees it. But single-line inputs (chat entry box,pfChatCopyBox) have bit 6 CLEAR — their nodes are0x0D/0x20D, identical to display FontStrings — so bit 6 can't catch them. - Focused-editbox global
DAT_00cf4dc8(InputFocused(); holds the editbox with keyboard focus, cleared byClearFocus=FUN_0077e410) — catches those single-line inputs. It's GLOBAL (true UI-wide, not per-node), which is why, while an editbox is focused, other display text that rebuilds also briefly renders raw. That's an accepted tradeoff: there is no per-node signal for single-line inputs, and when you're in an editbox seeing raw markup is what you want anyway.
Why the tokenizer's bit-6 gate is load-bearing for RENDER, not just measure:
when the emitter suppresses an editbox it delegates to the ORIGINAL emitter,
which re-enters the tokenizer to lay out glyphs (FUN_005ccbe0 →
FUN_005c2810). On that render path flags is the node's own flags, so bit
0x40 makes the tokenizer stand down and the |T draws as literal text. Drop the
bit-6 gate and the (un-focused) macro editor draws BLANK — the tokenizer eats
the span as a zero-width token and the original emitter renders nothing (verified
in-game). Focused single-line inputs get the same "don't intercept" via
Suppressed() → InputFocused(). So both the emitter and the tokenizer consult
Suppressed() || bit-6; the two must agree or you get blank-vs-raw mismatches.
(Dead end: monochrome render flag DAT_00c2b9dc (FUN_005c8b70 sets it per
group) — un-set at MacroFrameText's build time and flickered as a flush gate.
Dropped. The editbox class vtable is 0x0081c8c0, its script-slot resolver
FUN_0077a310 with focus slots at +0x438/+0x440 — useful if a frame-level
hook is ever needed.)
Descriptor fields + the vertical flip
ParseIcon handles the full positional payload
path:height:width:offsetX:offsetY:texW:texH:left:right:top:bottom:r:g:b.
Texcoords crop a sprite sheet to one cell: u = left/texW, right/texW,
v = top/texH, bottom/texH — e.g. UI-RaidTargetingIcons is a 256×256 sheet,
4×2 grid of 64×64, so marker N's cell is 256:256:<col*64>:<+64>:<row*64>:<+64>.
Vertex colour (r:g:b, 0-255): the last three positional fields tint the
icon. They pack to 0xFFrrggbb — the same 0xAARRGGBB order the tokenizer's
|cAARRGGBB colour path builds (verified from FUN_005c2810's colour branch),
so the value flows straight into the quad's vertex colour and the font stage's
default MODULATE COLOROP multiplies texture.rgb × tint. White (255:255:255,
the default) = untinted. Because parsing is positional, a tint needs all the
preceding fields present; the TintIcon helper passes 0s for width..bottom
(texW/texH 0 disables the texcoord crop → full texture) so the colour lands in
the trailing slots.
Texcoord order: the region's 4-float texcoord setter
(FUN_SIMPLETEXTURE_SET_TEXCOORD) takes the rect Y-FIRST INTERLEAVED
({v0, u0, v1, u1}), matching the engine's {yA, left, yB, right} rect
convention — diagnosed in-game when {u0,v0,u1,v1} rendered a raid-mark crop as
the wrong cell. v is top-down, same as the |T payload's top/bottom fields.
(The removed quad path had the inverse concern: the OpenGL backend put v=0 at
the bottom, so the quad mapped the TOP screen corners to v1 — kept here as the
backend note.)
Build / deploy / test cadence
set -o pipefail; cmake --build build --config Release 2>&1 | tail -5 && cp build/Release/ClassicAPI.dll "C:/WoW/Octo/dll/ClassicAPI.dll"—pipefailstops a failed build from deploying a stale DLL.- The client must be fully EXITED to relink (it loads a symlink to the
linker's output). DLL changes need a full restart, not
/reload. - The embedded
!!!ClassicAPIaddon is symlinked, so Lua-only changes (theTextureTest()harness inUtil/AddOnCompat.lua) need only/reload.
Remaining / optional
- Measure width, height, wrap — all DONE (the three fs-level co-hooks in
Current design). Vertex-colour tint (
:r:g:b) — DONE. The bring-up diagnostics (_classicapi_InlineTexSuppress/Tune/Stats/ProbeFS/RegionCal/Wrapand the capture globals) were REMOVED (5e5677b); only_classicapi_InlineTexEnableremains. - Animated emotes — no DLL work is needed: a TwitchEmotes-style animator
re-
SetTexts each line ~30fps and rewrites the|Ttexcoords to crop the current film-strip frame. That is addon Lua. RLE-compressed TGAs do not decode in 1.12 (uncompressed only) — convert withmagick in.tga -compress none in.tga(no-orient/-flip: the region renderer's texcoord order shows the frame right-side-up). - Still icon-blind (accepted): the substring measure
FUN_00772AE0; the hyperlink hit-test past a tall icon OUTSIDE the link on the same line; and a ≤1px trailing-icon residual inGetStringWidth(the measure loop ends on the last glyph's ink width, not its advance).
Goal & spec
Render the modern inline-texture escape (warcraft.wiki.gg/wiki/UI_escape_sequences#Textures):
|Tpath:height[:width[:offsetX:offsetY[:texWidth:texHeight:left:right:top:bottom[:rV:gV:bV]]]]|t
Atlas markup (|A:atlas:…|a) is Legion+ (needs an atlas DB 1.12 lacks) — out
of scope. FileDataID paths are Legion+ — 1.12 resolves texture PATH strings
only.
Confirmed: 1.12 has ZERO inline-texture support
In-game test on the target client — all of these render as literal text, no icon:
|TInterface\Icons\INV_Misc_Coin_01:16|t
|TInterface\Icons\INV_Misc_Coin_01:16:16|t
|TInterface\Icons\INV_Misc_Coin_01:16:16:0:0|t
Root cause (see 1.12 map below): the shared escape tokenizer has no T/t
case, so |T falls through to "literal | + ordinary glyphs".
Reference: 4.3.4 (C:\WoW\Proudmoore\apwow.exe, build 15595)
4.3.4's text pipeline is a shared |-tokenizer feeding per-purpose loops that
switch on the returned token type. It DOES support |T.
-
Tokenizer
FUN_00613980— reads one token, returns a type code, bytes consumed (*param2), payload char (*param5).|-switch token types:1=color(|c+8 hex),2=reset(|r),3=break(|n/newline),4=||,5=|H,6=|h,7=texture(|T…|t),8=|t,9/10=|K/|kcallback,0xb/0xc=|W/|w,0=ordinary glyph. TheTcase scans forward to the closing|tand returns 7 with the whole span's byte length. -
Field parser
FUN_00617ba0(tokenStart, &desc, size)— splits the|Tpayload on:(helpers:FUN_0040fa50=strchr,FUN_004b3d00=atof,FUN_004b3480=atoi) into a 0x40-byte descriptor:off field +0x10/+0x14path ptr / length (up to first :)+0x18height (font-scaled) — required +0x1Cwidth (defaults to height) +0x20/+0x24offsetX / offsetY +0x28–+0x344 normalized texcoords (texel ÷ texW/texH) +0x3ChasTexCoords flag +0x38–+0x3Bvertex B/G/R/A +0x3DhasColor flag -
Measure loop
FUN_00618430— walks tokens;case 7callsFUN_00617ba0and adds the texture width to the pen. -
Draw emitter
FUN_0061ea10(analog of 1.12FUN_005ccbe0) — itscase 7is the texture draw:FUN_00617ba0(tokenStart, &desc)— parse fields into the descriptor (stored inline on the line-state struct atparam7+0xb, 0x10 dwords).- Compute pen x, width (
desc.width[+0x18 dword = param7[0x12]] * scale), and y from the justify mode[obj+0x58](0=baseline, 1=center, 2=top). - Copy the descriptor to a stack struct and call
FUN_0061e820— the inline-texture quad emit. (FUN_0061dd50handles a region-state 1→2 transition when a texture interrupts a hyperlink capture.)
-
FUN_0061e820— normalizes the 4 quad corners (÷ screen w/h fromDAT_00dd9ea0/DAT_00dd9ea4) and callsFUN_0061e410(1, &verts). -
FUN_0061e410(count=1, &verts)(__thiscall, ECX = a vertex-buffer object) — appendscountquads of 0x40 bytes (one quad = pos + texcoords) to a dedicated inline-texture vertex buffer, growing it as needed (FUN_0061db40). So inline textures accumulate in their OWN batch, separate from the per-font-page glyph batches, each quad carrying its own texture (bound at flush). This is the concrete confirmation of the "separate quad path" — the backport must add such a batch + flush on the 1.12 side.
Target: 1.12 (C:\WoW\Octo\WoW.exe, build 5875) injection map
Same architecture as 4.3.4, different addresses and token numbering. Reached
from Script_GetStringWidth (FUN_0079e510) → FUN_00772890 →
FUN_0044d670 → FUN_005c2050 → the loops.
- Shared tokenizer
FUN_005c2810—~11 callers.|-switch token types:0=color(|c),1=reset(|r),2=break(|n/newline),3=||,4=|H,5=|h,6=ordinary glyph. NoT/tcase →|Thits the fall-through (*param5=0x7c; return 6) = literal|then glyphs. Adding a texture token means picking an unused code (e.g.7). - Measure loop
FUN_005c6940—switch:0/1/4/5zero-width,2break, default glyph (advance viaFUN_005c6b70; kerningFUN_005ca2d0/FUN_005ca4b0). No texture case. - Fit/width loops
FUN_005c6c50(chars-into-width + per-char x, for cursor/wrap) andFUN_005c7470(truncation/ellipsis). Same switch shape. - Draw builder
FUN_005cdc20— reads the layout object's text at[+0x48], handles line-wrap / justify ([+0x54]) / color state, per line calls the glyph emitter andFUN_005cd310(hyperlink rect registration). - Glyph emitter
FUN_005ccbe0— the real quad emitter. Per glyph:FUN_005cabd0(fontFace,char)→ glyph record (atlas page atrec[10], advancerec[0x12], texcoordsrec[0x18..0x1b]), then appends 4 verts to a per-atlas-page batch at[obj + page*4 + 0xa0].case 0/1set/reset color,4/5open/close hyperlink region, default = glyph.
The architectural wrinkle
Glyph quads batch per font-atlas page. An inline |T texture is an
arbitrary texture, not a font page, so it cannot join that batch — it needs a
separate textured-quad draw (its own draw call, correctly ordered against
the glyph batches so it appears inline). This is the substantive work, not the
tokenizing. 4.3.4 solves it exactly this way — captured below: its draw case 7
appends the quad to a dedicated inline-texture vertex buffer at
renderObject+0x9c, separate from the per-font-page glyph batches (see the
FUN_0061ea10 / FUN_0061e820 items under Open items).
Strategy
The tokenizer is shared by ~11 callers, so DON'T just make it return a new
type — the other callers' switches would hit default and mis-handle it.
Instead:
- Reimplement (co-hook) the measure loop
FUN_005c6940and the draw builderFUN_005cdc20/emitterFUN_005ccbe0— copy existing logic (fully decompiled), delegate every non-texture token to the original handling, and add an inline|T…|tcase: measure → advance pen by texture width; draw → emit the arbitrary-texture quad. - Port
FUN_00617ba0(field parse → 0x40 descriptor). Standalone, safe to write now from the 4.3.4 decompilation; needs 1.12 equivalents of strchr/ atof/atoi (trivial or already inOffsets.h). - Leave the shared tokenizer
FUN_005c2810and the other ~9 callers untouched — they keep rendering|Tliterally (wrap/cursor math slightly off inside a texture in v1 — cosmetic, extend later). - Texture load by path — reuse the engine's
Texture:SetTextureloader; quad emit — the primitive 4.3.4's draw case uses (to pin).
Risk: the hot text path (every string every frame). But these are deterministic C functions, NOT the contended nampower/SuperWoW targets, so the MinHook-collision concern is low. Reimplementing two complex loops faithfully is the real cost.
Incremental slices
- Fixed-size
|Tpath:height|t— render + width only (ignore width/offset/ texcoord/color). Proves the end-to-end quad path. - width, offsetX/Y.
- texcoords (
texW:texH:l:r:t:b). - vertex color.
- correct wrap/cursor (extend
FUN_005c6c50/FUN_005c7470).
Open items / next steps
-
4.3.4 draw-side
case 7— captured:FUN_0061ea10case 7 →FUN_00617ba0(parse) +FUN_0061e820→FUN_0061e410(append quad to a dedicated inline-texture vertex buffer). Separate batch, per-quad texture. -
4.3.4 inline-texture buffer located —
FUN_0061e820(RET 0x40, i.e. a 0x40-byte quad struct by value) doesADD ECX,0x9cbeforeFUN_0061e410, so the dedicated inline-texture vertex buffer is at renderObject+0x9c (glyph batches are the+0xa0 + page*4array — the two are adjacent but distinct). Quad struct: positions at+0x8..+0x14, texcoords at+0x20..+0x2c(rest = z / texture handle / color). Appended one quad at a time viaFUN_0061e410(this=buf@+0x9c, count, &quad). -
Flush + path→texture load — NOT traced on the 4.3.4 side by design; its purpose (the flush + per-quad texture bind + path→load mechanism) is fully answered on the 1.12 side below: paint/flush
FUN_005c8fe0, bindFUN_00589e80(0x17,tex)+ drawFUN_005c8f40, loadFUN_00449d90. 4.3.4's own+0x9c-buffer flush is not needed — we implement against 1.12. -
1.12 path→texture loader —
FUN_00770200(textureObj, path, flag, blend=DAT_00878cf0, flag). It's the string-path branch ofScript_Texture_SetTexture(FUN_0079bb40, method-table entry at0x0087c1a0). This is how a|Tpath becomes a bound texture. -
1.12 batch render + textured-quad GPU primitive — FOUND. The paint pass is
FUN_005c8fe0(layoutObj): it ensures each line built (FUN_005cd6a0), then per font page (stride 0x18, indices 0..7 over[obj+0x18c+page*0x18]= the page's texture object) does: - bind texture:FUN_00589e80(0x17, texturePage)(0x17 = the texture render-state selector), - lock dynamic VB:FUN_0058a140(0, stride=0x18, 0x800)→ handle;FUN_0058a080(handle)→ vertex data ptr, - copy the page's built verts from the per-page batch at[lineObj + 0xa0 + page*4](FUN_005ce090=count,FUN_005ce0c0=copy), - draw:FUN_005c8f40(&handle, vertCount)(flush/submit), - unlock:FUN_0058a0a0(handle, 0).**Vertex stride = 0x18** (24 bytes = pos + uv + packed color). So an inline `|T` quad = 4 (or 6) such verts, bound to its own texture. Reuse path for the `|T` draw: `FUN_00589e80(0x17, inlineTex)` → write quad verts → `FUN_005c8f40`. **`FUN_005c8fe0` is the co-hook site for strategy B** — after the glyph batches are drawn, draw the frame's collected `|T` quads. -
Path → bindable texture handle — RESOLVED.
FUN_00770200(SetTexture-by-path) internally callsFUN_00449d90(path, &desc, flags, 0, 1)— the general path→CGxTexture loader (normalizes path, by-name cache, creates on miss viaFUN_0044a140/FUN_0044a310, returns a fallback texture on failure so never null) — and stores the handle attextureObj+0xcc. That handle is the SAME CGxTexture typeFUN_00589e80(0x17, tex)binds (thetex[0x3c]streamable flag + non-null*texthatFUN_00593840checks are CGxTexture fields; font pages and Texture widgets bind identically). So a|Tdraws as:tex = FUN_00449d90(path,&desc,flags,0,1)→FUN_00589e80(0x17,tex)→ write 4 verts (stride 0x18) →FUN_005c8f40(&vb,n). No scratch widget needed if we replicateFUN_00770200's descriptor setup (FUN_0058a980(&desc, blend, …)thenFUN_00449d90); or, simplest, keep one scratch Texture object,FUN_00770200(scratch,path,…), read[scratch+0xcc]. The internal by-name cache makes repeats cheap.
Two implementation strategies once the primitive is pinned:
- A (mirror 4.3.4): own a separate inline-texture vertex buffer, flush it in the paint pass alongside the glyph batches. Faithful, more integration.
- B (immediate): at paint time, draw each collected
|Tquad immediately via the GxU primitive (bindFUN_00770200'd texture, draw one quad). Simpler; inline textures are few, so per-quad draw calls are fine. Likely the better first cut. - Confirm 1.12's tokenizer flag bits (
param4 & 0x100/0x200/0x400/0x800) that gate color/escape handling, so the reimplemented loops pass them through unchanged.
Reality check on scope — how it actually landed
The plan above feared reimplementing 1.12's glyph emitter FUN_005ccbe0 (a
long, intricate function) and the measure loop. It did not come to that. The
shipped design avoids both:
- Positioning does NOT reimplement the emitter — it SEGMENTS the line at icon boundaries and delegates each plain run to the ORIGINAL emitter, so the engine still lays out every glyph. We only track where the icons go.
- Rendering does NOT stand up a separate quad batch — icons are engine-managed regions anchored to their FontString (the removed quad batch was strategy B; regions replaced it).
- Measure does NOT reimplement the loops — three cold co-hooks on the fs-level width / height / wrap functions add the icons' contribution and call the originals.
The result is the largest feature in the project, but built from co-hooks that delegate to the engine rather than from reimplemented layout code. It was verified by in-game iteration over many build/test rounds, as expected.