mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
998deeac4ab7645945bc594feab2260f6ff891e8
403
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f2af2734f0 |
docs: trim internal implementation detail from FontString entries
User-facing API docs should describe the contract (behavior, inputs, outputs, errors, observable caveats), not how a method is built or which engine path it uses. Drop the "engine already computes this internally / only adds the binding / comes from the engine's own wrap math / reads what it last drew and compares" narration from the FontString entries, keeping every observable behavior and caveat (the setup requirements, the must-have-rendered-once note, the icon-inclusive widths, the <=1px rounding note). |
||
|
|
dc13d7bbfc |
fix(fontstring): SetFormattedText uses engine str_format, not _G
SetFormattedText resolved _G.string.format and called it, so an addon
that replaced string.format could hijack or break it. Push the engine's
own str_format C function instead (strlib "format" entry 0x007FD3D0,
verified by decode) and pcall it -- immune to global replacement, and
matching retail, whose SetFormattedText formats in C. Also simpler: one
PushCClosure replaces the _G table walk and its two failure branches.
Verified in-game: with both string.format and the format global replaced
by a stub, SetFormattedText("%d apples", 5) still renders "5 apples".
|
||
|
|
87acb70c5b |
feat(fontstring): add IsTruncated, SetMaxLines/GetMaxLines
Backport three FontString methods, each working WITH the engine's own text-layout machinery instead of reconstructing it: - IsTruncated(): did the engine cut the text off with an ellipsis? Reads render truth -- the built text node keeps a copy of the string it actually laid out (node+0x48), the ellipsized form on truncation -- and compares it to the source. Same "displayed vs full" check retail does (5.4.8 inner fn 0x0045E001). Re-calling the display-text resolver from Lua cannot work: it reads the laid-out rect (fs+0x64), which is zero between frames, so it never sees the bound. - SetMaxLines(n)/GetMaxLines(): cap the fontstring to n wrapped lines, ellipsizing the rest. Writes the engine's own per-fontstring maxLines field (fs+0x128, already honored by the truncation resolver) and re-invalidates the layout the way SetText does (drop caches, release node, notify region). Vanilla has no SetWordWrap -- the fs->layout flag translator exposes no no-wrap bit -- so SetMaxLines(1) is how you make a single-line, ellipsized label. Also correct a mislabeled bit in the inline-texture notes: fs+0x120 bit 0x1000 (gxu/node bit 0x40) is NON-SPACE-WRAP (what SetNonSpaceWrap toggles), not a dedicated "editable" flag. The inline-texture code uses it as an editbox proxy, which works because multi-line editors enable non-space-wrap while display text does not; the comments now say so, with the rare-edge-case caveat. Documentation only, no logic change. Verified in-game: IsTruncated true/false across bounded/unbounded boxes; SetMaxLines caps of 1/2/9/0 with matching GetNumLines and IsTruncated. |
||
|
|
92a959c381 |
feat(fontstring): backport GetWrappedWidth
The rendered width: the widest wrapped line -- the method that
completes the width trio (GetStringWidth and GetUnboundedStringWidth
both measure the string on ONE line; verified in-game they agree to
float noise). Uses the tooltip auto-size's own recipe: break positions
from FUN_FONTSTRING_BREAK_ARRAY, widest per-segment measure through
FUN_FONTSTRING_MEASURE_SUBSTRING -- both icon-aware through the
existing co-hooks. Segments are trimmed of the whitespace the wrap
consumed (the render never draws it, and a trailing space flips the
last real letter from ink to full-advance treatment, +~1.5px measured).
The wrap budget (shared with GetNumLines' unbuilt fallback via
WrapBudget) is rectWidth / fs+0x7C, calibrated EMPIRICALLY against the
render with a three-point probe on a 100px box at ~0.91 scale, using
text whose candidate lines measure 78.1 / 94.6 / 101.6 px:
raw rectW -> effective budget ~91px -> broke one word EARLY
rectW/scale^2 -> effective budget ~110px -> broke one word LATE
rectW/scale -> effective budget 100px -> breaks exactly where the
render does (94.6 <= 100 < 101.6)
All three observations fit budget_px = pxOf(param) x scale. A paper
derivation from the rebuild's node-budget chain predicted /scale^2 --
one hop of that chain models live behaviour wrong; the probe data is
recorded in the code comment so the broken paper chain doesn't get
re-derived. (FUN_00772B60 multiplying its width arg by fs+0x7C before
gxu, and FUN_0044DB50 normalizing through FUN_0041AE40, are verified
decompiles.)
Verified in-game: 100px box, wrapped 93.8 / one-line 165.7 / 2 lines,
break at the render's own position. Residual <=1px vs a direct measure
of the line text -- the engine's own per-glyph measure conventions
(ink-vs-advance, kerning-variant flag), the same class GetStringWidth
carries; documented in API.md.
|
||
|
|
efc6b29b6b |
docs(fontstring): correct GetUnboundedStringWidth vs GetStringWidth
The entry claimed GetStringWidth measures inside the wrap box -- it does not, on any client: both methods measure the string on ONE line (verified in-game: a fontstring wrapping in a 100px box reports ~165px from both). They differ only on modern clients and only for ellipsis-truncated text, where GetStringWidth reports the displayed width; 1.12's getter never applies truncation, so the two always agree here. The as-rendered width (widest wrapped line) is GetWrappedWidth, which 1.12 lacks. |
||
|
|
b09db4d5a5 |
feat(fontstring): backport GetUnboundedStringWidth, GetNumLines, GetLineHeight, SetFormattedText
Four modern FontString bindings 1.12 never shipped, all thin wrappers over engine machinery already verified in this codebase (fontstring/Metrics.cpp grows from the GetStringHeight backport into the general metrics module): - GetUnboundedStringWidth(): the substring measure (FUN_FONTSTRING_MEASURE_SUBSTRING) over the whole string (len 0). Icon-aware for free -- the call routes through the InlineTexture co-hook. Verified in-game it agrees with GetStringWidth to float noise, which is retail parity: both measure unwrapped (the classic gotcha; the rendered width is GetWrappedWidth, a future backport). - GetNumLines(): render truth from the node's built-line count (OFF_TEXT_NODE_BUILT_LINES = 0x9C, the draw builder's own counter / early-out gate) once painted; for an unbuilt node, the engine's break-array computer (FUN_FONTSTRING_BREAK_ARRAY = 0x00772B60, the tooltip auto-size's own segment source -- icon-aware via the wrap-stepper hook) against the fs's rect width. Empty text 0; no wrap constraint 1. Verified: 165px text in a 100px box reports 2. - GetLineHeight(): the fs font-height getter (FUN_007727b0) through the standard push conversion; excludes spacing, like retail. - SetFormattedText(fmt, ...): resolves the LIVE string.format (addon replacements honoured), pcalls it over the varargs, propagates format errors as real Lua errors, and sets through the engine's FUN_FONTSTRING_SET_TEXT so sanitizer/escape handling is identical to SetText. New Offsets entries carry the derivations; docs/API.md documents all four under the FontString section. |
||
|
|
67172c95f7 |
feat(model): add Model:SetCreature; dress character displays natively
SetCreature(creatureID) resolves through the client creature cache to a display ID, then loads like SetDisplayInfo (uncached entry = no-op, documented with a RequestLoadCreatureByID recipe). Character-based displays (extendedDisplayInfoID != 0) are now dressed by the engine's own CharComponent compositor, mirroring CGUnit_C::UpdateCharacterCustomization's NPC branch field for field: baked body texture, hair/facial-hair geosets (CharHairGeosets, CharacterFacialHairStyles), equipment geosets (sleeves, robe->trousers, tabard), and helm/shoulder attachment models with HelmetGeosetVisData hiding. Dress jobs run on WorldTick behind the engine's own model-loaded gate, one compositor per Model frame, kept until the frame loads another display or the reload teardown (PrepareForReload). Attached helm/shoulder children additionally get the frame's light/fog pre-render callback: the frame only registers it on its own instance, so the children rendered pure black (verified in-game -- a light tint colored the body but not the equipment). Weapons cannot show: NPC weapons are server-pushed per spawned unit, not in any client table. The manual baked-skin/hair-texture appliers are superseded by the compositor and removed, along with the geoset debug probes (_classicapi_ModelInstance/Peek/Poke). Creature::Info gains a public DisplayID(creatureID) for the cache resolve. |
||
|
|
6b13368e65 |
feat(fontstring): backport FontString:SetRotation / GetRotation
Generalizes the region-transform module (formerly texture-only) to serve the FontString method registry too, backporting the modern `fontstring:SetRotation(angle [, cx, cy])` and `GetRotation()`. Rotation is visual only, matching retail: GetStringWidth/GetStringHeight/ GetRect/SetPoint stay axis-aligned. A positive angle is CCW, same convention as Texture:SetRotation; the optional cx,cy pivot is a superset of retail (centre-only). How it works: the text paint copy-out (FUN_005c8710) is translate-only, so a rotation baked into the node-local glyph verts survives to screen. SetRotation rotates the live verts immediately (like the texture path) around the vert bounding-box centre, idempotently via an axis-aligned baseline snapshot (restore -> rotate). The baseline is re-captured on every fresh vertex bake, wired through inline-texture's DrawBuilder co-hook (gated on g_buildEmitSeq > 0 so clean paints never double-rotate, since inline-texture owns every text-render hook). Node page-buffer vertex layout added to Offsets.h (cross-verified across the emitter, FUN_005c8710, and FUN_005ce0c0). Known limitation: inline |T icons in a rotated fontstring don't turn with the text (separate anchored regions). Plain text rotates correctly. |
||
|
|
9b34ceff9e |
feat(unit): add UnitCreatureID(unit)
The unit-token twin of C_CreatureInfo.GetCreatureID — resolves the token to a GUID and reads the creature-template entry vanilla packs into bits 24-47. nil for players, empty tokens, and non-creature/pet GUIDs. Factor the entry extraction + creature/pet gate out of GetCreatureID into a shared Guid::CreatureEntry so both callers use one source of truth for the GUID bit layout. |
||
|
|
a373a775cf | Clarify UnitSpellTargetName docs | ||
|
|
e9014801b6 |
docs: move UnitSpellTargetName to the Unit section
It's a Unit* function taking a unit token, so it belongs with the other Unit calls, not under Spell. Relocates the API.md section + ToC entry and the README calls-table row. |
||
|
|
dc8a510611 |
feat(spell): add UnitSpellTargetName(unit)
Returns the name of the unit a caster is casting/channeling a spell at, or nil. The cast's target rides in SMSG_SPELL_START (SpellCastTargets: u16 mask + packed GUID when TARGET_FLAG_UNIT) — we already parse that packet for cast timing and just stopped before the target block. Extend the parse to capture the target GUID for the player (g_castTargetGuid) and remote units (RemoteCast.targetGuid), gated on an active cast so a stale target is never returned. nil when the unit isn't casting, the spell has no unit target (self/ground/item), or the target's name can't be resolved. Factor the GUID->name chain (object manager -> friends -> NameCache) out of UnitNameFromGUID into a shared Player::Info::NameFromGuid so both callers use one source of truth. |
||
|
|
621d1a9db9 |
feat(attributes): cast spell without a unit via CastSpellByName
A `type="spell"` click-cast button with no `unit` attribute did nothing: the `spell` verb bailed the moment no unit resolved. Now it reads the `spell` attribute first, then branches — with a `unit` it casts at that unit via C_Spell.CastAtUnit (unchanged), and with no `unit` it falls back to the plain global CastSpellByName on the current target, like `/cast`. Fixes #18. |
||
|
|
acc9a85bc6 |
feat(spell): CastSpellNoToggle accepts an optional unit token
CastSpellNoToggle(name | spellID [, unit]) now takes a unit token as an
optional second argument, so the spell fires at that unit without
changing the current target:
CastSpellNoToggle("Auto Shot", "focus")
CastSpellNoToggle("Shoot", "targettarget")
The spam-safe toggle gates run first and are unchanged: if the requested
spell is already auto-repeating or its self-aura is already up, the call
stays a no-op and the unit is ignored. When the spell does cast and a
unit is supplied, it dispatches through the existing Spell::AtUnit core
(resolve token -> GUID -> dispatch) instead of the plain CastSpellByName
-- a unit-target/auto-repeat spell fires straight at the unit, a ground
spell lands at its feet, and an unknown token raises the engine's
standard "Unknown unit" error. No new offsets or hooks.
Fixes #22.
|
||
|
|
207d47c8b8 |
feat(bindings): backport direct-action and override binding APIs (#19)
* feat(bindings): backport direct-action and override binding APIs
Add SetBindingSpell/Item/Macro/Click plus the owner-scoped
SetOverrideBinding family. Store permanent commands through vanilla
SetBinding, execute SPELL/ITEM/MACRO/CLICK in the resolved-command hook,
and layer priority overrides ahead of the native binding table.
Factor raw and saved macro dispatch into Macro::Execute so click
attributes and binding commands share the same parser fallback. Preserve
key-down/key-up pairing when overrides change during an action.
Document return values, persistence, precedence, macro-text usage, and
the deliberate 1.12 differences in README and docs/API.md.
* fix(bindings): normalize override key order and preserve command exec-context
Two fidelity gaps in the override binding layer, both verified against the
1.12 binary:
- Override key matching now normalizes modifier order to the engine's own
keypress form (ALT-CTRL-SHIFT- before the base key, per FUN_004b6630), so a
caller passing "CTRL-ALT-F" matches the "ALT-CTRL-F" the engine builds at
keypress. Prefix-stripping keeps the minus base key intact ("SHIFT--").
- Override-dispatched commands now run inside the same execution context the
engine wraps around a native keypress (save/zero/restore DAT_00ceeac0, its
nesting depth DAT_00ceeac4, and the manager +0xD8 mid-command flag, per
FUN_004b7990). Without it, an ordinary Bindings.xml command routed through
SetOverrideBinding ran without the context its handler expects. The native
binding-table path is untouched (the engine already establishes context
before the co-hooked FUN_004b7b50).
Adds the three verified offsets to Offsets.h and documents the any-order,
case-insensitive key handling in docs/API.md.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
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 (
|
||
|
|
d366fec43e |
fix(attributes): restore the previous target after a macro click-cast
The `macro` verb selected the clicked unit and left it targeted (Clique's click-heal minus the restore). Snapshot the current selection GUID, retarget the clicked unit, run the macro, then restore the prior target via FUN_TARGET_BY_GUID (which validates the GUID and drops a stale one), or ClearTarget when there was no prior target. The macro's actions dispatch synchronously while the clicked unit is selected, so restoring afterward doesn't affect them. |
||
|
|
4d5fe8d41b |
feat(spellbook): add C_SpellBook.GetSpellBookItemInfo
Backport C_SpellBook.GetSpellBookItemInfo(slotIndex, spellBank) -> table, reusing Spell::Info's DBC reader. slotIndex is 1-based across the book; spellBank is Enum.SpellBookSpellBank (0 = Player, 1 = Pet), resolved via Spell::Lookup::SpellbookSlotToID. Returns nil for an empty/out-of-range slot, matching retail. Fields map from Spell.dbc: itemType is Spell (player) or PetAction (pet) - vanilla's book holds only real spells, so None/FutureSpell/Flyout never occur; actionID == spellID (no override system); name/subName from the localized Name/Rank; isPassive from Attributes; isOffSpec always false. iconID is the icon PATH string (vanilla has no fileID), the same deviation as C_Spell.GetSpellInfo.iconID; skillLineIndex is omitted. Also register the two Enum tables the return contract references (non-destructively, like the other Enum.* additions) so info.itemType == Enum.SpellBookItemType.Spell comparisons work: Enum.SpellBookSpellBank and Enum.SpellBookItemType. Document in docs/API.md (SpellBook section + both Enum entries) and list in README. |
||
|
|
783ffd05bf |
feat(aura): Carnage Rip/Rake refresh + signal duration-mod changes
Turtle's Carnage refreshes the caster's Rip and Rake off Ferocious Bite, behind a per-combo-point roll whose outcome the client only sees as the combo point the proc returns. A src/turtle/Carnage watcher arms on a Ferocious Bite send and confirms on the first combo-point rise, then refreshes the cached auras. Verified against tortoise-wow spell_druid_carnage: icons 108 (Rip) / 494 (Rake), family bits 0x800000 / 0x1000, caster scoping, and RefreshHolder (restore the aura's own applied duration). A cache duration edit has no engine packet behind it, so nothing re-fired UNIT_AURA and event-driven aura bars never saw the change. The trigger mods (ApplyMod) and the Carnage refresh now enqueue the affected unit, and the WorldTick flush re-broadcasts UNIT_AURA via the engine's own per-token signal (FUN_UNIT_EVENT_BROADCAST), deferred off the SMSG_SPELL_GO subscriber. Also move the two static Turtle duration mods (Conflagrate -> Immolate, Molten Blast -> Flame Shock) from Lua into src/turtle/DurationMods via a new C++ entry Aura::Source::AddDurationMod, and drop the now-unused exact-spellID RegisterAuraDurationModifier Lua export (RegisterAuraDurationModifierByTrigger stays for Shadow Weaving). Based on the approach from @fuffc in #15. Closes #15 |
||
|
|
f559eb4d07 |
docs(api): move UNIT_SPELLCAST_* events into the Events section, fix TOC link
The TOC entry pointed at #unit_spellcast_-events-player, but the heading generates #unit_spellcast_-events (no -player suffix) — broken link. Move both the TOC entry and the content block out of the Spell section and into the Events section where the other event docs live, and correct the anchor. |
||
|
|
f293653837 |
docs: clarify GetNumWhoResults second return is server-dependent
The second value's meaning varies by server core. Mangos/cmangos cores send the query match count; Turtle (tortoise-wow) sends the whole realm's online population whenever more than 49 players are online, ignoring the filter (verified against tortoise-wow MiscHandler.cpp: data.put(4, count > 49 ? count : clientcount), count = online players). Earlier wording claimed it was always the match total, which is wrong off Turtle -- confirmed by a Twinstar /who priest returning 15/15. |
||
|
|
ba1e12fca9 |
feat(friendlist): C_FriendList.GetWhoInfo / GetNumWhoResults
Add the modern table form of /who results. Vanilla's global
GetWhoInfo returns positional values and no class token; GetWhoInfo
here returns a table with filename (the "MAGE"/"WARRIOR" token, keyed
for RAID_CLASS_COLORS) plus fullName, fullGuildName, level, raceStr,
classStr, and area. GetNumWhoResults returns the shown + total counts.
Reads the engine's /who buffer directly (WHO_RESULT_* globals added to
Offsets.h, verified by decompiling Script_GetWhoInfo / GetNumWhoResults).
No gender field -- vanilla's /who entry has no sex.
Share the class/race/zone display-name resolvers: extract ClassName,
ClassToken, AreaName out of GetFriendInfo into dbc/Names.{h,cpp} (adding
RaceName and an AreaName resolveToParent flag -- friends resolve a
sub-area to its zone, /who uses the area's own name). GetFriendInfo and
GetWhoInfo both use them now.
Document both functions in docs/API.md and README.md.
|
||
|
|
867478f410 |
feat(friendlist): add classFilename to GetFriendInfo
Return the locale-independent class token ("WARRIOR", "MAGE", ...)
alongside the localized className, read from the same ChrClasses.dbc
filename column GetPlayerInfoByGUID's englishClass uses. It is the key
for RAID_CLASS_COLORS and other class tables, so addons can color a
friend's name without matching the localized class name. nil when
unknown, so className and classFilename appear together. Document in
docs/API.md.
|
||
|
|
caeb598b78 |
feat(player): resolve UnitNameFromGUID from the friends list
Add a friends-list fallback to UnitNameFromGUID, between the object manager and the persistent name cache. The friend list keeps name + GUID for online AND offline friends (SMSG_FRIEND_LIST), so a friend's GUID now resolves to a name even when the unit is not synced and was never seen in chat -- the case that previously returned nil. Only UnitNameFromGUID uses this: it returns name + realm, and the friend entry has the name. GetPlayerInfoByGUID is left unchanged because it also returns race and sex, which the friend entry does not carry. Add FriendList::NameForGuid helper. Document the lookup order in docs/API.md. |
||
|
|
37ca209210 |
feat(friendlist): C_FriendList.GetNumOnlineFriends
Add the online-friend count. Vanilla stores no online total, so count friend entries whose connected byte is set -- the same flag GetFriendInfo reports. Document in docs/API.md and README.md. |
||
|
|
3f09b3f883 |
feat(friendlist): C_FriendList.IsIgnored / IsIgnoredByGuid
Add ignore-list membership checks. Vanilla's ignore list is a flat u64 GUID array in the social singleton (social + 0x650, stride 8, max 25, terminated by the first zero) -- verified by decompiling GetIgnoreName (FUN_005AE570 reads social + 0x650 + index*8) and GetNumIgnores (FUN_005AE550 stops at the first zero, caps at 25). IsIgnoredByGuid parses the GUID string and walks the array. IsIgnored accepts a name or GUID string (mirroring IsFriend); for a name it resolves each ignored GUID to its cached name through the NameCache and compares -- the same GUID->name path GetIgnoreName uses -- so it matches any ignored player the client has synced this session. Share the ignore layout + IgnoreGuidByIndex / IsGuidIgnored helpers in FriendList.h alongside the friend layout. Document both functions in docs/API.md and README.md. |
||
|
|
b38673f51f |
docs: document the friend-notes API
Update the GetFriendInfo entry so notes is a live field (with the per-character persistence note), add SetFriendNotes and SetFriendNotesByIndex sections plus TOC and README-matrix rows. Example values are from a verified in-game /dump. |
||
|
|
eefcbb17f2 |
docs: document C_FriendList.GetFriendInfo family
Add API.md sections and the README matrix row for GetFriendInfo, GetFriendInfoByIndex, and GetNumFriends, with the FriendInfo field list and example values captured from a live /dump (verified, not guessed). |
||
|
|
228c5daa0f |
docs: document IsFriend, GetSpellDispelType, IsNextMeleeSpell, ResetsMeleeSwing
Add API.md sections and README matrix rows for the four functions, with example returns verified against Spell.dbc. Also correct two stale docs: - IsRangedAutoAttackSpell now describes the AttributesEx2 autorepeat flag (bit 0x20), matching the fixed behavior -- not the old Attributes RANGED-bit test that wrongly matched Aimed Shot / Multi-Shot. - ResetsMeleeSwing mirrors the server's IsMeleeAttackResetSpell: true for cast-time spells whose casting resets the swing (Fireball, Frostbolt), false for instant specials (Sinister Strike) and for Slam (NOT_RESET flag). The first draft had the examples and framing backwards. |
||
|
|
954533a170 |
feat(aura): add CROWD_CONTROL / !CROWD_CONTROL aura filter
Reuses the C_LossOfControl classifier so the two never drift. Extract ClassifyControlLoss out of the LoC module into a shared Spell::CrowdControl: Classify(rec) returns the hard control-loss type string (stun/fear/silence/root/charm/confuse/pacify/possess/disarm) and still backs C_LossOfControl; IsCrowdControl(spellID) backs the aura filter. Crowd control is broader than loss of control: IsCrowdControl also counts movement slows / snares (SPELL_AURA_MOD_DECREASE_SPEED = 33, added to Offsets.h), which are crowd control but not a loss of control — so a Frostbolt/Hamstring slow is CROWD_CONTROL while C_LossOfControl still ignores it. Classify (LoC) is unchanged. Wire it as a third CcMode dimension on the Aura::Data::Match struct, checked in MatchesAura; tokenizer honors CROWD_CONTROL / !CROWD_CONTROL. Docs updated. Verified in-game: Psychic Scream (fear) and a Frostbolt slow both classify as CROWD_CONTROL; DoTs and buffs do not. |
||
|
|
dbe5ab40ee |
feat(aura): add DISPELLABLE / !DISPELLABLE aura filter
Modern DISPELLABLE means "can be dispelled/purged/stolen by SOME mechanism, regardless of whether the player can". Confirmed against the Turtle/Tortoise server: an aura is dispellable iff its Spell.dbc Dispel type is Magic(1), Curse(2), Disease(3), or Poison(4) — the server's DISPEL_ALL_MASK — and vanilla applies no per-aura "undispellable" attribute, so the dispel type is the whole story. Data::IsDispellable(spellID) reads the Dispel field (OFF_SPELL_DISPEL_TYPE) via the existing SpellRecord and checks 1..4 (the type ID directly, not dispelName != nil, in case SpellDispelType.dbc names Stealth/Invisibility). Fold the caster and dispel predicates into one Aura::Data::Match struct that replaces the standalone CasterMode parameter across the Find*/Push*/ Append* surface, applied by a shared MatchesAura(match, isPlayerCast, spellID). Orthogonal filter dimensions now add a struct field instead of another parameter. Existing caster behavior is unchanged. Tokenizer honors DISPELLABLE / !DISPELLABLE; docs updated. Verified in-game: HARMFUL|DISPELLABLE returns Magic debuffs, HARMFUL|!DISPELLABLE returns physical debuffs (Rend). |
||
|
|
2d266a9b76 |
feat(aura): tokenize C_UnitAuras filters; add PLAYER/!PLAYER negation
The aura filter string was matched with raw strstr, which the modern
AuraFilters token set breaks: strstr(f, "PLAYER") also matches
RAID_PLAYER_DISPELLABLE (false PLAYER-only), and "!PLAYER" contains
"PLAYER" so it was read as PLAYER-only — the opposite of intent.
Replace it with a real tokenizer (Aura::Api::ParseFilters): tokens
separated by "|" or whitespace, each optionally negated with a leading
"!", whole-token matching. Honored tokens: HELPFUL / HARMFUL
(descriptor slot ranges) and PLAYER / !PLAYER (caster == / != the local
player). Every other AuraFilters token (RAID, CANCELABLE, DISPELLABLE,
INCLUDE_NAME_PLATE_ONLY, MAW, …) is accepted and ignored — vanilla has
no data for them.
!PLAYER makes the caster restriction ternary, so the Aura::Data layer's
`bool playerOnly` becomes `CasterMode { Any, PlayerOnly, NotPlayer }`
threaded through every Find*/Push*/Append* function (plus the
lossofcontrol call site). Existing Any/PlayerOnly behavior is preserved
exactly; NotPlayer is additive. A cache miss counts as not-player, so
!PLAYER includes auras whose cast we did not observe (matching
IsPlayerCast's miss semantics).
Also fixes: "PLAYER" alone on the by-id / by-name getters now searches
both ranges instead of wrongly restricting to helpful.
Docs: API.md gains an STE "Filter tokens" note under GetAuraDataByIndex.
|
||
|
|
e4a75e68ca |
feat(frame): add GetMouseFoci — mouse-focus stack under the cursor
Modern WoW exposes GetMouseFoci() (the stack of frames under the cursor) alongside GetMouseFocus(), with GetMouseFocus() == GetMouseFoci()[1]. Vanilla stores only the single topmost focus (Script_GetMouseFocus reads *(ctx + 0x7C)); there is no stored stack. Reimplement natively (no Lua polyfill, no hooks): walk the engine frame list that Script_EnumerateFrames iterates (head *(ctx + 0xCC4), next +0x308, low-bit/null sentinel), keep frames that are visible + mouse-enabled and whose rect contains the cursor (Region getters + cursor/effective-scale, mirroring Frame::Modern's IsMouseOver), order top-first by strata rank then frame level (level read directly from +0xC4), and force index 1 to the engine's stored focus so the invariant holds by Lua table identity. Frames are pushed via the shared UI::FrameObject::Push so == compares the same wrapper GetMouseFocus returns. Filters to the mouse-enabled (interactive) stack, matching 1.15.x (verified: GetMouseFocus skips a higher non-mouse-enabled cooldown to land on the button, and 1.15.x GetMouseFoci returns the same set). /framestack lists more because it is a pure-geometry debug view, not the mouse-focus set. Docs: API.md entry (Simplified Technical English). |
||
|
|
5a3badb5bd |
feat(macro): add C_Macro.CreateMacro / EditMacro with string icons
The vanilla CreateMacro / EditMacro globals take an icon INDEX into the GetMacroIconInfo list, and that list omits INV_* item icons entirely -- so item icons are unreachable through the stock API even though the engine stores and renders them fine. C_Macro.CreateMacro / EditMacro accept the icon as a texture string (a full Interface\Icons\<name> path or a bare <name> basename) instead, writing the basename directly to the macro struct; GetMacroInfo re-prefixes it as Interface\Icons\%s on read, so any Interface\Icons\ texture round-trips. Both go straight to the engine's own workers (FUN_004f1010 create / FUN_004f1280 edit), which do the bounded copy, re-run the primary-spell parser, set the persist-on-logout dirty flag, and refresh the action bars. EditMacro resolves its index arg as a slot number or a macro name (via the GetMacroIndexByName resolver), leaves any nil field unchanged, and reads back the entry's local flag so the worker's unconditional rewrite of it is a no-op. The legacy globals stay untouched (index-only); string-icon callers opt in through the C_Macro namespace. Verified in-game incl. an INV_* item icon surviving a relog. Unblocks a pfUI macro-UI remodel. |
||
|
|
e0e4fbcf84 |
docs: list the new frame-attribute + modern-script-arg APIs
The attribute methods and the modern-script-args toggle shipped on this branch but weren't in the README index, and the toggle wasn't documented at all. - README: add frame:SetAttribute / SetAttributeNoHandler / ClearAttribute / GetAttribute, the OnAttributeChanged script, and SetModernScriptArgs / GetModernScriptArgs to the Frame row. - docs/API.md: document SetModernScriptArgs(enable) / GetModernScriptArgs() (opt-in modern positional handler args) with a Frame TOC entry. The attribute methods and OnAttributeChanged were already covered. |
||
|
|
1da06d4a73 |
frame: attribute backport, modern script args, and SMSG hook consolidation (#13)
* frame: backport Frame:SetAttribute/GetAttribute + unit-frame mouseover/click Adds native SetAttribute / SetAttributeNoHandler / GetAttribute on the base Frame registry: a per-frame, case-insensitive value store with the 3.3.5 prefix/name/suffix getter precedence, stored on the frame's own Lua table. A `unit` attribute makes the frame a mouseover source. A WorldTick poll of the engine's mouse-focus frame (GetMouseFocus's global) calls the real mouseover setter (FUN_00492890) for its unit -- 1:1 with hovering the 3D model: model highlight, mouseover tooltip, UPDATE_MOUSEOVER_UNIT, and the native GUID slot. Stomp-proof (the engine's 3D-hover setter is event-driven) and independent of the frame's scripts, so an addon setting its own OnEnter can't break it. A `type1`/`type2`/`type` attribute installs a chained OnClick on that frame only (PCall-guarded, Button-only) that dispatches target / assist / focus on the unit at click time, then runs any prior handler. No global hooks: mouseover reads the mouse-focus global; clicks use the frame's own OnClick. Deliberately does NOT MinHook the button-click dispatcher (FUN_00779540) -- SuperWoW's click-casting owns that prologue and a second inline hook corrupts the trampoline (ERROR #132). * frame: extend attribute backport (one-verb click dispatcher + OnAttributeChanged) The `type*` click path now mirrors retail's SecureActionButton_OnClick: resolve ONE verb per click from the modifier/button-qualified `type` attribute and perform it, instead of a fixed `type1=target`. - Modifier/button resolution: `[alt-/ctrl-/shift-]type[1..5]` with prefix..name..suffix -> name..suffix -> name precedence, read from the live key state and the click's button. - Verbs: target (with the engine's default-interaction precedence - cast a pending spell / drop a cursor item on the unit instead of switching target), assist, focus, spell, stopcasting, macro, and menu. - Own-the-click: when a verb resolves we perform it and do NOT chain the frame's previous OnClick, so a configured `type1` no longer double- dispatches alongside an addon's own conditional click handler. - Self-healing wire: addons that re-SetScript OnClick (pfUI on every raid relayout) clobber our closure; WireOnClick re-wraps a clobbered Lua handler but skips its own C closure, so re-setting `type*` recovers without double-chaining. Dispatch goes straight to C++ where we own the code - no Lua round-trip through the global table: spell -> Spell::AtUnit::CastByName (a native unit-targeted cast; the unit's GUID is fed to the engine's dispatcher so there's no target juggling, and ground-target spells land at the unit's feet), focus -> Unit::Focus::Set, and the target verb's predicates -> Spell::AtCursor::IsPlacementActive / Cursor::Info::HasItem. Only genuine engine entries (TargetUnit/AssistUnit/SpellTargetUnit/DropItemOnUnit/ SpellStopCasting) and addon-provided functions still go through Lua globals. Spell::AtUnit gains a C++ header sharing its CastCore with the C_Spell.CastAtUnit Lua entry. macro verb: takes the content from the `macrotext`/`macro` attribute and prefers an addon-provided RunMacro (SuperCleveRoidMacros etc. - handles named macros and extended macro text), falling back to running the text natively when no RunMacro global is present. The native path runs each line through the stock FrameXML ChatEdit_ParseText via a throwaway edit-box (GetText closure + no-op __index), so it needs no addon. menu/togglemenu verb: pops the standard unit dropdown at the cursor via the new ClassicAPI_ToggleUnitMenu (Util/SecureUnitMenu.lua), resolving the unit -> menu type with Blizzard's own generic resolver (self->SELF, pet->PET, grouped player->PARTY, other player->PLAYER, NPC->RAID_TARGET_ICON). Keeps the FrameXML dropdown logic in Lua with the C side as a thin call. OnAttributeChanged is now a real SetScript/GetScript/HookScript-able frame script on every frame: SetAttribute fires it, SetAttributeNoHandler suppresses it. Made settable by co-hooking the base-frame script-name resolver FUN_0076a0d0 (the one every frame type delegates through) and handing back an external per-frame {handler, context} cell for that name - frames are immortal in 1.12, so the cell never goes stale. One hook does it (vs the tooltip OnTooltipSet* work's five) because we already own the firing side. 1.12 convention: the handler reads this = frame, arg1 = name, arg2 = value. Recursion-guarded so a handler may itself SetAttribute. * frame: add Frame:ClearAttribute (retail 11.2.0) `cleared = frame:ClearAttribute(name)` removes an attribute and returns whether it was set. Registered on the base Frame method registry next to SetAttribute/GetAttribute, so every frame has it. Routes through DoSet's nil-value path (removes the stored key, drops a `unit` mouseover binding) but does NOT fire OnAttributeChanged — verified against a live retail 11.2 client: SetAttribute fires the handler, ClearAttribute fires nothing, and the return is true for a set attribute / false when there was nothing to clear. * frame: store attributes in the Lua registry, hidden from Lua Attributes were kept as a subtable on the frame's own Lua table under a control-char key ("\1ClassicAPIAttributes"). That key, while collision- safe, is still enumerable via pairs(frame) and readable/writable from Lua. Move the store to registry[frame] in the Lua registry (LUA_REGISTRYINDEX), which has no _G path — so the attribute map is invisible to pairs(frame) and can't be read or tampered with from script, matching how retail keeps attributes C-side. Only PushSub changed (create/fetch now key the registry by the frame table); GetAttribute/DoSet/CopyAttr sit on top unchanged. 1.12 frames are immortal, so the strong registry key never leaks. The dead kAttrKey constant is removed. Verified in-game: SetAttribute/GetAttribute still round-trip, and a pairs(frame) scan no longer finds any ClassicAPI key. * frame: add the `item` click verb (SecureActionButton item action) type*="item" uses the modifier-qualified `item` attribute: - a "bag slot" string (e.g. "0 1") -> UseContainerItem(bag, slot); - otherwise an item name / itemID / link -> C_Item.UseItemByName(item, unit), passing the unit as the use target (self-use items ignore it, targeted ones like scrolls/bandages apply to it); - the deprecated `bag` + `slot` attributes are honored when `item` is unset. Both bag paths go through lua_call (new CallTableFunc2Str / CallGlobalNum2) rather than a direct C++ call: the item-use bag walk does SetTop(L, 0), so it needs its own Lua stack frame — a direct call would wipe the dispatcher's stack. (spell stays direct because Spell::AtUnit is stack-free; the helper comment records the distinction.) Retail's "bag slot" string is the preferred form; the deprecated per-attribute form is supported too. * docs: format the attribute click verbs as a table The verbs were one long paragraph of nested parentheticals - hard to scan. Replace it with a Verb | Extra attributes | Action table so each verb's inputs and behavior are legible at a glance. Content-equivalent; no API change. * frame: clear target on the `target` verb when unit is "none" Retail's SecureActionButton target action treats a "none" unit as "clear target". Match it: the `target` verb calls ClearTarget() when the resolved `unit` is "none" (case-insensitive), before the normal cursor/spell precedence. Mouseover already handles "none" implicitly (it resolves to GUID 0 = no unit). Docs' target-verb row updated. * frame: pass modern positional args to script handlers Vanilla always invokes frame-script handlers with zero Lua args; the handler reads this/arg1/event as globals. Modern addon ports write SetScript("OnMouseWheel", function(self, delta) ...) and get nothing. Co-hook both script runners -- FUN_FRAME_INVOKE_SCRIPT (no-arg scripts) and FUN_FRAME_RUN_SCRIPT_ARGS (scripts with values) -- and reimplement their pcall tail: keep the engine's exact this/argN global save-set- restore and message-handler errfunc, but additionally push self + arg1..argN as real positional arguments and pcall with nargs = 1+N. Purely additive: a zero-param vanilla handler ignores the extras and reads globals; a modern (self, delta) handler binds them. OnEvent gets (self, event, arg1..argN), detected structurally by matching the invoked handler ref against the frame OnEvent slot (frame+0x0C) -- exact, since each SetScript makes a distinct ref. Runtime switch SetModernScriptArgs()/GetModernScriptArgs(), default on; when off both detours are a straight passthrough to the original runner, which matters because FUN_FRAME_RUN_SCRIPT_ARGS is the hottest Lua path in the engine (every OnUpdate frame). Verified in-game across OnMouseWheel/OnClick/OnValueChanged/OnUpdate/OnEnter/OnLeave/OnEvent. * net: consolidate spell SMSG hooks onto one dispatch funnel The spell subsystem's per-opcode SMSG handlers (SpellGo, SpellStart, SpellDelayed, ChannelStart/Update, SpellFailure, SpellFailedOther, SpellCooldown) were each co-hooked directly -- and nampower (hadesmem) plus SuperWoW detour the same prologues. Two inline hookers on one prologue is the documented MinHook collision risk, and a whole-protocol bisect fingered exactly this cluster as the crash-suspect surface. Add Net::PacketDispatch: a receive-side mirror of Net::SendObserver that co-hooks the single incoming-SMSG dispatch funnel FUN_NET_MESSAGE_DISPATCH (0x00537AA0) -- a chokepoint nampower does NOT hook (it detours the leaf handlers) -- and fans each packet out to opcode subscribers with the cursor at the body and centralized save/restore. Migrate all eight handlers to subscribers: aura/Source (SpellGo, which re-decodes the packed guids + spellId the leaf handler used to hand it pre-decoded), spell/Cast (Start/Delayed/Channel*/Failure*), and lossofcontrol (Cooldown). The parse bodies are unchanged; only the hook site moved. Subscribers run before the engine's leaf handler instead of after a co-hook's original -- verified order-independent for all eight (self-contained cache/state updates; SpellGo's aura-application handoff rides a separate SMSG_UPDATE_OBJECT). Cuts the ClassicAPI-nampower shared spell prologues from 10 to 3 (the OnAura* method hooks, which have no packet chokepoint to relocate to). One hook on an uncontended function replaces eight on contended ones. Verified in-game: cast bars, channels (incl. Mind Control cast-then- channel), pushback, remote-cast interrupt eviction, and C_LossOfControl school lockouts all intact. * ScriptArgs is back to opt-in * frame: fix ScriptArgs comments to match opt-in default * frame/net: dedupe packet observers, reuse Lua/token helpers, fix attr edge cases Post-review cleanup of the attribute + SMSG-consolidation work. - net: extract the shared packet-observer plumbing (PacketObserver.h) — the intrusive subscriber list, Subscribe(), and the read-opcode / reset-cursor / fan-out / restore loop — so Net::PacketDispatch (SMSG, u16) and Net::SendObserver (CMSG, u32) each reduce to a one-line hook thunk over FanOutByOpcode<OpcodeT>. Drops the dead per-namespace Callback aliases rather than keeping them as compat shims. - Game::Lua: promote PushGlobalFunction / CallGlobal / CallGlobalString into the shared Lua helpers (a pattern several modules open-code); Frame attributes use them instead of private copies. - frame/Attributes: resolve unit tokens through Unit::Identity::GuidForToken (engine resolver + player fast-path) instead of a duplicate raw-cast wrapper. - frame/Attributes: wire the chained OnClick for every "type" action attribute the click resolver reads (IsTypeAttr: modifier prefixes + type1..type5), not just type/type1/type2 — a middle-click or modifier-only binding now installs. - frame/Attributes: FireAttributeChanged snapshots and restores the caller's arg1/arg2 around the fire, so calling SetAttribute from inside a running script handler no longer clobbers its globals. |
||
|
|
0c27d61839 |
unit: add markN raid-target-marker unit tokens
"mark1".."mark8" (star..skull) now work as unit tokens against the whole
Script_Unit* surface, and fire per-token unit events (UNIT_HEALTH, ...)
with arg1 == "markN" -- the same TokenObserver path focus/nameplateN use.
Resolution: a markN branch in the FUN_TOKEN_TO_GUID hook
(unit/TokenExtensions.cpp) reads the engine's 8-slot marker table
(VAR_RAID_TARGET_GUIDS = 0x00B71368, mark{1..8} = table[N-1]), so every
stock Unit* gains the token for free and "mark1target" composes via the
existing suffix walker.
Events: unit/RaidTarget.cpp runs a WorldTick watcher that diffs the marker
table and attaches/detaches one descriptor observer per marked unit,
deferring registration until the unit is in the object table (a unit can
be marked while out of range and enter later) -- the same range handling
Focus does, x8. One distinct callback per slot fires its fixed "markN"
token. Idle (no markers set) costs 8 compares and no object lookups; a
marker on a non-unit is never observed.
Verified the array shape against the binary (reverse lookup FUN_004bb190
walks 8 uint64 slots) and against nampower's CGRaidInfo_m_raidtargets.
Docs added under Unit tokens (markN); README token table updated.
|
||
|
|
29e3dab24a |
UNIT_SPELLCAST_* event family + GUID unit tokens (#11)
* spell: backport UNIT_SPELLCAST_* events for the local player
Adds the TBC+ cast/channel events (START, STOP, DELAYED, SUCCEEDED,
INTERRUPTED, FAILED, SENT, CHANNEL_START, CHANNEL_UPDATE, CHANNEL_STOP)
for the player, so cast-bar / rotation addons written against the modern
signature work on 1.12. Each carries (unit, castGUID, spellID, spellName,
rank) -- SENT inserts `target` at arg2 -- with a synthesized modern-shape
castGUID (Cast-3-0-0-0-<spellID>-<castUID>) shared across all of a cast's
events so START pairs with STOP. arg1 is always "player" (player-only phase).
The events are derived, not independently tracked: Spell::Cast already
hooks every cast/channel path for UnitCastingInfo/UnitChannelInfo, so
Spell::CastEvents reuses that state.
- START/STOP/DELAYED/CHANNEL_START/STOP: polled from Cast's OnWorldTick
against the previous snapshot.
- SUCCEEDED: fired from the SMSG_SPELL_GO hook (covers instants too).
Deferred for channels so it lands after CHANNEL_START (modern order).
- INTERRUPTED/FAILED: split by result code in a Spell_C_SpellFailed
co-hook -- a started cast that aborts (kick/move/LoS) fires INTERRUPTED
(repeated per retry, reusing the cast guid); a pre-cast rejection fires
FAILED.
- SENT: minted from the CMSG_CAST_SPELL send, threading its castGUID
forward so all of a cast's events share one guid.
- CHANNEL_UPDATE: from a new MSG_CHANNEL_UPDATE co-hook, which also
re-anchors g_channel.endMs to the server's remaining time so channel
pushback (which shortens vanilla channels) shows in UnitChannelInfo.
Every fire is gated on Event::Custom::HasListeners (new), so the system
costs one pointer-compare per transition when no addon registers.
Supporting changes:
- Net::SendObserver: shared co-hook on the NetClient send funnel with an
AutoSubscribe list, so CastEvents (SENT) and ComboDuration (combo-point
capture) both watch outgoing packets without owning the hook. Extracted
from ComboDuration's private hook.
- Cast.cpp: player channel now self-expires at its computed endMs in the
poll (was cleared only by the ~1s-lagged +0x228 field, so CHANNEL_STOP
trailed the real end by ~1s); wrap-safe delta compare so a long-uptime
ms tick past 2^31 can't misfire it.
Player-only; remote-unit fan-out, FAILED_QUIET, and empowered casts are
not implemented.
* spell: extend UNIT_SPELLCAST_* to non-player units (phase 2)
Fires the six observable cast/channel events -- START, STOP,
CHANNEL_START, CHANNEL_STOP, SUCCEEDED, INTERRUPTED -- for other units,
not just the player. Each is fanned out once per unit token currently
mapping to the caster (target / focus / nameplateN / party / raid / pet /
mouseover), so a target frame, a party frame, and a nameplate cast bar
all get their own event with a shared castGUID -- matching retail.
Token fan-out reuses the engine's own GUID->token reverse map
(FUN_00515c50, nampower's unfilled GetNamesFromGUID) for native tokens,
plus focus/nameplate which the engine can't see, via
Unit::Identity::TokensForGUID. SuperWoW's raw-GUID token ("0x...") is
filtered out so only standard tokens fan out.
Remote events are derived from Spell::Cast's existing packet hooks:
- START / CHANNEL_START from HandleSpellStart (SMSG_SPELL_START)
- SUCCEEDED from the SPELL_GO hook (Aura::Source)
- STOP / CHANNEL_STOP at the computed end, or on abort
- INTERRUPTED (casts only) from HandleCastAborted (ClearCastingSpell /
failure packets)
A per-caster state machine (PollRemote, from OnWorldTick) fires them in
modern order; a channel's SPELL_GO cast->channel ClearCastingSpell is
filtered so it doesn't self-interrupt at its own start.
Not fired for remotes (data is caster-only / client-local): SENT,
DELAYED, FAILED, CHANNEL_UPDATE.
Also in this change:
- castGUID follows type rule from https://warcraft.wiki.gg/wiki/GUID#Cast : real casts are Type 3 with a
time-based castUID (low 23 bits = UNIX second, high bits = per-second
counter, matching retail's structure), threaded across a cast's events
(player and remote converge on the same value); FAILED is Type 2 with
a flat incrementing integer.
- Channels never fire INTERRUPTED (player or remote) -- retail emits
only CHANNEL_STOP whether a channel completes or is cut short.
arg1 is the caster's unit token ("player" or another token); the
spellName / rank tail extensions are unchanged.
* spell: return the castGUID as UnitCastingInfo's castID
UnitCastingInfo / CastingInfo now return the cast's castGUID as castID
(return 7) instead of nil -- the same string the UNIT_SPELLCAST_* events
carry, so an addon can correlate the polled info with the events. It's
pulled from Spell::CastEvents (the single source of the castUID) via a new
CurrentCastGuid accessor, and works for the player and remote units. The
timing stays sourced from Spell::Cast -- only the castGUID crosses over,
so there's no duplication of cast state.
UnitChannelInfo is left retail-exact (no castID; channels don't carry
one), even though our channel events do include the shared castGUID.
Also corrects the spell-cast-GUID spec attribution in comments/docs to
warcraft.wiki.gg/wiki/GUID#Cast (it was wrongly credited to Wowhead).
* spell: add UNIT_SPELLCAST_RETICLE_TARGET / _CLEAR events
Backports the ground-target reticle events for the player:
RETICLE_TARGET when an AoE placement reticle comes up (Blizzard, Flare,
Rain of Fire, ...), RETICLE_CLEAR when it's cancelled. Args are
(unit, "", spellID, spellName, rank); arg1 is always "player".
Driven by polling the engine's targeting-flag global (0x00CECAC0 -- the
predicate behind SpellIsTargeting) from OnWorldTick: 0->nonzero fires
RETICLE_TARGET with the pending spellID (0x00CEAC58, written by
Spell_C_CastSpell); nonzero->0 fires RETICLE_CLEAR. CLEAR is suppressed
on placement (a CMSG_CAST_SPELL for the reticle spell went out, seen via
the shared send observer), so it fires only on a genuine cancel --
matching retail, which emits no CLEAR when the spell is placed/cast.
The castGUID slot (arg2) is "" rather than retail's nil: there's no cast
to identify yet, and the engine's event dispatcher can't emit a nil
mid-argument-list (a NULL %s corrupts the args after it -- the nil trick
only survives as the last arg). unit (arg1) and spellID (arg3) are exact.
* spell: fire UNIT_SPELLCAST_FAILED_QUIET for the quiet result whitelist
Vanilla's Spell_C_SpellFailed dropped SPELL_FAILED_DONT_REPORT silently.
Modern surfaces suppressed (no-error-text) failures as
UNIT_SPELLCAST_FAILED_QUIET rather than FAILED.
Verified against the 3.3.5 client's unit-spellcast dispatch (FUN_007fecc0),
which selects the QUIET event for a fixed 3-code whitelist, mapped to 1.12's
SpellCastResult enum (FUN_006e23e0):
CHARMED (0x14) . DONT_REPORT (0x17) . SPELL_IN_PROGRESS (0x61)
SPELL_IN_PROGRESS (casting while already casting / a nampower spell-queue
rejection) is the common case that previously mis-fired as a loud FAILED.
* unit: accept raw GUID literals as unit tokens
Fold a "0x<hex>" branch into the existing FUN_TOKEN_TO_GUID hook so every
Unit* function (UnitName, UnitHealth, UnitClass, UnitExists, ...) accepts a
64-bit GUID literal in place of a token. The parsed GUID goes straight to
the engine's own object-manager lookup (the path "player" takes), so an
unloaded/out-of-range GUID resolves to nil like any absent unit, no error.
Reuses the existing suffix walker, so "0x...target" composes.
Gated on SuperWoW's absence (GetModuleHandleA("SuperWoWhook.dll"), cached):
SuperWoW already provides GUID input via its own resolver hook, so when it
is loaded we defer to avoid two layers parsing the same string. Behaves
identically either way. Input direction only.
|
||
|
|
555ea02447 |
loot: add C_Loot.LootAllCorpses to auto-loot nearby corpses
C_Loot.LootAllCorpses([max]) loots every nearby lootable corpse in sequence -- coin (CMSG_LOOT_MONEY) plus every item slot (CMSG_LOOT_ITEM) from each window before releasing and advancing. Optional max caps the corpse count. Shares Loot::Scan's existing corpse-walk state machine and its single FUN_LOOT_CONTROLLER hook -- MinHook allows one hook per target, so this can't be a separate module. ScanNearbyLoot scrapes each window and releases; LootAllCorpses does the same walk but actually loots it first. The walk stays silent (LOOT_OPENED/LOOT_CLOSED suppressed, so LootFrame never flickers) while the item-received / money chat + inventory events fire normally. Packet-based and target-clean, matching the rest of the C_Loot suite: no right-click, no target change, no auto-walk toward out-of-range corpses. Money goes through FUN_005ea8c0 (CMSG_LOOT_MONEY) with the SAME player pointer passed to FUN_CMSG_LOOT_UNIT -- whose send wrote this window's target GUID to the player's +0x1D28 guard slot, so the money send's internal guard passes. Item sends bypass the client BoP/unique confirm dialog (the server still enforces real loot permissions). Reimplemented in spirit from WeirdUtils's LootAllCorpses (public domain) on our own packet loot primitives + object-scan helpers, rather than its right-click-autoloot approach. Wires the existing AOELOOT keybinding to it (was ScanNearbyLoot). |
||
|
|
cd674aa115 |
hearth: gate HEARTHSTONE_BOUND on in-world flag, not location diff
Turtle's server re-sends SMSG_BINDPOINTUPDATE on every map/zone transition with the unchanged bind location, behind a loading screen. The valid-flag gate only suppresses the initial post-login sync, so every map change fired HEARTHSTONE_BOUND. A player can't bind mid-load, so gate on the engine's "world is live" flag instead: VAR_IN_WORLD (0x00B4B424), set to 1 by the enter-world init FUN_004908C0 and back to 0 by the world-teardown FUN_00490A80 that runs at the start of every transition (verified via the enter/leave pair in Ghidra). The resync arrives with the flag 0 (suppressed); a real innkeeper bind always arrives with it 1 (fires) -- including a rebind at the same inn, unlike a location diff would. Add VAR_IN_WORLD to Offsets.h (the real pollable in-world boolean; 0x00B4E37C, once wrongly labeled this, is only instance grace-period state). Update the bind-handler offset comment and docs/API.md. |
||
|
|
a2c5db7b76 |
time: add GetTimeCached() frame-stable timestamp
Backports retail 4.x's frame-cached GetTime() behavior under a distinct name, leaving vanilla GetTime() live/per-call. 1.12's Script_GetTime recomputes the OS tick on every call, so same-frame calls can differ; GetTimeCached() samples once per frame (via the shared Tick::WorldTick hook) and returns that until the next frame, on the same epoch as GetTime() so the two are directly comparable. Falls back to a live sample before the first world tick so it never returns 0. Deliberately NOT a perf feature and documented as such: the 1.12 tick source is cheap (GetTickCount shared-page read or rdtsc) and both functions pay the same dominant Lua->C dispatch, so caching saves nothing measurable. The only benefit is frame-stable semantics; the real hot-loop fix is caching GetTime() in a Lua local, which no C function can do for the caller. New global chosen over modifying GetTime() to avoid changing a core vanilla function's behavior. |
||
|
|
46597f6587 |
unit: fire UPDATE_MOUSEOVER_UNIT on mouseover loss
Vanilla fires UPDATE_MOUSEOVER_UNIT only when a mouseover unit is gained;
moving the cursor off a unit clears the mouseover and signals nothing.
Retail fires for both gain and loss, so addons watching
UnitExists("mouseover") can react when it goes false. This restores the
loss fire.
Co-hooks the engine's mouseover set/clear chokepoint (FUN_00492890) --
the ONLY writer of the mouseover GUID globals, so every gain/loss/change
flows through it. Resolves whether the mouseover is a unit before and
after the original and fires the event on the unit->non-unit transition.
Gating on unit TYPE (not just "GUID present -> absent") is load-bearing:
the same GUID slot also holds gameobjects and items, which never fire a
gain, so a naive present->absent test spuriously fired when moving off a
herb node or chest (reported in testing). The unit|player object-mask
resolve fixes that; the !hasUnit half prevents a double-fire on any
->unit transition the engine already covered inline.
Change-gated target (per-frame would spam the gain event while
hovering), so it's a cool hook. Documented in API.md (loss-fire fix
subsection + TOC) and Events.md notes.
|
||
|
|
e1a9d9b5c4 |
docs: document IsIndoors / IsOutdoors
Add the two globals to the State section of docs/API.md (with TOC entries) and the README State row. Notes the 1/nil return contract (retail + SuperWoW 2.2 parity) and that the state is a live WMO geometry query, not zone/area based. |
||
|
|
1f3f3cb9f6 |
aura: infer server-side DoT-duration changes from the triggering cast
C_UnitAuras expirationTime for a debuff on another unit is derived from
SMSG_SPELL_GO at cast time; the vanilla server never retransmits a LATER
server-side duration change on a non-self unit (verified in the server
source: SetAuraDuration/RefreshHolder, and UpdateAuraDuration is self-
scoped -- on a mob no packet is built at all). So a refresh/consume goes
stale in our cache. We can't hear the change, but we DO see the triggering
cast, so mirror the server's edit off that.
Aura::Source gains a rule engine applied in SpellGo_h (before the aura
gate -- triggers apply no aura themselves): a trigger matched by exact
spellID OR by SpellFamilyName + school index, an affected aura matched by
family + family-flag overlap (+ optional icon, rank-proof like the server
scripts), and an op (refresh/reduce/set/remove). Proc-applied affected
auras enter the cache unattributed (casterGuid 0); the rule accepts those
and attributes them to the trigger caster (also gives them a sourceUnit).
Lua: C_UnitAuras.RegisterAuraDurationModifier (exact-ID trigger) and
RegisterAuraDurationModifierByTrigger (family+school trigger), so the
server-specific ruleset lives in the addon, not the DLL.
Default Turtle ruleset (AuraDurationModifiers.lua, gated on
TURTLE_WOW_VERSION; IDs/flags DBC-verified):
Conflagrate -> reduce Immolate 3s
Molten Blast -> refresh Flame Shock
Shadow Weaving (5/5 talent 15334) -> priest shadow-school casts refresh
Shadow Vulnerability 15258 (covers the max-stack refresh blind spot;
Turtle reworked it, so stock DBC proc masks don't apply -- match by
school). Best-effort: DoT-tick procs emit no cast packet.
Carnage's roll-gated Rip/Rake refresh is deliberately excluded (the client
can't know the server roll).
Verified in-game (debug trace): Conflagrate/Molten Blast, and Mind Blast /
SW:P / Mind Flay all refresh 15258 with advancing expiration + sourceUnit.
|
||
|
|
7ae9b83ad7 |
spell: CastAtUnit casts unit-target spells directly at the unit
Previously CastAtUnit only handled ground-target spells (placement at the unit's feet); a non-ground spell fired with no implicit target (fell to current selection). Now it resolves the unit once to its object, reads position AND GUID, and dispatches the cast WITH that GUID -- the engine's FUN_SPELL_CAST_DISPATCH substitutes it exactly where it would the current selection (verified: passing 0 substitutes VAR_CURRENT_SELECTION_GUID), so a unit-target/normal spell fires straight at that unit regardless of current target. Branch on placement state after dispatch: no placement -> cast went out (unit-target); ground placement -> commit at the unit's feet (existing); other placement -> unit not accepted as target, cancel + false. AtCursor gains an optional targetGuid on DispatchSpellCast[ByName] (0 = prior behavior, so CastAtCursor is unchanged) and IsPlacementActive(). Verified in-game: ground spells still land at the unit's feet; Frostbolt/ Renew/PW:Fortitude cast on the named unit while another unit stays targeted. |
||
|
|
4281cd8253 |
glue: add C_Glue.IsFirstLoadThisSession and C_Glue.IsOnGlueScreen
IsFirstLoadThisSession() - glue-only; true only during the first glue screen since process launch, false after a world->glue logout (login <-> character-select stays within the first session). Backed by a process-static glue-boot counter incremented in the GlueModuleAutoRegister callback (fires once per glue boot). IsOnGlueScreen() - true on a GlueXML screen, false in the world. Registered on both Lua states; since glue and in-game states are mutually exclusive the answer is a constant per state (true from glue, false in-game), so it's callable from either environment with no runtime flag. Verified in-game: first login true/true, post-world-logout false; in-game C_Glue.IsOnGlueScreen() false. |
||
|
|
9239756153 |
frame: add frame:GetEffectiveAlpha()
Own alpha times every ancestor's alpha -- the product WoW composites at render time. Vanilla has only GetAlpha (a frame's own alpha); this walks self -> parent -> ... via the engine's own GetAlpha/GetParent, so it reflects the engine exactly, including 8-bit alpha quantization (SetAlpha(0.5) -> 127/255). Frame-scoped, matching GetAlpha's registry. Verified in-game: matches an equivalent Lua GetAlpha/GetParent walk, and a two-level 0.5/0.5 chain returns (127/255)^2 = 0.248043 exactly. |
||
|
|
f13aa1943d |
unit: add UnitPosition(unit)
Backport the modern UnitPosition -> posY, posX, posZ, instanceID. Reads any visible unit's world position through the shared Unit::Position helper (CGObject::GetPosition vtable slot 5 -- same path UnitDistanceSquared uses), so no group/taint restriction like retail: works for target, mouseover, nameplates, in-range party/raid. nil when the unit has no known position. Retail return order (posY=world Y/west, posX=world X/north, posZ=height); instanceID is the current Map.dbc id. Verified in-game: squared delta of two UnitPosition reads matches UnitDistanceSquared exactly. Note: SuperWoW also defines a global UnitPosition with a different shape; last registrant wins if both load. Documented in docs/API.md. |
||
|
|
7f4b20c6ec |
frame: add region:GetRect and region:IsDragging
Two more Region-base methods backported from 3.3.5, both on the Region registry so they resolve on every region type. GetRect() -> left, bottom, width, height, composed from the engine's own GetLeft/GetBottom/GetWidth/GetHeight (all UI-scale conversion is engine code). Returns nothing for an unpositioned region, matching retail. IsDragging() -> true while the region is the frame currently being moved/sized. Reads the engine's single global drag target (*(VAR_UI_CONTEXT_PTR) + 0xCFC); StopMovingOrSizing (0x00776990) gates its own clear on the identical `context+0xCFC == self` predicate. Non-frame regions never match the stored frame, so they report false. Verified in-game: GetRect on UIParent/Minimap; IsDragging toggles with a live frame drag. |
||
|
|
9622ea7742 |
frame: add region:IsMouseOver([top, bottom, left, right])
Native Region method (all region types) for cursor-in-rect testing with optional per-edge offsets. Mirrors the engine's own math: delegates to the Region-registry rect getters (GetLeft/Right/Top/Bottom) and GetCursorPosition, dividing the cursor by the region's effective scale read from obj+0x7C -- the same field GetLeft/GetEffectiveScale read internally, so it works on textures/fontstrings where GetEffectiveScale (Frame-only) would typecheck-fail. Returns false for an unpositioned region. Offset semantics match modern FrameXML's MouseIsOver forwarding. |