Removed two paragraphs that just stated the project premise out loud
("Vanilla 1.12 ships no equivalent...", "Vanilla 1.12 doesn't ship X
(added in later expansions)..."). API.md is the reference for what
ClassicAPI adds — that backport context applies to every entry by
definition.
Kept the substantive nearby context (existing-vanilla-function
contrasts, server constraints, behavioral quirks) — those are
genuinely informative.
Modern arg-order shape (unit first, questID second; questID-keyed).
Walks the unit's +0xE68 sub-struct quest list at +0x28 — same data
source as the engine's IsUnitOnQuest(logIndex, unit). Single Lua call
covers both "is the player on it" and "is a party/raid member on it"
without making the caller find a matching log index first.
Crash hazard fix: the +0xE68 sub-struct is uninitialized for NPCs
(CGCreature_C). First attempt gated on `[unit + 0xE4] & 1` (the
engine's own pre-check before +0xE68 derefs in SetUnitBuff etc.) but
that wasn't sufficient — passing an NPC token still AV'd in the
quest-list walk. The engine's Script_IsUnitOnQuest gets away with the
weaker gate because its GUID-type-filtered ObjMgr lookup
(FUN_00468460(0x10, ...)) rejects non-player GUIDs upstream;
FUN_RESOLVE_UNIT_TOKEN doesn't have that filter. Switched to
UNIT_FLAG_PLAYER_CONTROLLED, which is the gate Item::InventoryID and
Unit::Flags already use for the same hazard.
While doing that, extracted IsPlayerControlled to Unit::Flags::
(new Flags.h) as the canonical predicate. Removed the file-static
copy in Item::InventoryID and collapsed two inline copies in
Unit::Flags (TestPlayerFlag, ReadGuildKey) to call the shared helper.
Walks VAR_QUEST_LOG_ENTRIES (the same array GetQuestIDForLogIndex
reads) matching each real entry's questID against the input. Skips
header rows via the +8 header-pointer gate. Returns false for invalid
input (non-positive / non-number / not in log) — modern semantics, no
lua_error.
Lighter than the engine's IsUnitOnQuest(logIndex, unit) which forces
the caller to walk the log themselves to find the matching index and
resolves a unit token even when the question is just about the player.
Walks the player's buff range for an aura whose Spell.dbc effects
include SPELL_AURA_MOUNTED (78) and sends CMSG_CANCEL_AURA for that
spellID via the existing direct sender. Early-outs on
UNIT_FIELD_MOUNTDISPLAYID == 0 to skip the aura walk when the player
isn't mounted.
Vanilla 1.12 has no Dismount global; addons had to find the mount
buff via GetPlayerBuff and call CancelPlayerBuff with its 0-based
index. Matches Classic Era's no-arg shape.
Vanilla treats warriors as always-in-a-stance — the engine has no "no
stance" state, right-clicking the active stance bar slot does nothing,
and the server rejects CMSG_CANCEL_AURA for stance spells regardless
of how the request is formed. Tried both a looser aura-walk (no
visibility gate) and a form-bar fallback before confirming stances
genuinely aren't cancelable from the client.
All other shapeshift forms (druid, shaman ghost wolf, priest
shadowform / spirit of redemption, rogue stealth) are real visible
buffs and cancel cleanly via the original aura-walk path.
No-arg drop-current-form, polyfilling the modern singular. Walks the
player's buff slots, scans each spell's Spell.dbc EffectApplyAuraName[3]
at +0x16C and EffectMiscValue[3] at +0x1A8 for the
SPELL_AURA_MOD_SHAPESHIFT (0x24) effect whose misc-value matches the
current form byte, and sends CMSG_CANCEL_AURA via FUN_006E7040 for the
owning spellID.
Offsets validated against both 1.12's Script_CastShapeshiftForm
(0x004B4810) — which does the same scan when re-toggling an active form
— and 3.3.5's Script_CancelShapeshiftForm inner FUN_00726CE0. Vanilla's
public Lua surface only exposes the index-based toggle via
CastShapeshiftForm, forcing addons to know which bar slot the current
form occupies before they can cancel it; the no-arg shape is a lot
easier.
Modern aura-cancel primitives — `CancelUnitBuff` decomposes to these
internally. Both go direct to the engine's CMSG_CANCEL_AURA sender
(`FUN_006E7040` at 0x006E7040, `__fastcall(spellID)`) and skip
Script_CancelPlayerBuff's client-side gates (the per-entry cancelable
flag at +0x0A bit 0x01 and the fallback AttributesEx & 0x04 check on
the spell record). Server is the authority on what's cancelable —
non-cancelable auras are rejected server-side as no-ops either way.
CancelSpellByName walks the player's unit-aura descriptor slots 0..31
(buff range) and matches Spell.dbc localized name case-insensitively.
Buff-only by design — matches modern semantics where dispels go
through separate UX.
Player-only (vanilla server only accepts CMSG_CANCEL_AURA for the
local player's own auras), so neither function takes a `unit` arg.
Pre-validates spellID via Spell::Lookup::RecordForID — the engine's
sender unconditionally derefs [record + 0x1C] after a NULL-on-OOR
record lookup, so skipping the check would AV on bad input.
Synthesize modern's per-form-change event by hooking the engine's
bonus-action-bar refresh helper at 0x004E4FC0 — fires every relevant
UNIT_BYTES_1 broadcast plus once at post-login. Cached-byte gate on
descriptor[+0x212] filters out the recomputes for non-form bytes
(standstate, etc.) the same helper handles. Sentinel -1 for "player
not resolvable yet" distinguishes early-login transients from real
"left a form" transitions.
Vanilla 1.12 only has UPDATE_SHAPESHIFT_FORMS (plural — list-changed).
`expirationTime` now reads from the engine's player-buff table at
`0x00BC6040` (same data path `GetPlayerBuffTimeLeft` uses) when the
unit is the local player. Other units still report 0 — the server
only broadcasts cast/duration for the local player's own auras.
Verified that the engine's ms tickcount matches Lua's GetTime() *
1000, so `expirationMs * 0.001` lands directly on the GetTime
timeline with no epoch reconciliation needed.
`duration` looks up `Spell.dbc.m_durationIndex` (+0x78) →
SpellDuration.dbc and applies the `(effLevel - spellBaseLevel) *
perLevel + base` scaling the engine uses internally, capped at max.
Populated for any unit (the base duration is identical regardless of
who's affected); talent / glyph extensions aren't included here since
those are caster-side and already baked into `expirationTime` on the
caster's side.
First attempt had the wrong field offset for spellID in the buff
table — read +0x0C (untalented rank, returned by Script_GetPlayerBuff
as its second result) instead of +0x04 (the actual spellID, used by
Script_GetPlayerBuffTexture to look up Spell.dbc). Fixed before this
commit.
This unblocks `buff.lua` bookkeeping (the bid-tracking ring-buffer
exists only to compensate for the missing time data) — addons can
now use modern UnitAuras semantics directly.
Adds the GameTooltip row entry in the README + a per-method section
in docs/API.md covering the tooltip shape, localization behavior
(Blizzard FrameXML globals with English fallbacks), and the
storage-format change that persists itemID alongside GUID per slot
to support naming missing items.
Reorders all 30 top-level sections (and the matching Contents TOC
groups) by case-insensitive name. Done via a one-shot Python script
that sliced the file by ## headers and reassembled in sorted order
— no content edits, every per-section sub-bullet and prose block
preserved verbatim.
Also adds the Hooks TOC group that was missing entirely. The Hooks
section existed in the body but had no TOC bullet pointing at it.
Sub-bullet count is unchanged before/after (188 ### subsections),
confirming nothing was dropped during the reshuffle.
Adds README + docs/API.md entries for the two new functions, plus a
correction to the UseHearthstone entry — it still described the old
Script_UseContainerItem dispatch after the 30b3d91 refactor that
routed it through FUN_ITEM_USE directly.
The GetActionInfo entry calls out the known gap: the 0x40000000
non-macro branch surfaces type "item" but nil for the id, since
extracting the itemID from the bag-action hash struct needs more
reversing than landed in 509fbfe.
Vanilla 1.12 registers GetCVar/SetCVar/RegisterCVar/GetCVarDefault
and RunScript only on the in-game FrameScript engine; GlueXML had
no way to reach them. Mirroring is pointer-aliasing — same Script_*
C functions registered on glue via RegisterGlueFunction. CVar
storage is process-global so writes from either state are visible
on the other. C_CVar.GetCVarBool (our existing polyfill) gets a
GlueModuleAutoRegister alongside the existing in-game one.
The single addon driving the C_CharacterList.* bindings moved off
them; keeping the engine-hook surface live for a feature nobody
calls is dead weight. Snapshot record layout, hook target, and the
"why memory-only" rationale all land in TODO #95 so another DLL
can pick it up without re-deriving any of it.
README CharacterList row gains a GlueXML-only callout for the two new
globals plus their persistence path. docs/API.md gets a dedicated
subsection under CharacterList covering scope (glue Lua state, not
in-world), the API surface, the shared ClassicAPI.txt storage layout,
a usage example, and a brief how-it-works note pointing at
FUN_0046ABB0.
Six functions matching the retail namespace:
- GetItemInfo(slot) reads the 28-byte merchant entry directly.
- GetBuybackItemID(slot) walks buyback storage → player invMgr →
CGItem instance block. No GetBuybackItemLink roundtrip.
- GetNumJunkItems / SellAllJunkItems iterate bags via the existing
ResolveBag helper and read quality from the ItemStats cache.
- IsMerchantItemRefundable / IsSellAllJunkEnabled stub to false /
true to match retail's API contract in a version that has no
refund mechanic or sell-junk-disabled setting.
SellAllJunkItems calls the engine's internal MerchantSellItem
dispatcher (CMSG_SELL_ITEM) directly rather than going through
Script_UseContainerItem. The dispatcher uses an irregular fastcall
(count in ECX, four stack args, EDX ignored); a dummy EDX in the
typedef forces MSVC to lay the args out the callee expects.
Sells are deferred one per frame via the shared WorldTick
subscriber. Burst-sending 10 CMSG_SELL_ITEM packets in one frame
consistently dropped the 2nd-to-last sell (verified empirically).
Spreading them across frames matches the cadence of click-by-
click selling.
GetNumJunkItems also returns 0 away from a merchant frame to
match retail's contract — the count is meant as a "what would the
sell button do right now" signal, not a passive inventory query.
Includes a small refactor: factored GUID→CGItem resolution out of
EquipmentSet::Locations into Item::Location::ResolveByGUID so it's
shared cleanly between modules, and renamed VAR_MERCHANT_FLAG_A/B
to VAR_MERCHANT_NPC_GUID_LO/HI now that the semantic is decoded.
Cursor-clearing-when-holding-junk left as TODO #93.
C_Item.EquipItemByName (explicit slot) and C_EquipmentSet.UseEquipmentSet
now call the engine's own swap primitive directly. No cursor touch,
2-cycles resolve atomically in one server packet.