mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
e2174e16567dec206c836a31f3cbd369dd970151
12
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c447a0d796 |
refactor(frame): one wrapper for each draw-layer invalidate
CSimpleFrame::NotifyLayerChanged (FUN_FRAME_NOTIFY_LAYER_CHANGED, 0x0076A990, __thiscall (frame, layer)) was wrapped by hand in Cooldown, ModelScene and ClipChildren, and CScriptRegion::NotifyLayerChanged (FUN_REGION_NOTIFY_LAYER_CHANGED, 0x0077FDF0, __thiscall (region)) in the inline-texture pool and the texture wrap. Each file carried its own typedef for the same engine call. frame/LayerChange.h now holds the two: NotifyFrame and NotifyRegion. All five files call them. |
||
|
|
1cdd443e53 |
refactor(text): inline icons take their line's fade when its colour changes
The icon textures have no frame, so the frame alpha fold (0x0077FAC0) skips them and their only alpha is the one copied from their fontstring's colour (colors[0], OFF_FONTSTRING_COLOR_ARRAY). The tick read that colour for every fontstring with icons, every frame, and re-coloured the icons when it changed. Every change of that colour ends in the fontstring's region slot 8, CSimpleFontString::OnColorChanged (0x00772180, `ret 4`): SetVertexColor (0x0077F750) calls it after storing a colour, which is how the chat fader and SetTextColor reach it, and the frame alpha setter (0x0076A690) calls it on each region of the frame. It folds the colour (0x0077FAC0) before it hands it to the built string, so the value is final when it returns. A co-hook on it now copies the colour onto the line's icons in the same call. No other loaded DLL refers to that address. The batch reads a texture's colour through a pointer, so no layer rebuild is needed. The glue value-follow (FadedColor) is unchanged. The tick only deletes orphaned textures now; the per-fontstring applied-colour stamp is gone. |
||
|
|
ada33825ad |
refactor(text): inline icons are placed at build and at move only
Inline icons were placed on three paths: the RebuildString refresh, the paint flush (FUN_TEXT_PAINT co-hook), which recomputed every icon line's placements after every paint and queued any change, and the tick, which applied the queue. Measured over normal play, the paint flush never supplied an icon the rebuild had missed. All it did was re-place icons that had moved, 456 times: almost all by float noise (1e-5 px), each one re-anchoring the icon and rebuilding the fontstring's layer; the rest by up to 0.9 px. That 0.9 px is a move. A fontstring whose size does not change keeps its built string: the rect callback (0x00772D40), SetTextOffset (0x00772100) and the animation translation only move it, through TextBlockSetStringPos (0x0044D600) -> CGxString::SetPosition (0x005CCB10), which re-finalizes the node origin (0x005CDF70) before it returns. The origin is floored to whole render-target pixels, so an icon anchored to the unrounded fontstring rect drifts off its glyphs by up to a pixel. The icons are now placed when the string is built (the RebuildString refresh) and after each TextBlockSetStringPos, from a co-hook on it. No other loaded DLL refers to that address. The move lays the node out first (FUN_TEXT_ENSURE_BUILT, as the rebuild does): a colour change can leave the node unbuilt until the next paint, and with no built lines (+0x9C) the origin finalize returns early with the raw normalized position in the origin, which placed those icons at the bottom-left of the screen. The placement now refuses an unbuilt node. Only nodes with icon records are laid out early. Removed: the paint flush's placement queue, the pool's queue and dirty flag, and the tick's apply. The pool has one entry point, Apply, which skips an icon set equal to the one applied. The paint flush keeps its other jobs (the stuck-blockless re-dirty, the stale-record guard and the baked-alpha mirror); the tick keeps the orphan deletes and the fade mirror. |
||
|
|
dd584703a2 |
refactor(text): place inline icons once, at scale 1
An inline icon texture was given its fontstring's layout scale (layout slot 0x10, as AddRegionToLayer gives a region its frame's), its anchor offsets were divided by that same scale, and every tick read each drawn icon's resolved width back and folded the error into a per-icon correction, re-placing the icon until it settled within 0.5%. The textures have no frame, so that machinery has nothing to correct. The layout constructor (0x00767680) sets the scale (layout +0x58, region +0x7C) to 1.0 and nothing else changes it without a parent. RelativePointGetX/Y (0x007A2F90 / 0x007A3070) place a point at the positioned region's own scale times the stored offset plus the relative edge, so with scale 1 the fontstring-relative edges land exactly. The scale copy and the divide cancelled, and the correction stayed at 1. The icon is now placed with two SetPoints at the raw offsets and the layout realize (0x00768060, SetDeferResize(0), which resizes at once when a resize is pending). Removed: the scale copy, the correction and the per-tick rect readback, and VTBL_LAYOUT_SET_LAYOUT_SCALE, which named the same slot as VTBL_LAYOUT_SET_SCALE. |
||
|
|
5911298acd |
fix(text): inline icons are drawn by their line, as 4.3.4 does
Inline icons were CSimpleTextures registered on the fontstring's parent frame, with their visibility copied from the line once per tick, after the draw. Any line that hid kept its icons for one more frame; once chat lines moved with their text, a line scrolled off the top flashed its icons above the chat frame. 4.3.4's CSimpleEmbeddedTexture has no frame, and the fontstring draws it: CSimpleFontString::Draw queues the string, then QueueTextures. 1.12's equivalent is CSimpleFontString::Emit (0x00772E50), the only caller of AppendToBatch (0x00773080). The icon textures are now made with no frame (SimpleRegionConstruct skips SetRegionParent for a null parent; the frame-alpha fold 0x0077FAC0 tests the parent), anchored to the fontstring and given its scale through layout slot 0x10, as AddRegionToLayer does. A hook on Emit adds a line's icons to the layer batch right after its text, and only when the text went in (the batch count at +0x4 grew), so an icon draws exactly when its line does, in the same frame. The batch copies each texture's handle, blend and colour count when built (0x00772FD0) and reads vertices, texcoords and colours through pointers, so a change to a line's icon set marks the fontstring's layer (NotifyLayerChanged 0x0077FDF0), and moves and fades need no rebuild. 4.3.4 sets the textures up in UpdateString. RebuildString (0x007724A0) now does the same: when its gate passes (layout flags +0x60 bit 1, `test byte [esi+0x60],1`) it replaces the built string, so the line's icons are dropped, the new node is laid out (FUN_TEXT_ENSURE_BUILT) and its placements applied at once. The paint flush stays the backstop. Removed: the per-tick visibility mirror, the freshness expiry, region Show/Hide and re-parenting, and the SMF early apply with its _classicapi_InlineTexEarly toggle; the rebuild refresh covers what it did, and it rebuilt every icon line on every layout. The textures are deleted through their vtable slot 0 (as the frame destructor deletes regions) one tick after their fontstring dies or a reload, once the batches holding them were rebuilt. |
||
|
|
f061179646 |
refactor(region): one region destruction signal; inline icons drop the vtable guess
Frame::RegionDestruction co-hooks SimpleRegionDestruct (0x77F6F0), the destructor body every region ends in, and runs its listeners first. It has exactly three callers: the base region's deleting destructor (0x77F6C6), ~CSimpleTexture (0x76FD40, a tail JMP; its only caller is the deleting destructor 0x76FD10) and ~CSimpleFontString (0x770E50, a tail JMP; called by its deleting destructor 0x770E20 and by a subclass's, 0x789320). The texture and font string vtables (0x81C718, 0x81C778) are written only by their constructor and destructor, so no inlined destructor skips the hook. It replaces FontString::Destruction, the font-string-only hook from the previous commit; the duration text binding now listens here. InlineTexturePool kept icon state keyed by font string pointer and judged a key alive by its first word matching a vtable it had seen painted. That guess had a hole: a destroyed font string's block goes back to the region pool and can come back as another font string, vtable and all, and the dead key's icons then served the new one. It also read possibly-freed memory on every tick. Now a destroyed key takes its entry with it at once, so the address starts clean; its icon regions live on with their parent frame and are hidden on the next tick, never inside the destructor that reported the death. A destroyed icon region is dropped wherever it is held, and a live key that loses one is placed again. The learned-vtable sets, IsLiveFontString and IsLiveRegion are gone. The SEH latch stays, for the engine region calls the tick makes from paint-time data. |
||
|
|
42ed0d27c7 |
Port the later clients' Cooldown API (#112)
* Add retail Cooldown methods and OnCooldownDone Port the post-4.3.4 Cooldown API onto the native CGCooldown frame: Clear, Pause/Resume/SetPaused/IsPaused, GetCooldownTimes, GetCooldownDuration, GetCooldownDisplayDuration, SetCooldownDuration, SetCooldownFromExpirationTime, the modRate argument, SetDrawSwipe, SetDrawBling, SetSwipeColor, SetEdgeColor, the drawSwipe/drawBling XML attributes, and the OnCooldownDone script (via Frame::ExtraScripts). Behavior follows retail probes, not the generated doc strings: the getters report the end flash once the sweep ends, modRate scales the flash and the display duration but not the sweep, and a reverse cooldown flashes and hides like any other. Add CooldownFrame_Set, CooldownFrame_Clear and CooldownFrame_SetDisplayAsPercentage to the embedded addon. * List the new Cooldown methods in the README table * Add Cooldown swipe, edge and bling textures SetSwipeTexture, SetEdgeTexture and SetBlingTexture, and the <SwipeTexture>, <EdgeTexture> and <BlingTexture> XML elements, split 4.3.4's star texture into three slots. An empty file is the engine's solid texture tinted by the slot colour, and Interface\Cooldown\edge maps to the built-in edge texels. A setter without r, g, b keeps the colour, as retail does. Slots left unset get 4.3.4's textures at the first SetCooldown, so the defaults stay 4.3.4's. The swipe's texcoords now map its positions over the frame so a custom texture lines up. * Add Cooldown rotation SetRotation / GetRotation and the XML rotation attribute (degrees) move where the sweep starts, clockwise from the top, as retail does. The sweep is now one polygon along the frame's outline in place of 4.3.4's four octant functions, with the same timing (each half side an eighth of the duration) and, at rotation 0, the same shape. The one difference is 4.3.4's reverse octant 1, which drew one triangle twice. * Add Cooldown countdown numbers Every Cooldown gets a countdown font string (FRIZQT__ 16 OUTLINE, centred), shown while retail's countdownForCooldowns CVar is 1; the CVar defaults to 0, so the default look stays 4.3.4's. The text follows retail: seconds, then m:ss below the abbreviation threshold, then whole minutes, hours and days rounded up, and nothing for cooldowns no longer than the minimum duration or during the flash. Adds SetHideCountdownNumbers / GetHideCountdownNumbers, GetCountdownFontString, SetCountdownAbbrevThreshold / GetCountdownAbbrevThreshold, SetMinimumCountdownDuration / GetMinimumCountdownDuration and the hideCountdownNumbers and minimumCountdownDuration XML attributes. * Add the Cooldown countdown milliseconds threshold SetCountdownMillisecondsThreshold / GetCountdownMillisecondsThreshold: below the threshold the numbers show tenths, rounded up, as retail does (threshold 5: 4.973 shows 5.0, 3.24 shows 3.3, 0.039 shows 0.1). The default is 0, so the numbers stay whole seconds. * Fix the Cooldown review findings - A zero-length timer (a new frame, SetCooldown(t, 0)) hides without the bling flash or OnCooldownDone, instead of flashing and reporting (now, 1000) from the getters. - Countdown text rounds up with integer math (700 ms read "0.8") and picks its unit on the rounded-up seconds (59.4 s read "60", not "1:00"). - SetMinimumCountdownDuration and minimumCountdownDuration clamp to the uint32 range. - The edge texcoord rotation uses the guarded done fraction (0/0 gave NaN). - Texture slots are one array with per-slot tag, default file and draw layer (Offsets::DRAWLAYER_*), replacing the ternaries and bare 2/3. - The header lists where the state machine follows retail over 4.3.4. edge.blp is now served to every texture load by texture/Builtin.cpp, a hook on TextureCreateFromBlp that falls back to the DLL's texels only when SFile has no such file; TextureCreate caches and ref-counts it like a file. Cooldown loads it by path and drops its edge special case. Frame::Region::CreateTexture / CreateFontString replace the hand-rolled pool-alloc + ctor copies in Cooldown, LinePool, BarTexture, SoftTargetIcon and InlineTexturePool. |
||
|
|
0c8468cf2f |
refactor(reload): auto-register per-/reload cleanup; fix Time::Timer stale refs
Modules that keep reload-fragile file-static state (Lua registry refs, frame/object-pointer-keyed maps, cached event-slot indices) each expose a PrepareForReload() that DllMain called from the FrameScript_Initialize hook. That list was hand-maintained, so a new module could silently forget to wire itself in -- the failure mode behind the Frame::Attributes stale-ref bug and Tooltip::SetEvents issue #33. Add Game::ReloadAutoRegister + Game::RunReloadCleanups(), mirroring the existing ModuleAutoRegister / HookAutoRegister / WorldTick::AutoSubscribe patterns. Each module self-registers with one file-scope line after its PrepareForReload: static const Game::ReloadAutoRegister _reloadReg{&PrepareForReload}; DllMain's 11-call manual list collapses to a single RunReloadCleanups(); a new module can no longer be forgotten. Player::NameCache::Flush stays an explicit call -- it's a save-before-teardown, not a stale-state clear, and also runs on the glue-return path. A sweep of all file-static state found one uncovered module: Time::Timer pins C_Timer.After/NewTimer/NewTicker callbacks in the Lua registry but never released them on /reload -- a surviving/stale ref could fire a dead closure. Add Time::Timer::PrepareForReload (release each pending timer's registry callback, clear the queue) and self-register it. - Game.{h,cpp}: ReloadAutoRegister + RunReloadCleanups. - DllMain.cpp: collapse the manual list to RunReloadCleanups(); drop 6 now-dead includes. - 11 existing reload modules + Time::Timer: add the self-register line. Behavior-preserving (same cleanups, before the Lua teardown); auto-register order is unspecified across TUs but every callback only clears its own state. |
||
|
|
a2c51a1ae6 |
fix(inline-texture): place chat icons pre-render to remove the one-frame lag
A ScrollingMessageFrame re-SetTexts every visible line on each new message, and the engine builds each line lazily at paint. The icon regions are separate objects whose placement is only known once a line builds mid-paint - after the frame's texture pass already drew - so on a content change the new glyphs appeared one frame before their icons caught up. Co-hook the SMF display refresh (FUN_00788750), which runs pre-render from the frame's own methods. After it, force each icon-bearing line to resolve+build via the engine's own Realize(0) -> RebuildString -> ensure-built path and apply its icon placement synchronously, before the frame draws. The placement math (ComputePlacementsForNode) and the per-fs apply (ApplyDirtyBranch) are shared with the existing paint-flush / FrameTick pipeline, so the later flush dedups to a no-op. Additive and best-effort: any line whose rect is not resolvable in time falls back to the unchanged paint + tick pipeline (correct, one-frame lagged). Gated by a new _classicapi_InlineTexEarly toggle (default on) with an SEH latch; the whole feature keeps its _classicapi_InlineTexEnable kill switch. |
||
|
|
e9407f6564 |
fix(text): follow text-colour changes on icon-bearing fontstrings
The glue AddonList greys a disabled addon's title through SetTextColor RGB alone (gold <-> gray, alpha stays 1.0). An icon-bearing title followed neither channel: the icons only ever mirrored the colour's ALPHA byte, and the TEXT was frozen at its bake-time colour -- a segmented (bit-3) node carries baked per-glyph colours, and the engine's colour setter (FUN_005CCB40) skips the rebuild-invalidate for bit-3 nodes because UNIFORM bit-3 text recolours live at paint. Plain titles swapped fine; icon-bearing ones didn't. Two mechanisms, matching what each colour channel means: - Text: re-bake on base-RGB change, everywhere. The emitter stamps the node's base colour (node+0x2c) at bake; the flush compares it against the live value and, on an RGB divergence, calls the engine's own node invalidate (FUN_TEXT_NODE_INVALIDATE = 0x005CDEF0 -- exactly what the colour setter does for accumulation nodes: clears the built state and frees the page buffers, so the next paint re-emits). The re-bake recolours base-coloured glyphs while |c runs keep their own colours -- baked per-glyph RGB cannot be patched in place. Alpha-only changes still take the cheap in-place alpha mirror (fades animate per frame; every baked glyph carries the node alpha, so the byte-patch is safe). - Icons: brightness-follow on the GLUE screen only. The pool's fade signal widens from the colour's alpha byte to the whole folded BGRA colors[0] dword (FsColorKey), so a pure-RGB SetTextColor now trips the change detector at all; FadedColor then scales the icon by the text colour's VALUE (max of R/G/B) when no local player exists. Value-follow dims but can never tint -- gold and red titles have a 255-max channel, factor 1.0 -- and in-world icons keep following alpha only (retail semantics: guild-green chat must not tint emotes). Verified on the glue addon list: toggling now swaps title text AND icons together (gold + bright <-> gray + dimmed), |c-coloured segments keep their colours through the re-bake. |
||
|
|
c54556f6a1 |
refactor: centralize engine field/global access via Game::Read/Ref/Ptr
Replace the raw `*reinterpret_cast<const T *>(base + Offsets::OFF_X)` idiom (and its double-cast variant when base wasn't already a byte pointer) with three typed accessors in Game.h: Game::Read<T>(base, offset) field value read Game::Ref<T>(base, offset) writable field lvalue Game::Ptr<T>(base, offset) pointer to a field (arrays / out-params) Game::Read<T>(address) / Ref<T>(address) fixed-VA globals Pure mechanical refactor, zero behavior change: ~330 cast sites across 84 files collapse to 651 helper calls. Offsets stay in Offsets.h per the single-source-of-truth rule — the helpers only remove the cast noise and fold away the inner `reinterpret_cast<uint8_t*>(obj)` base casts. Left as raw casts by design: FUN_* function-pointer casts, void*/char* VA handles passed as arguments (caches, method registries), subobject- anchor pointers fed to __thiscall helpers, `void *volatile` player-ptr readiness gates (converting would strip volatile), and VA-as-array-base captures that are subscripted later. |
||
|
|
76f48de67f |
Inline |T…|t texture escapes (with coin strings, texture methods, and TextureUtil) (#24)
* 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 (
|