mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
b4e5f4f2bb13742c58b4cb2956d8aaf514b4d010
138
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
61db68dd7f |
fix(lua): gate frame-method self with the engine's own type check
Every engine frame method validates its `self` in three steps before
touching it: lua_type == table, resolve to the CFrameScriptObject, then
the IsA(typeId) vmethod at vtable+0x10. We did the first two and skipped
the third, so ResolveObject handed back a pointer for ANY frame and the
method cast it to whatever type it expected.
That was reachable from plain Lua, not just through a mirror or a hook.
The per-type method dispatcher is an __index handler that rawgeti's the
method closure out of the Lua registry, so frame methods are ordinary
first-class values, and
GameTooltip.SetSpellByID(ShapeshiftButton1, 133)
reached the tooltip builder with a Button, writing tooltip fields through
Button memory. The engine refuses that same call with "Wrong object type
for member function".
Game::Lua::ResolveTypedObject runs the engine's prologue and raises the
engine's own three error strings, read from .data rather than reinvented.
FrameScriptTypeId mirrors the lazy id assignment, so a check is valid
before any stock method of the type has run. Seven per-type wrappers stop
a call site pairing a method with the wrong class's id, and
ResolveTypedObjectAny covers a method that more than one type reaches.
45 call sites across 19 files now gate self. model/DisplayInfo.cpp had
already worked this out for Model alone and loses its private copy.
Type ids are per CLASS, one shared by all of that class's methods. Each
was read from the prologue of a method that can only belong to its class:
a base-class method registered into several tables carries the BASE id, so
sampling GetObjectType or GetDrawLayer would have produced a gate that
accepts unrelated types. Frame comes from Script_RegisterEvent and Texture
from Script_SetDesaturated, both cross-checked against the first entry of
their table.
Deliberately left ungated: the binding `owner` in bindings/Api.cpp and the
three co-hook sites in texture/Atlas.cpp. Each only uses the pointer as an
identity key and never casts it, so a gate would tighten the contract for
no safety gain -- and raising inside a co-hook would fire before the
original ran.
Verified in-game: the Button-as-tooltip call now raises the engine's
error; a Button still reaches a Frame-registry method
(button:SetAttribute round-trips), so IsA does accept derived types; and
fontstring:GetRotation() still answers -- that reader is registered on
both the Texture and FontString registries and needs the id pair rather
than the Texture id alone.
|
||
|
|
36c367a6d6 |
feat(macro): native #showtooltip, conditional slash commands, and a display API for addons (#48)
* feat(macro): native #showtooltip/#show, conditional /cast and /use
Backport the macro display system to the engine:
- Macro::ShowTooltip resolves `#showtooltip [cond] value` / `#show` (and
the bare form over the macro's /cast and /use lines, first match wins)
through the Lua SecureCmdOptionParse on the world tick and writes the
result into the engine's per-macro spell cache (+0x564/+0x568), which
every action reader already consumes. Repaints go through the engine's
own slot-changed notifier. Item targets are cached alongside.
Re-evaluates on modifier / mouseover / target / combat changes and every
200 ms otherwise. Yields entirely when SuperCleveRoidMacros is loaded.
- The `?` icon rule is a co-hook on the macro icon getter, so action
buttons and the drag cursor both show the resolved icon; GetMacroInfo,
GameTooltip:SetAction, GetActionCooldown, GetActionCount and
IsConsumableAction are re-registered in front of the engine for macro
slots with a resolved directive and tail-call it otherwise.
- Macro::RunBody re-implements the engine's body runner so `#` lines
never reach chat; Macro::Execute skips them too.
- /cast and /use in the embedded addon (3.3.5 handler shape): items
first, [@unit] via C_Spell.CastAtUnit, 1..19 = inventory slot, other
numbers stay spellIDs. SecureCmdOptionParse: a group whose only piece
is @unit passes only while the unit exists (3.3.5 passes it
unconditionally). C_Item.GetItemCount accepts names. GetMacroItem
added; GetMacroSpell now reflects the directive.
- Offsets.h: 0x004F0F40 was the macroID -> MacroEntry resolver,
mislabeled as a spell-state cache; renamed FUN_MACRO_ID_TO_ENTRY, with
the action-bar / macro-runner constants this needs added and verified.
* feat(unit): add IsUnitToken for token-vs-name dispatch
Vanilla ships each "act on a unit" verb as two Lua entries, one taking a
unit token and one taking a character name, and each errors on the other
kind of input. Conditional slash commands need to accept either, because
SecureCmdOptionParse hands back a token for `/target [@focus]` and a name
for `/target Bob` through the same variable.
IsUnitToken(value) answers which one a string is by calling the engine's
own token resolver inside lua_pcall and reporting whether it returned or
threw. Consulting the resolver rather than matching a token list here
keeps the answer correct for every family it knows, including this
client's native GUID literals and our own focus / nameplateN / markN,
which unit/TokenExtensions.cpp hooks onto the same function. It reports
whether the text names a token, not whether a unit is there, so "target"
with nothing targeted is still true.
if IsUnitToken(x) then TargetUnit(x) else TargetByName(x) end
Additive on purpose. Merging the pairs into a modern TargetUnit /
AssistUnit / FollowUnit was written and reverted: those names are common
enough for other DLLs and addons to replace that re-registration is
silently last-one-wins, with no error and no trampoline to chain. That
mechanism is only safe for names nobody else contends.
Offsets.h records two findings from decompiling the resolver. The throw
is raised by its callee, not by FUN_RESOLVE_UNIT_TOKEN, which is a thin
wrapper returning 0 on a miss. And this client reaches the error through
a patched fallthrough that first parses a 0x<hex> GUID literal, so GUID
unit tokens resolve natively with no SuperWoW loaded.
* feat(addon): backport the conditional slash commands
Adds 27 commands that take [conditions] through SecureCmdOptionParse,
following the 3.3.5 SecureCmdList handler shapes: targeting
(/targetexact, /cleartarget, /targetlasttarget, /targetlastenemy,
/targetenemy, /targetfriend, /targetenemyplayer, /targetfriendplayer,
/targetparty, /targetraid), casting and state (/stopcasting, /cancelaura,
/cancelform, /dismount), equipment (/equip, /equipslot), action bars
(/changeactionbar, /swapactionbar) and the pet family.
/target, /assist and /follow gain conditions by replacing the FrameXML
handlers, which is the only way to add them. Plain input keeps working:
each routes through IsUnitToken to the engine's token entry or its
by-name entry, where the old handler always went by name.
Three natives have a different shape here than the 3.3.5 handlers assume,
so those bodies are not straight ports. PetAttack takes no target and
always sends the pet at the current target. ChangeActionBarPage takes no
page and only fires ACTIONBAR_PAGE_CHANGED, so CURRENT_ACTIONBAR_PAGE is
set first. Pet autocast is a spellbook-slot toggle with no enable and
disable entries, so a name is resolved against the pet book and on/off
read the state and toggle only on a mismatch. /cancelaura needs no buff
walk, since CancelSpellByName already matches a player buff by name.
Not ported for want of a native: /targetlastfriend, and the /mt and /ma
family, which needs party assignments the client does not have.
Command names come from the locale files, with the localized name taken
from the matching Blizzard GlobalStrings and the English one alongside.
zhCN ships English for all 27. The short aliases retail also carries
(/eq, /tar) are left out, since those collide with addon shorthands.
* fix(macro): resolve item link values in #showtooltip
`#showtooltip` over a `/use item:6948` line showed no icon. The directive
evaluator built its item argument as `{0, 0, value}`, hardcoding the whole
value as a NAME, so the `item:N` and pasted-link forms could never match
and the value fell through to the spell lookup. `/use` itself was fine,
which is why the macro cast the item but the button stayed blank.
The link parsing already existed for the Lua entries. Split it out as
`Item::Arg::ResolveString` and call that instead of hand-building the
argument, so both paths read the forms the same way.
A bare number keeps skipping the item lookup: `ResolveString` reads "6948"
as an itemID, and a bare number that is not an equipment slot has to stay
a spellID per the documented `/cast 5019` rule.
An explicit itemID now also resolves when none is carried, falling back to
the ID after the bag and equipment walk misses. The icon and tooltip come
from the item record, and the tooltip path already handled an unheld item
through a hyperlink, so a macro naming an item in the bank or one written
before looting it now displays. Names are still limited to what you hold,
since 1.12 has no name-keyed item cache.
* fix(macro): make [@cursor] work in /cast, /use and #showtooltip
`/use [@cursor] item:4390` did nothing and its `#showtooltip` showed the
question mark. Two causes, both in the addon.
The parser rejected the clause. A group whose only piece is `@unit` passes
only while that unit exists, and the existence test ran UnitExists on
`cursor`, which is not a unit token. The engine raises there, the pcall
caught it, and the group failed. `none` was already exempt; `cursor` joins
it, since both name something other than a unit and neither can be tested
that way.
Nothing routed the target once it did pass. `SecureCmdUseItem` sent every
target through UseItemByName, which takes a unit GUID, and the spell branch
had only the on-unit and default cases. A `cursor` target now goes to
C_Item.UseAtCursor and C_Spell.CastAtCursor, which were written as the
`[@cursor]` analogs but had no caller. SecureCmdItemParse has already
turned a bag or inventory slot into a link, so one item call covers every
value form.
`#showtooltip` needed no change: the value resolves once the clause passes.
* feat(macro): accept a character name as a macro target
`/cast [target=Feral] Rejuvenation` did nothing. A `@unit` or `target=unit`
piece takes a character name as well as a unit token, but nothing here
turned a name into something the unit functions accept, and the existence
gate ran UnitExists on it, which raises for a string that names no token.
`UnitTokenFromName(name [, exactMatch])` runs the engine's own by-name
search — `FUN_UNIT_FIND_BY_NAME`, the one behind TargetByName, AssistByName
and FollowByName — and reports the winner as a token: a standard one when
it fits, else the GUID literal, which this client's resolver takes too. It
walks party, then raid, then every loaded unit, so it reaches units no
token names. Prefix match by default, nearest first, like TargetByName.
`GroupPasses` now resolves a named target once and uses it for both jobs:
the bare-group existence test (`[@Feral][] Spell` falls through when they
are not around) and the conditions, which previously raised on a name.
The pcall that already guarded the existence test is what tells a token
from a name, so a token target costs no more than before.
The slash handlers resolve the target the same way before handing it to
CastAtUnit, UseItemByName, FocusUnit or StartAttack, and drop the command
when a named unit is not around.
* feat(macro): drop a ground-target item at your feet with [@player]
`/use [@player] item:4390` sent the grenade through UseItemByName, which
passes a target GUID but never commits the placement, so the reticle came
up instead of the grenade landing. Route a `player` target to
`C_Item.UseAtUnit` instead, which commits at the unit's position.
Only your own position is offered. Aiming a ground-target item at another
unit is not something the game lets you do by hand, so the slash handler
does not either; every other unit target keeps going to UseItemByName.
`C_Item.UseAtUnit` now dispatches with the unit's GUID rather than a zero
target, matching `C_Spell.CastAtUnit`. Without that, routing `@player`
through it would have cost a non-ground item its target: a bandage or a
scroll would fire at the current selection instead of at you. It now
covers both kinds of on-use item, the way CastAtUnit covers both kinds of
spell.
* fix(macro): stop /cast [@unit] aiming ground spells at that unit
The same aim the item side was just denied: `/cast [@target] Flamestrike`
dropped the reticle on the target with no click, for any unit. Placing a
ground spell somewhere you could not put it by hand is aim the player has
not earned, and it should not differ between a spell and a grenade.
`/cast [@player]` and `/cast [@cursor]` still place, since both name a
position you can already aim at. Every other unit still has the spell cast
on it when it takes a unit target, which is what `@unit` is for; only the
ground-placement leg is dropped, leaving the reticle up exactly as casting
by hand does.
`C_Spell.CastAtUnit` keeps the whole primitive and gains a third argument
for the choice, defaulting to placing so the API and its callers are
unchanged. The restriction lives in the slash handler, the same split the
item side uses, where `C_Item.UseAtUnit` stays unrestricted and only
`/use` limits itself to `@player`.
`Spell::AtCursor::GroundPlacementPending` reports whether the in-flight
placement is a ground one, so the handler can leave that reticle up while
still cancelling a placement for a unit the engine did not accept. Leaving
that armed would strand the cursor.
* fix(item): stop a bad unit raising out of C_Item.UseItemByName
The optional `unit` went straight to the engine's token resolver, which
raises for a string that names no token. Both the code comment and the
API docs promised the opposite, that an unrecognized string is no target,
matching the no-op contract the item argument already has.
It is reachable without an addon calling the function directly: secure
button attributes and key bindings both feed it a configured string, so a
`unit="foo"` attribute raised inside a click handler.
Probe with Unit::TokenResolve::IsUnitToken first and treat anything else
as no target, which makes the documented contract true.
C_Item.UseAtUnit keeps raising, which is deliberate and now stated in its
docs: it is the companion of C_Spell.CastAtUnit, which documents the same
behavior as matching UnitHealth("garbage").
* feat(macro): let an addon publish its own macro display
`C_Macro.SetMacroDisplay(macroSlot, value)` hands a macro's resolution to
the display path, for an addon that parses macros itself. It is aimed at
SuperCleveRoidMacros, which today replaces ten action globals plus
GameTooltip.SetAction to put its answers on the bar, and borrows an
unrelated action slot to get a range check for a macro.
None of that is needed. Writing the spell into the engine's own per-macro
cache is what makes cooldown, range, usable, current and auto-repeat
correct for a macro button, with nothing overridden, and the icon then
reaches two places a Lua override cannot: the cursor while a macro is
dragged, and the macro window grid, both of which come from an engine
getter we hook.
The value takes the forms a `#showtooltip` value takes, so a publisher
hands over what it would have written in the macro. Three states: a value
to show, false for claimed-but-nothing-matched, nil to release.
Ownership is per macro. A published one is not parsed or re-evaluated by
us and is honored even while yielding; the rest stay ours. Nothing is
re-evaluated for the publisher, but a published resolution is re-applied
whenever the engine's re-parse overwrites the cache, so a macro edit
cannot silently replace it.
The wholesale stand-down when SuperCleveRoidMacros is loaded is lifted by
`CleveRoids.ClassicAPIMacroDisplay`, which a build sets to say it drives
us. Forks without it keep the all-or-nothing yield, so an older one cannot
end up fighting for the same buttons.
* fix(macro): accept the !Name prefix in /cast and #showtooltip
`#showtooltip` over `/cast !Shoot` showed nothing and the line cast
nothing: the `!` prefix, which asks for a toggle ability to be started
but never turned off, was never part of vanilla and no name resolver
knew it.
Split it in two.
The NAME is normalized in the one co-hook on the engine's single
name -> spellbook-slot resolver, which already owned the numeric
spellID form (so `spell/CastByID.cpp` becomes `spell/NameResolve.cpp`).
`FUN_RESOLVE_SPELL_NAME_TO_BOOK_ID` calls that resolver, so a single
strip covers the runtime cast, `Spell::Arg`, the `#showtooltip`
resolution and the engine's own macro parser -- which is what lets
`IsAutoRepeatAction` light a `/cast !Shoot` button even while macro
display is yielded to SuperCleveRoidMacros.
The BEHAVIOR stays in Lua: `SecureCmdCast` strips the prefix and casts
through the existing `CastSpellNoToggle`, which asks the engine whether
the ability is already up first. `CastSpellByName` cannot carry it --
re-registering that global is off limits and nampower already co-hooks
it.
`CastSpellNoToggle` gains the `placeGroundSpell` argument that
`C_Spell.CastAtUnit` has, so `/cast [@target] !X` keeps the rule that
only your own feet and the cursor place a ground-target spell. It also
tolerates a `!` on its own input now, since its auto-repeat name
compare is ours rather than the engine's.
* feat(item): take an item location wherever an item action takes an item
`C_Item.UseAtCursor`, `UseAtUnit`, `UseItemByName` and `EquipItemByName`
took an item reference only - an itemID, `item:N`, a link, or a name - and
resolved it by searching the bags for the first match. Holding two stacks of
the same item, or two copies enchanted differently, there was no way to say
which one you meant.
They now also take an item location: `{bagID=B, slotIndex=S}`,
`{equipmentSlotIndex=N}`, or an item GUID string - the shapes
`C_Item.GetItemID` already took. A location names one exact item.
`Item::Location::FindItemArgOrLocation` owns the overload; the old `Resolve`
(locations, pointer) and the new `ResolveItemArgOrLocation` (either, pointer)
are wrappers over it, so the classification and the walk live in one place.
None of the four call sites resolves anything itself any more.
A table is only ever a location, and so is a string that parses as a strict
`0x` + 16 hex digit GUID, which no item link or item name can look like. The
form is decided from the argument alone and committed to: a location resolve
STOMPS the Lua stack (`PackBagSlot` overwrites the first slots with its own
arguments), so falling back to the reference forms after one had run would
re-read the argument as whatever it left behind - a bag index read as an
itemID, which names an unrelated item.
`EquipItemByName` needs the source coordinates too, since the swap packet
carries them, which is what the detail form is for. An
`{equipmentSlotIndex=N}` location names a worn item, so with a `dstSlot` it
routes to `Item::Swap::FromPaperdoll` - that is how a ring 11<->12, trinket
13<->14 or weapon 16<->17 move is expressed. Without a `dstSlot` there is no
slot for the engine to pick, so that combination does nothing.
Its `lua_settop(L, 0)` ahead of `ClearCursor` is gone: `Script_ClearCursor`
(`0x004895B0`) is `FUN_00495190(1, 1)` and a return - no arguments, no stack
reads. Dropping it lets the item resolve run after the cursor clear, which a
location needs: while an item is held its slot reads empty, so the location
it came from would otherwise resolve to nothing.
* refactor: centralize the item constants and the icon-path build
Four copies of the ItemStats displayInfoID -> `Interface\Icons\<name>`
chain had accumulated - `item/GetData`, `item/Info`, `container/ItemInfo`
and the new `item/Icon` - and they had already drifted: two checked for an
empty icon name and two did not. `Item::Icon::PathForDisplayInfoID` is now
the one builder and the other three call it, so a change to that chain has
a single site. `PathForItemID` is it plus the cache lookup.
`action/ItemState` had local constants shadowing values already in
`Offsets.h`: `kItemSpellSlots` for `ITEMSTATS_SPELL_SLOT_COUNT`, and a bare
`trigger == 0` for `ITEM_SPELLTRIGGER_ON_USE`. `INVTYPE_AMMO` / `THROWN`
existed in two files, and the engine runner's `0x400` macro line buffer in
two more, so those move to `Offsets.h` as well - `INVTYPE_*` next to the
string table they index, `MACRO_LINE_BUFFER_SIZE` next to the delimiters.
CLAUDE.md's rule, and duplicated offsets drifting is exactly what it was
written for.
* fix(macro): indented directives, release, and icon-getter re-entry
Three defects found reviewing the `#showtooltip` work, plus dead code.
A directive typed with a leading space was lost AND leaked to chat.
`ParseDirective` and the two `#`-line filters all tested byte 0, but the
tokenizer splits on `\r\n` only, so ` #showtooltip` arrives with its space:
the parse missed it, and then `Macro::RunBody` / `Macro::Execute` failed to
recognize the comment and dispatched the line through `EXECUTE_CHAT_LINE` -
the /say this feature exists to stop. All three skip blanks now, as does
`CastCommandArgs` so an indented `/cast` line is still collected, and the
runner dispatches the trimmed line so an indented command works at all.
`C_Macro.SetMacroDisplay(slot, nil)` left the publisher's spell in place.
`Release` cleared our entry and asked for a rescan, but `Rescan` only marks
an entry dirty when it has a directive with options - so for a macro with
no directive of its own, nothing ever rewrote `+0x564`, and the button, its
tooltip, cooldown and auto-repeat state stayed on the published spell until
the engine happened to re-parse. It now hands the field back to the engine
by running the engine's own parser, then repaints.
The macro icon getter could run Lua from under a click. `FUN_MACRO_ICON_PATH`
has two callers and one is `FUN_MACRO_PICKUP`, inside the UseAction core, so
`Lookup`'s catch-up could evaluate conditions through `SecureCmdOptionParse`
and fire `ACTIONBAR_SLOT_CHANGED` into addon handlers while the drag was on
the stack - the re-entrancy hazard CLAUDE.md records for `Tooltip::SetEvents`.
`LookupPassive` reads only what the entries already hold; the world tick
does the work and repaints, so a resolution can be one tick behind an edit.
Also drop `Active()` (no callers) and `RunBody`'s unused trampoline, and
correct the header's reference to a module that does not exist: the icon
comes from `Macro::IconPath`, not `Action::Texture`.
* fix(slash): five conditional-command defects, and cheaper option passes
`/cast 5019` could consume an item. A bare number that is not an
equipment slot is a spellID, but it reached the item lookup, which reads a
number as an itemID - so carrying item 5019 used it instead of casting the
spell. `Macro::ShowTooltip::ResolveValue` already guarded this exact case,
so the button showed the spell while the click used an item.
Every bare `/targetenemy` stepped backwards. The cycling selectors pass
the parsed value as their reverse flag, and a clause that matches with no
value yields the empty string - which is a true boolean in Lua. Six
commands were affected in their most common form.
`/cast [@none] Spell` did nothing. `@none` names no unit, but only
`@cursor` was exempted from the token resolve, so `none` went to the
by-name search and the cast was dropped. It now means no unit, which is
the untargeted form of the verb; `/target [@none]` clears the target, as
documented. The other unit verbs no longer feed `none` to that search
either - it matches on the START of a name, so it would find a Nonek.
`/assist [@target] Bob` ignored Bob. `/target` and `/follow` both let a
trailing name win over an explicit `target=target`; assist did not.
`/use [@player] 0 1` used the wrong item. The position branches ran before
the bag branch, so a named slot was thrown away and the item re-found by
link - the first match anywhere, which with two stacks is the wrong one.
Every form now resolves to one item and goes through one call, which also
means a slot is aimed by `@unit` like a name is, and that `/use` always
uses: clicking a bag slot sells the item at a merchant and repairs it
under the repair cursor (`Script_UseContainerItem` branches on the
merchant GUID and on cursor mode 0x11), which a typed command must not do.
`GroupPasses` also stopped paying for an answer it discards. A group with
conditions only needs a token, so it asks `IsUnitToken` rather than
`pcall(UnitExists)` - the conditions test existence themselves. The
existence path keeps its single pcall, and a name, which costs an
object-manager search, is remembered for the rest of the pass.
|
||
|
|
9a26207df2 |
feat(item): read a bagged weapon's temporary enchant
C_Item.GetWeaponEnchantInfo covers only the three equipped weapon slots, so a poisoned or oiled weapon sitting in a bag reported nothing. Add C_Item.GetItemTempEnchantInfo(itemLocation), returning the same (hasEnchant, expirationMs, charges, enchantID) tuple for any location the rest of the C_Item location family accepts. The temporary-enchant reader already needed nothing but a CGItem, so it now takes one directly, with a thin wrapper for the paperdoll path. Its local copy of the slot offset (0x4C) gives way to the block layout Offsets.h already carried for spell/BonusDamage.cpp, extended with the within-slot duration and charges deltas and a named temporary-slot index. Verified in game: a staff carrying Brilliant Mana Oil reports enchant 2629 both equipped and in a bag, and the remaining duration keeps counting down while the weapon sits there. Fixes #47 |
||
|
|
a124629669 |
fix(item): warm the cache when an icon lookup misses
The three icon accessors (GetItemIcon, C_Item.GetItemIcon, C_Item.GetItemIconByID) all funnel through PushIconForItemID, which peeked the cache and returned nil on a miss without queueing the item. Every sibling getter -- name, quality, level, sell price, max stack size, inventory type, family, spell, openable, uniqueness, set, average level -- calls WarmCache there, so the icon was the only field that could not self-heal: a caller polling after a miss re-resolved every other field while the icon stayed nil for the rest of the session, because nothing else ever requested that itemID. Most visible right after login, where the carried-item prefetch can walk a bag-slot GUID array that SMSG_UPDATE_OBJECT is still filling and legitimately not see an item yet -- reported downstream as icons that resolve when the client loads fast and never when it doesn't. But that window only decided WHICH items were affected; the permanence was this missing warm, which equally broke every uncached icon the prefetch never touches -- quest rewards, vendor and auction listings, links out of chat. Verified in-game: IsItemDataCachedByID(19019) reports false, and a re-poll two seconds later returns Interface\Icons\INV_Sword_39. Both calls returned nil indefinitely before. |
||
|
|
a9d2ad73f3 |
feat(container): add C_Container.SortBags and SortBankBags
Two phases, because every item move is a server round trip and the second phase reads slot contents the first changed. Phase one packs partial stacks; phase two runs on the next Bag::UpdateDelayed, plans the whole layout, and fires the swaps as one batch, tracking each item's live position rather than re-reading a layout it is mutating. The ordering is ours, since retail computes it in code we cannot read and its categories have no counterpart here: hearthstone, gear by descending quality, consumables, reagents, trade goods, quest items, everything else by quality, junk last and filled from the far end. Then class, subclass, name, fuller stacks first - a real tuple comparator, so there is no zero-padding to overflow and no placeholder name to wedge an unnamed item among real ones. An item whose data has not arrived is pinned in place with its slot withheld, rather than ranked by guesswork. Neither phase may touch the Lua stack, since phase two runs from a bag update callback. Hence Lua-free ContainersFrom / AutoStoreFrom / MoveCountFrom, with the Lua-taking forms reduced to resolving the source pointer and delegating, plus a direct invMgr walk instead of ResolveBag. Five things had to be found the hard way, every one of them the client's local state disagreeing with the server's: - Never plan a swap between two stacks of the same item. Player::SwapItem tries a MERGE before it considers swapping and returns if that succeeds, collapsing two slots into one or redistributing counts and leaving both in place. Neither is a swap, so a single collision invalidated the bookkeeping for every move after it in the batch. One collision in a 55-item bag turned one pass into three. - Entry marked "unplaced" with destBag = -1, safe while bag IDs were 0..4 and wrong the moment the main bank joined as bagID -1: every item bound for the main bank read as unplaced and had its move dropped, so nothing could move into the main bank at all. The sentinel is destSlot now, which cannot collide because slots are 1-based. - FUN_INVENTORY_SWAP's last argument gates a pre-send confirmation check. With 0, a Bind-on-Equip item the character could wear is stashed behind the bind dialog and NO PACKET IS SENT - silently, since the builder returns void. Now passes 1, which is what the engine itself does when re-issuing a swap after the dialog is accepted, and is correct here because both endpoints are always bag content slots where nothing binds. - CMSG_AUTOSTORE_BAG_ITEM cannot merge across bags. Its destination byte can only be INVENTORY_SLOT_BAG_0 (255) for the player, and server-side that is the specific-container branch: keyring and backpack only. The search-every-bag path is NULL_BAG (0), which the builder cannot emit. Both sets now use one explicit two-pointer merge that addresses both endpoints and works everywhere. It costs a packet per transfer rather than per emptied source, which is the price of being correct. - The merge loop must choose split-versus-swap from its own model, not the item's live stack count. The batch goes out in one frame with no replies, so descriptors still hold pre-batch counts; a move the model knew was the last of a stack went out as a split, and the server rejects a split that would empty its source. Consolidation packs fully rather than stopping once a slot is freed: 9 and 2 with a cap of 10 become 10 and 1. It settles in one pass and sends nothing on the next call, because a packed group has every stack full except the last, so the first step walks straight to the end. Bank specifics: ViewForBag gains the main bank (bagID -1, inside the player's own invMgr) and bank bags (5..10, each with its own), which can themselves be specialty bags. Bank bags resolve only once the bank window has been opened, which is the right gate rather than an accident - the server refuses bank moves without it, so a bank sort with the bank closed finds no cells and does nothing instead of dispatching a batch that would be rejected wholesale. _classicapi_SortBagsStats() and _classicapi_SortBagsBags() report the last pass and the per-bag view. Both earned their keep: the stats ruled out our side of the swap divergence by showing a complete plan fully dispatched with zero local failures, and the per-bag dump ended the sentinel hunt by eliminating the entire area three successive guesses had been aimed at. |
||
|
|
db88fca050 |
feat(container): add C_Container.AutoStoreItem
Moves an item and lets the server pick the destination slot, which is worth having because the server does not merely find an empty one: it first merges the stack into existing stacks of the same item, splitting it across several when that is what fits, and places a remainder only if one is left. So one call consolidates a partial stack. Two engine builders back it, because the wire has two autostore opcodes. FUN_005E12E0 sends CMSG_AUTOSTORE_BAG_ITEM (0x10B) and takes a destination container, so it can confine an item to one equipped bag or let the server search the whole inventory. FUN_005E18F0 sends CMSG_AUTOSTORE_BANK_ITEM (0x282) and takes no destination at all - the server derives the direction from the source, so a bank source travels to the inventory and an inventory source to the bank. AutoStore picks between them and accepts only the pairs the wire can honestly serve. Bank-to-bank is not among them, so consolidating stacks within the bank still needs per-pair moves. Both builders' stack-arg counts come from their RET, not from a decompiler parameter list. 0x10B's last slot is never read by the body but is still popped, and declaring seven args instead of eight made the callee pop four bytes we never pushed - which shifted the caller's frame and surfaced as a garbage Lua state pointer in the next function to run, several frames from the call. Noted at both offsets, since this family is not uniform in arity. Three fixes to the shared bagID encoder found while doing it: - EncodeBagSlot had no case for the keyring (bagID -2), so SwapItems, MoveItem and AutoStoreItem all rejected keyring slots. The engine's own map in FUN_PACK_BAG_SLOT has had it all along, and the linear base was already recorded in the invMgr slot map. - Its bank constants restated named Offsets::INVMGR_* values, so they now derive from them, and the slot map is fully named rather than half constants and half comment. Each player-container range is bounded by both its own last linear slot and the live invMgr count - stricter than before, where the backpack had no upper bound at all. - FUN_PACK_BAG_SLOT's fourth out-param was labelled outUnused. It is the bank flag, and it is what makes right-clicking a bank item send 0x282 instead of using the item. |
||
|
|
993c82cca7 |
refactor: route unit-token resolution through Game::ResolveUnitToken
Sweep the ~35 modules that each hand-rolled a `ResolveUnitToken_t` typedef plus `reinterpret_cast<…>(Offsets::FUN_RESOLVE_UNIT_TOKEN)` onto the shared `Game::ResolveUnitToken` helper. Behavior-identical — it is the same engine function — and net -87 lines. The typedef now lives in exactly one place (Game.cpp). unit/Position.h is a header, so it gains an `#include "Game.h"`; every other touched file already pulled Game.h in. No offsets, logic, or unrelated typedefs were changed. |
||
|
|
7f52afeef4 |
perf(event): fire custom events through O(1) AutoReserve::Slot()
Every custom-event fire resolved its name to a slot via Event::Custom::Lookup - a linear strcmp scan over the ~46-entry reservation table, on every single fire. The slot itself was already cached per table build; only the name->reservation hop was repeated. On a client that is purely CPU-bound, that is wasted work on paths that burst exactly when frames are scarce (nameplate churn, cast spam, loot rolls, mouse/modifier input). AutoReserve now remembers its reservation index (the ctor's dedup resolves duplicate names to the same entry) and exposes Slot() - two loads. Reload safety is unchanged and stays centralized: Slot() reads through the shared table PrepareForReload/RetryClaims maintain, so the value can never go stale. Lookup is deleted; LookupByName remains for engine-defined names. All fire sites converted to the instance handle: - CastEvents: the k* name constants become the AutoReserve instances, so all 19 fire sites stay textually identical; the Fire/FireReticle/ FireRemote helpers take the reservation by reference. - equipmentset: reservations move into Set.h as C++17 inline consts so the Data and Api TUs share one handle. - Cache::QueryLoad::Register takes the AutoReserve pointer instead of an event-name string (creature/gameobject callers updated). - Tts keeps its lazy VanillaTTS-stand-down reservations via null-guarded pointers set at registration. - GlobalMouse/InputEvents/lossofcontrol instances moved above their fire sites (static-init list order is irrelevant). |
||
|
|
58ddcace32 |
perf(item): settle the item-cache gate on a wall-clock delay, not frames
The startup gate that defers item queries until the engine's dispatch is ready used a fixed 60-frame count, which is FPS-dependent: on a fast machine it could fire before dispatch was ready (orphan risk) and on a slow login it stretched well past its intended ~1s, leaving bag icons as "?" longer than needed. Anchor the delay to VAR_IN_WORLD (set by the enter-world initializer, cleared on every transition) and measure a fixed 1000 ms past world-live, so it is identical on any machine and only starts once the loading screen is gone. The engine-response fast-latch is untouched: a real item response still settles the gate instantly, so a warm WDB has no delay and only a cold WDB waits the floor. Drops the now-unused frame counter. |
||
|
|
58ee86447b |
feat(item): proactively cache carried items on enter-world
A bag item's icon comes from its ItemStats cache entry (m_displayInfoID);
on a cold WDB an uncached bag item resolves displayID 0, and the icon
path draws INV_Misc_QuestionMark ("?"). Nothing in the bag-draw path
queries stats (GetContainerItemInfo and the icon getter both do
null-callback lookups), and the server pushes no item stats on login, so
a carried item stayed "?" until a hover, a loot, or an addon GetItemInfo
happened to query it. Equipped items are exempt (icon from the
server-pushed visible-items table).
Seed the request queue with every carried item once the startup gate
settles (one-shot per enter-world, re-armed on login and /reload) on the
existing owned-priority lane. This gives complete carried-item coverage
ahead of any addon's background flood, stays bounded by the same owned
budget so it adds no burst (issue #25), and is still deferred past
g_settled so it cannot orphan a cache entry before the engine's dispatch
is ready.
|
||
|
|
c54556f6a1 |
refactor: centralize engine field/global access via Game::Read/Ref/Ptr
Replace the raw `*reinterpret_cast<const T *>(base + Offsets::OFF_X)` idiom (and its double-cast variant when base wasn't already a byte pointer) with three typed accessors in Game.h: Game::Read<T>(base, offset) field value read Game::Ref<T>(base, offset) writable field lvalue Game::Ptr<T>(base, offset) pointer to a field (arrays / out-params) Game::Read<T>(address) / Ref<T>(address) fixed-VA globals Pure mechanical refactor, zero behavior change: ~330 cast sites across 84 files collapse to 651 helper calls. Offsets stay in Offsets.h per the single-source-of-truth rule — the helpers only remove the cast noise and fold away the inner `reinterpret_cast<uint8_t*>(obj)` base casts. Left as raw casts by design: FUN_* function-pointer casts, void*/char* VA handles passed as arguments (caches, method registries), subobject- anchor pointers fed to __thiscall helpers, `void *volatile` player-ptr readiness gates (converting would strip volatile), and VA-as-array-base captures that are subscripted later. |
||
|
|
5456295e2e |
fix(item): throttle item-cache queries; prioritize carried items
Post-settle `WarmCache` fired one CMSG_ITEM_QUERY_SINGLE per item immediately, and `OnWorldTick` escalation issued every pending item in a single tick. A `/reload` that makes addons (pfQuest/Questie/Bagnon) look up hundreds of items in one frame therefore emitted an unbounded packet burst — a reported 1,325 requests in ~14 ms exhausted a consumer router's NAT table and dropped the machine's internet connectivity. Make `OnWorldTick` the single point that issues queries and rate-limit it. All warmups now route through the pending queue (`WarmCache` -> `Track`); background misses go out at most one per 50 ms (20/sec). The timeout now counts only after a query is actually issued, so a throttled backlog no longer fires spurious failures for items never queried. To keep the throttle from delaying the player's own inventory on a cold cache, add a priority tier: the carried items (equipment + backpack + equipped bags) issue first on a separate budget (up to 6/tick, no spacing floor). The owned set is a bounded snapshot built by a pure-C inventory walk (no Lua stack — safe at world-tick time), refreshed at most once per second and only while there is queued work. Peak issue rate stays ~7 packets/frame, far below the flood. Fixes #25 |
||
|
|
39d22ac124 |
fix(time): centralize engine ms-tick reads in Time::Clock
The engine's OS millisecond counter (FUN_OS_TICKCOUNT_MS, same epoch GetTime() scales by 0.001) is unsigned and wraps at 2^32 ms. Nine files each re-derived the reader; several stored the tick into a signed int, so past 2^31 ms (~24.9 days uptime) every timestamp went negative and `startTime + duration` landed in the past -- callers saw every cooldown, aura, and lockout as already elapsed. The same bug shipped three times (the cooldown by-ID getters and C_LossOfControl). Add one source of truth -- Time::Clock (src/time/Clock.h) -- with a uint32 NowMs() and wrap-safe Reached/Remaining/Elapsed helpers, and route every tick reader through it. No module re-derives the reader or hand- rolls a `now < deadline` compare (which inverts across the wrap) anymore. Also fixes the reported cooldown/LoC getters (unsigned out-params, wrap-safe compares) and three latent instances of the same `now < end` inversion found while sweeping: totem/Tracker's two timer getters and aura/Source's cache-eviction pass. Named Time::Clock, not Time::Tick, because a Time::Tick inner name shadows the global Tick namespace (the WorldTick hook) from inside any Time::* file. Discovered by fuffc in #17. |
||
|
|
13008ab8aa |
refactor(item): centralize passive item-cache peek in Item::PeekRecord
Add item/Record.{h,cpp} with Item::PeekRecord(itemID) -- the passive
ItemStats_C cache peek (null callback, no network query). Route the three
duplicate implementations through it:
- the per-module GetItemRecord_t typedef + fn(cache,id,&zero,nullptr,
nullptr,0) call in ~25 read-only item accessors
- Item::StatAccum::FetchRecord (deleted; 7 callers repointed)
- item/Tooltip.cpp's local PeekItemRecord (deleted)
Behavior-identical: every converted call was already a passive peek with
identical args (dedup flag is a no-op when the callback is null).
item/Data.cpp is deliberately untouched -- it owns the ACTIVE fetch
(CacheFetch passes a real callback to fire SMSG_ITEM_QUERY_SINGLE, the
load-bearing cache-race path in CLAUDE.md) and keeps its own typedef.
|
||
|
|
0df8885045 |
refactor(offsets): collapse duplicate object type-mask enum (OBJ_TYPE_* -> TYPEMASK_*)
OBJ_TYPE_* was a partial second naming of the same object-type bits as the complete TYPEMASK_* set (OBJ_TYPE_ITEM=2=TYPEMASK_ITEM, ... GAMEOBJECT =0x20 both) -- a single-source-of-truth violation. Repoint all ~18 references to TYPEMASK_* (identical values, behavior-preserving) and delete the OBJ_TYPE_* definitions, folding their derivation notes (bitmask semantics, FUN_004F8DB0 for PLAYER, FUN_0052AA20 for GAMEOBJECT, FUN_00529FE0 SetUnit) into the surviving TYPEMASK_* comment. |
||
|
|
8fa344a084 |
refactor(item): name CGItem deref idioms via Item::InstanceBlock / ObjectFields
Add item/CGItem.{h,cpp} with two null-safe accessors for a CGItem's two
descriptor-like pointers:
InstanceBlock(cgItem) -> CGItem + 0x08 (item GUID @ +0, itemID @ +0x0C)
ObjectFields(cgItem) -> CGItem + 0x114 (stack/flags/charges/durability/...)
Replace the 30 hand-written `*reinterpret_cast<const uint8_t *const *>(x +
OFF_ITEM_INSTANCE_BLOCK/OFF_ITEM_DESCRIPTOR)` derefs across 24 files with
these calls. Behavior-preserving: same deref, all reads were already const,
and each site keeps its own null-check and field reads. Helpers add a
cgItem null guard (strictly safer).
|
||
|
|
2612118ff6 |
refactor(object): centralize GUID->object resolution in Object::ByGuid
Every caller of the engine object resolver (0x00468460) re-declared the
same __fastcall typedef and split the GUID into lo/hi by hand -- 30 call
sites across 28 files. Add object/Resolve.{h,cpp} with
void *Object::ByGuid(int typeMask, uint64_t guid, const char *debugName, int priority)
and route every site through it (behavior-identical: same typeMask,
debugName, priority per site; single-uint64 callers pass guid, split-lo/hi
callers reconstruct it).
Also collapse the duplicate offset constant: FUN_CLNT_OBJ_MGR_OBJECT_PTR
was a second name for the same 0x00468460 address as
FUN_OBJECT_RESOLVE_BY_GUID (a single-source-of-truth violation). Remove
it; the ABI-equivalent (u32,void*,u64,int) view it documented is folded
into the surviving constant's comment.
|
||
|
|
b8bd0bce4e |
fix(unit): gate +0xE68 sub-struct reads on OBJECT_TYPE_PLAYER, not PLAYER_CONTROLLED
The CGPlayer sub-struct at [unit+0xE68] (guild key, PLAYER_FLAGS, quest list, visible items) exists only on real player objects. Reads of it were gated on UNIT_FLAG_PLAYER_CONTROLLED, but the server sets that flag on pets, totems, guardians, companions, and MC'd creatures too (Turtle UnitDefines.h; Pet.cpp/SpellEffects.cpp/SpellAuras.cpp setters) -- all TYPEID_UNIT creatures with no such sub-struct. On one of them the +0xE68 pointer is garbage-but-non-null, so the null check passes and the deref AVs (ERROR #132, pfUI issue #34: UnitIsInMyGuild on a nameplate pet/totem, frequent in crowded dungeons/raids). Add Unit::Flags::IsPlayerObject (m_objectType == OBJECT_TYPE_PLAYER via [obj+0x14]) and use it as the gate at every arbitrary-unit +0xE68 reader: - UnitIsInMyGuild (ReadGuildKey) -- the reported crash - UnitIsAFK/UnitIsDND (TestPlayerFlag) -- same latent crash on a pet - IsUnitOnQuest (Quest::Log::UnitHasQuest) - GetInventoryItemID (non-local unit visible-items path) Local-player-only readers are unaffected. IsPlayerControlled stays for minion/ownership classification (Unit::Pet), which wants the broad flag. |
||
|
|
e84673dde5 |
item: clamp bank-bag slot count in NewItems baseline scan
AppendNonBagOwned read each bank-bag container's slot count straight from the invMgr's first dword with no upper bound. A container resolved while only partially initialized (plausible right at login) can yield a garbage value there, driving AppendGuidArray into a multi-billion- iteration loop -- a multi-second freeze. Clamp to kMaxContainerSlots (64), far above any real vanilla/Turtle bag, so it's invisible to real inventories and only trips on a bogus count. |
||
|
|
564495248c |
item: apply random suffix in by-string GetItemNameByID / GetItemInfo
C_Item.GetItemNameByID and C_Item.GetItemInfo resolved an item link down to just the itemID and dropped the random suffix (3rd `item:` field), so "item:12022:0:769:0" returned "Iridium Chain" instead of "Iridium Chain of the Owl" (and GetItemInfo's rebuilt link lost the 769). The global GetItemInfo applies it; now these match. Item::Arg::Resolve parses the suffix alongside the itemID. New Item::Link::NameFromIDSuffix builds the suffix-decorated name from (itemID, suffixID) without a live CGItem, via the engine's inner name builder (FUN_005d8b00 = the formatter behind FUN_ITEM_BUILD_INSTANCE_NAME, which reads the localized "of the X" suffix from ItemRandomProperties). Item::Link::BasicFromIDSuffix preserves the suffix in the rebuilt link (payload + bracketed name); BasicFromItemID is now a suffix=0 wrapper. GetItemNameByID and GetItemInfo route through these; numeric/suffixless input still yields the base name. Numeric item stats are unaffected (the suffix only decorates the name/link). Enchant/unique fields are normalized to 0 in the rebuilt link (suffix is what affects the name). Verified in-game: item:12022:0:769:0 -> "Iridium Chain of the Owl" (name + link); bare 12022 / item:12022:0:0:0 -> "Iridium Chain". |
||
|
|
659dd7e159 |
newitems: fix false "new" flags from transient bag-scan drops
A bag update in progress transiently drops items from the pure-C++ bag read -- sometimes the entire backpack (all 16 slots) for a frame or two. The old logic rebuilt the seen-set from each scan, so a momentarily- missing item fell out of the set and was re-flagged "new" the instant it reappeared (e.g. dragging/swapping an item into the backpack lit it up). Replace the rebuilt-each-scan set with a persistent seen-set whose entries carry a consecutive-absent-scan counter (SeenReconcile): present items reset it, absent ones age by one, and only items absent kMaxMissStreak scans running are evicted. Counting scans rather than wall-clock means a pause with no bag activity never ages an owned item, and any reappearance resets the streak -- so transient drops are absorbed while the set stays bounded to ~currently-owned items (genuinely-removed items age out). Verified in-game: backpack repeatedly vanishing from the scan, seen-set holds steady, zero false flags. |
||
|
|
a20e1206fb |
totem: add GetTotemInfo(slot) with a self-tracking totem subsystem
Vanilla 1.12 tracks nothing about totems client-side (the totem bar, PLAYER_TOTEM_UPDATE, and GetTotemInfo are all TBC additions), so Totem::Tracker tracks the four element slots itself — data-driven: - Slot from the summon spell's Spell.dbc effect (87-90 = SUMMON_TOTEM_SLOT1..4 = Fire/Earth/Water/Air; slot = effect - 86). - Creature entry from the effect's EffectMiscValue (for death detection). - Duration from SpellDuration.dbc via the engine duration helper. - haveTotem tool item from the spell's Totem[0] field (0xA0) — the totem the spell requires (a tool, not a consumed reagent) — resolved from the player's spellbook on SPELLS_CHANGED, not hardcoded. Casts are observed through Aura::Source's existing SMSG_SPELL_GO hook (a one-line notify before its aura gate, since a summon applies no aura) — no new hook, respects one-hook-per-target. Tool items resolve on SPELLS_CHANGED (a no-arg event via the shared Event::SignalHook), when the spellbook is populated. A slot clears when its duration elapses OR when the totem creature disappears early (killed / Totemic Recall / destroyed), detected by a throttled WorldTick object-manager scan for the player-owned creature of that entry (seen-then-gone latch; CreatedBy == player so another shaman's same-entry totem can't mask yours). GetTotemInfo returns haveTotem, totemName, startTime, duration, icon, modRate=1, spellID. Turtle-custom totems are tracked automatically. Also exposes Item::Count::InInventory (equipped + bags) as a shared helper for the tool-presence check. Verified in-game: Earthbind lands in slot 2, haveTotem reflects the Earth Totem tool, and Totemic Recall clears the slot early. |
||
|
|
8fdc767cc7 |
item: add Enum.ItemQuality
Poor=0 through Artifact=6, matching the numeric quality GetItemInfo / C_Item.GetItemQuality report. Heirloom (7) and WoWToken (8) are omitted — no such items exist on 1.12. Registered in src/item/TypeInfo.cpp alongside Enum.ItemClass / Enum.InventoryType. Docs + README updated. |
||
|
|
aa31c25be5 |
item: add GetItemClassInfo, GetItemSubClassInfo global, Enum.ItemClass
- GetItemClassInfo(classID) -> localized ItemClass.dbc name, registered as both a global and C_Item.GetItemClassInfo. Obsolete class slots return the client's literal "...(OBSOLETE)" string. - GetItemSubClassInfo(classID, subClassID) exposed as a global (the C_Item form already existed); returns name + the armor-material bool. - Enum.ItemClass: 0..15 with modern key names on the obsolete slots (Gem/ItemEnhancement/CurrencyTokenObsolete/PermanentObsolete), plus post-vanilla 16..19 for parity, matching the Enum.InventoryType precedent in the same module. All added to src/item/TypeInfo.cpp alongside the existing subclass / inventory-type surface. Docs + README updated. |
||
|
|
461f15a4a6 |
item: derive bag family from (class, subclass) for bags with empty field
Turtle's item data leaves m_bagFamily at 0 on the bags/quivers themselves — the four profession bags (Soul/Herb/Enchanting/ Engineering, Container class) and quivers/ammo pouches (Quiver class) all read 0, so C_Item.GetItemFamily and C_Container.GetContainerNumFreeSlots reported 0 for them even though the tooltip clearly shows "Soul Bag" etc. Recover the family from the item's class + subclass instead (keyed on class because subclass numbers repeat: Container sub 2 = Herb Bag, Quiver sub 2 = Quiver). Loot items keep carrying the field directly. Factored the derivation into a shared Item::BagFamily helper (BitmaskForRecord) used by both GetItemFamily and the free-slot functions, so a bag and the items it holds always agree on the family bit. Side effect: CalculateTotalNumberOfFreeBagSlots now correctly excludes specialty bags from the general free-slot total. Non-stock data lives in its own module: src/turtle/ with a TURTLE_WOW_VERSION-based Turtle::Detected() gate (no realm sniffing) and the custom Meat/Fish/Leather/Mining families (ItemBagFamily.dbc rows 10-13) plugged into Item::BagFamily via an AutoResolver extension point, so the stock table stays pure vanilla. |
||
|
|
e1ffaab6b4 |
item: add native C_Item.GetItemInfo (full modern tuple)
Implement C_Item.GetItemInfo(itemInfo) in C, returning the full modern tuple instead of the Lua alias to the vanilla global (which only returned 1.12's short set). Sourced entirely from the cached ItemStats_C record plus the class/subclass/inventory-type DBC name lookups item/Info.cpp already does for GetItemInfoInstant — no new duplication. Returns 18 values: itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType, expansionID (0), setID (nil if none), isCraftingReagent (false; no such flag in 1.12), itemDescription. itemTexture is the icon path (no fileID system in 1.12). On a cache miss it warms the cache and returns nil, landing on the GET_ITEM_INFO_RECEIVED retry — same async contract as the stock global. Drops the `C_Item.GetItemInfo = GetItemInfo` shim from ItemUtil.lua so the native implementation isn't clobbered at addon load. Verified in-game against Rancher's Trousers (nil setID) and Blackened Defias Boots (setID 161) — all 18 fields correct. |
||
|
|
c13b1c8eb7 |
item: fix C_NewItems flagging unequipped / bank-pulled items as new
The new-item diff only tracked bag contents, so an item moving INTO a bag from anywhere out of scope looked identical to a fresh loot. Unequipping a piece of gear (equipment -> bag) flagged it new; same for pulling an item out of the bank. Widen the "already owned" baseline to the player's whole inventory — bags, worn equipment (paperdoll + equipped bags), and the bank (main + bank bags) — while still only flagging bag items. An item whose GUID was already owned somewhere is a move, not an acquisition, so it isn't flagged. Bank GUIDs are read straight from the invMgr array (the gate-bypass C_Item.GetItemCount already uses; the array is server-populated at login), so no bank window is needed. Cap raised 256 -> 512 to hold bags + equipment + a full bank. |
||
|
|
e8a03d584b |
spell: add GetSpellBonusDamage / GetSpellBonusHealing
GetSpellBonusDamage(school) reads the player's per-school spell damage
directly from the CGPlayer sub-struct at [player+0xE68]+0xFD4 (POS) / +0xFF0
(NEG), net = POS-NEG. That field isn't in the broadcast descriptor (+0x110
reads zero — the vanilla server never sends it there), but the client keeps a
fully-computed copy at +0xE68 with gear/enchants/buffs/talents/sets baked in.
Same source nampower's GetSpellPower reads; verified 613 generic / 647 Fire on
a geared mage. 1-based school, matching 3.3.5's Script_GetSpellBonusDamage.
GetSpellBonusHealing() has no such field (vanilla lacks a healing-done field
entirely), so it's derived to mirror the server's SpellBaseHealingBonusDone:
- flat healing: SPELL_AURA_MOD_HEALING_DONE (135) off gear equip-effects,
item enchants, random suffixes, and active buffs
- Spirit conversion: SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT (175) x
total Spirit / 100 (Priest Spiritual Guidance)
- Armor conversion: SPELL_AURA_MOD_SPELL_HEALING_OF_ARMOR_PERCENT (199) x
armor / 100 (Turtle Ironclad)
Percents are read straight from Spell.dbc, so it's generic across any
aura-175/199 talent/buff including Turtle customs, and gated on SPELL_ATTR_
PASSIVE for the known-spell-bitmap walk. Spirit/Armor come from UNIT_FIELD_
STAT4 (+0x250) / UNIT_FIELD_RESISTANCES[0] (+0x254).
Item flat healing routes through the shared Item::StatAccum engine rather than
re-implementing the item spell/suffix/enchant walk: extract a reusable
ApplyEnchant() (from ApplyRandomSuffix) plus a Value() reader, and read
ITEM_MOD_SPELL_HEALING_DONE_SHORT.
The healing sum is expensive (StatAccum over 19 items + buff table + the 27k
known-spell bitmap), so it's cached and recomputed only when a player stat
input changes. New Player::StatSignal (a pull-based epoch) is bumped from the
aura hooks (player-guarded), the equipment observer, and the spell learn/
unlearn writers (0x4B25B0 / 0x4B2C50) -- so buffs, gear, and talent respecs
all invalidate instantly. A coarse world-tick recompute remains only as a
backstop against a missed signal.
|
||
|
|
c1cf437bf8 |
item: route all local player resolvers through Unit::Identity
Nine modules each rolled their own ResolvePlayer / PlayerInvMgr helper on the
throwing FUN_RESOLVE_UNIT_TOKEN("player"). Delete them all and route through
the canonical non-throwing Unit::Identity::PlayerObject(), plus a new
Unit::Identity::PlayerInventoryManager() (PlayerObject + inventory-manager
offset, mirroring the existing PlayerDescriptor accessor).
Verified equivalent by disassembly: FUN_RESOLVE_UNIT_TOKEN is TokenToGUID ->
FUN_OBJECT_RESOLVE_BY_GUID, the same object-manager lookup PlayerObject()
performs, differing only in a type-mask the player object passes either way.
Callers therefore get the identical CGPlayer (and inventory manager) but
non-throwing - null pre-world instead of a raised Lua error. That also makes
item/Location's equipment resolver safe to call outside a Lua callback (e.g.
the C_NewItems WorldTick bag scan), where the token resolver could have
raised.
Migrated: item/Count, item/AverageLevel, item/Swap, item/Location,
player/CanUseItem, spell/Cancel, equipmentset/Data, equipmentset/Locations,
merchant/Frame. debug/Probe keeps its own (deliberately standalone).
|
||
|
|
07a91feff0 |
item: add C_NewItems (new-item glow tracking)
Backport the modern C_NewItems system - IsNewItem / RemoveNewItem / ClearAll - flagging items freshly added to bags as "new", cleared once acknowledged. Vanilla has none of the machinery (no DBC, no server data), so it is pure client-side bookkeeping, done entirely in C++ like retail. Newness is keyed on each item's instance GUID (read off the CGItem), so a flag survives the item being moved between slots - impossible for a Lua addon, which can only track by (bag, slot). Bags 0..4 only; equipment and bank are out of scope, matching retail. The feed is event-driven, not polled: it subscribes to Bag::UpdateDelayed (which co-hooks the engine's three BAG_UPDATE fire sites), so a bag rescan runs only on frames where a bag actually changed. A one-time baseline taken ~1.5s after login (re-armed on character switch) keeps items owned at login from being flagged. BAG_NEW_ITEMS_UPDATED fires when the set changes. Consolidations along the way: - New Bag::UpdateDelayed::AutoSubscribe exposes the authoritative "a bag changed this frame" signal as a C++ subscription. - New Item::Location::ContainerInventory factors the CGContainer -> its inventory (vtable +0x10) dispatch hand-rolled in item/Count, item/AverageLevel, and equipmentset/Locations; all now share it. - New Item::Location::EquippedBagInventory (equipped bag -> inventory) plus the FUN_GET_EQUIPPED_BAG_GUID / OFF_CONTAINER_GET_INVENTORY offsets. - NewItems resolves the player via the shared Unit::Identity::PlayerObject. |
||
|
|
8bfe0b008c |
item: EquipItemByName auto-slot uses Item::Cursor::PickupBagItem
Replace the auto-slot path's Script_PickupContainerItem stack-fake (SetTop + PushNumber x2 + call) with the shared Item::Cursor::PickupBagItem, which drives the engine's cursor primitive directly -- the same one C_Item.PickupItem uses. The ClearCursor at the top still runs first, so PickupBagItem's empty-cursor guard is satisfied; bail if the pickup didn't take (locked item / busy cursor) rather than auto-equipping nothing. Drops the now-unused ScriptFn_t typedef. FUN_SCRIPT_PICKUP_CONTAINER_ITEM now has no callers -- the Script-pickup stack-fake is gone from the codebase. Explicit-dstSlot path (atomic FUN_INVENTORY_SWAP) is unchanged. Verified in-game (auto-slot equip by name and by id). |
||
|
|
e9c2e7416a |
item: add C_Item.PickupItem, via direct engine cursor primitives
C_Item.PickupItem(itemInfo) picks the matching item up onto the cursor.
itemInfo is an itemID / "item:NNN" / link / name (same input family as
UseItemByName / EquipItemByName): resolved via Item::Arg::Resolve and
found by Item::Location::FindByArg across equipment (1..19, checked first)
and bags (0..4) using the shared MatchesArg predicate (itemID, or the
decorated name for a name arg). An equipped match is lifted off the
paperdoll; a bag match off the container. Verified in-game (bag + equipped,
by id and by name).
Drives the engine's cursor-pickup primitives DIRECTLY rather than the Lua
Script_Pickup* state-machine wrappers (no faking the Lua stack), via a new
shared Item::Cursor:
- PickupEquipmentSlot -> FUN_004C7300 (self-contained; own guards)
- PickupBagItem -> FUN_00494B60, replicating the two guards the
Script wrapper applies (empty cursor + unlocked item) and the
post-pickup source lock. The empty-cursor check reuses a new shared
Cursor::Info::HasItem() (the same cursor-GUID globals GetCursorInfo
reads), rather than duplicating it.
Supporting consolidation in Item::Location:
- ResolveBagSlotDetail exposes the container object + linear slot the
cursor primitive needs; ResolveBagSlot now delegates to it.
- FindByArg (equipment-then-bags, MatchesArg) reuses FindByArgInBags for
the bag half; FindByItemID is now its itemID-only specialization.
C_EquipmentSet.UseEquipmentSet was considered but already uses the atomic
FUN_INVENTORY_SWAP (no cursor). EquipItemByName's auto-slot path still uses
the Script wrapper; migrating it to Item::Cursor::PickupBagItem is a
follow-up.
|
||
|
|
6641e5ac13 |
item: add C_Item.IsConsumableItem (+ global IsConsumableItem)
Returns true if an item is a consumable: item class Consumable (0), or inventory type INVTYPE_AMMO (24) / INVTYPE_THROWN (25). Registered as both the namespaced C_Item form and the bare global, like IsUsableItem. Definition established by decoding 3.3.5's Script_IsConsumableItem (0x005173E0) then verifying the surviving contract on a modern client: 3.3.5 walked the item's on-use spells and returned true for any with a real effect (which would include on-use trinkets), but that heuristic did NOT survive -- an on-use trinket with a numeric Use: effect (Talisman of Ephemeral Power) returns false on modern. It's a plain class/ammo check. Verified in-game on our client, matching modern exactly: potion / bandage / Faintly Glowing Skull (all class 0) and Rough Arrow (Ammo) -> true; Hearthstone, Talisman, plain armor -> false. itemID / "item:NNN" / link input (names -> false, no vanilla name->ID map); uncached -> false with no async load, same contract as C_Item.IsEquippableItem. Documented in API.md (+ TOC) and the README Item-row index. |
||
|
|
db1f00e0a3 |
item: add C_Item.IsItemInRange, via a shared Spell::Range core
C_Item.IsItemInRange(item, targetUnit) resolves the item to its on-use spell (Item::Spell::OnUseSpellIDForItemID) and runs the same geometric range test as C_Spell.IsSpellInRange: true / false in-or-out of range, nil when the check doesn't apply (no on-use spell, a rangeless one, or an unresolvable item/unit). Matches retail, which also returns nil for items with no range restriction. item accepts itemID / "item:NNN" / link (names aren't resolvable in vanilla -> nil). Range-only, ignoring LoS/faction, like IsSpellInRange. The range predicate SpellIDHasRange was about to become its fourth copy, so extract the shared core into Spell::Range (SpellIDHasRange + PlayerVsUnit, returning 1/0/-1). C_Spell.IsSpellInRange and C_Item.IsItemInRange are now thin Lua wrappers over PlayerVsUnit, and C_Spell.SpellHasRange / SpellHasRange call the shared SpellIDHasRange -- range logic single-sourced. |
||
|
|
2a218a0a76 |
item: match decorated (suffixed) name via shared MatchesArg predicate
IsEquippedItem(name) and the bag find-by-name (FindByArgInBags, behind
UseItemByName/EquipItemByName/UseAtCursor) compared the caller's string
against the base ItemStats m_name[0], so a random-suffix item ("Foo of
the Owl") only matched when queried by its base name ("Foo"). The modern
client does the opposite -- verified in-game on both the modern client
and ours:
IsEquippedItem("Iridium Chain") -> false
IsEquippedItem("Iridium Chain of the Owl") -> true
IsEquippedItem("iridium chain of the owl") -> true (case-insensitive)
IsEquippedItem(12022) -> true (itemID)
Match the decorated display name instead, via the engine name builder
(Item::Link::NameFromCGItem), which falls back to the base name for
unsuffixed items so plain items still match.
The match predicate was duplicated inline in both call sites -- which is
why this took two edits. Consolidate it into a single
Item::Location::MatchesArg(cgItem, resolvedArg): itemID-compare when
arg.itemID > 0, else case-insensitive decorated-name compare. Both
IsEquippedItem and FindByArgInBags now delegate to it, so the full chain
is single-sourced (Item::Arg parses input -> MatchesArg decides the match
-> NameFromCGItem / ID::FromCGItem supply the comparands). Also drop a
now-unused <string.h> from Equipment.cpp and fix the stale m_name[0] doc
on FindByArgInBags.
|
||
|
|
e8a9003bf0 |
item: dress GameTooltip:GetItem() name with random suffix
GameTooltip:GetItem() resolved the CGItem and built the suffixed link via
Item::Link::FromCGItem, but returned the base ItemStats name beside it --
so name and link disagreed ("Iridium Chain" vs "[Iridium Chain of the
Owl]"). The old comment claimed the engine didn't expose the dressed name
as a separate string; it does, via the same builder the link uses.
Extract that builder into a shared Item::Link::NameFromCGItem helper
(next to FromCGItem, wrapping FUN_ITEM_BUILD_INSTANCE_NAME) and use it in
both GetItem and C_Item.GetItemName so the returned name matches the link
and modern behavior. Verified in-game: GetItem() now returns "Iridium
Chain of the Owl" alongside its matching link.
Left the base-name reads that are correct as-is: itemID-only paths (mail,
cursor-by-id, GetItemInfo, equipment-set missing items) have no instance,
and the by-name *matching* in IsEquippedItem / bag lookups compares
against a caller string (a separate semantics question).
|
||
|
|
aa0279a600 |
item: decorate C_Item.GetItemName location form with random suffix
The location form of C_Item.GetItemName points at a real item instance,
so its name should carry random-suffix decoration ("... of the Owl") the
way modern WoW does -- but we were reading m_name[0] off the itemID-keyed
ItemStats_C cache, which only holds the base name.
Resolve the location to its CGItem and build the name via the engine's
own per-instance name builder (FUN_005D8BC0): it reads the suffix ID off
the descriptor (+0x98) and formats base + ItemRandomProperties localized
suffix through the engine's ITEM_SUFFIX_TEMPLATE. This is the same
builder FUN_GAMETOOLTIP_BUILD_ITEM_LINK wraps in brackets, so the output
now matches GetItemLink's bracketed name and modern C_Item.GetItemName
exactly (verified in-game: "Iridium Chain of the Owl"). Falls back to the
base ItemStats name (and warms the cache) when the instance build yields
nothing.
GetItemNameByID is unchanged -- an itemID has no instance, so base name
only is correct.
|
||
|
|
d55877649f |
item, unit: drop hand-rolled unit-token grammar mirrors
FUN_TOKEN_TO_GUID (0x00515970) is a pure parser: it returns 0 for any input it doesn't recognize and never raises -- verified from the disassembly (plain stack frame, no assert/SEH prologue; every unknown-input path is xor eax,eax; ret). Both call sites had mirrored the engine's token grammar by hand to pre-screen input, on the mistaken belief this function throws (it was conflated with its sibling FUN_RESOLVE_UNIT_TOKEN 0x00515940, which does throw). - item/Use.cpp UseItemByName: delete LooksLikeToken / MatchBase / SkipTargetSuffixes / HasPrefix; just call FUN_TOKEN_TO_GUID and let it return 0 for non-tokens. - unit/Flags.cpp UnitIsInMyGuild: delete LooksLikeKnownToken / HasPrefix / AllDigits. Resolve the input to a GUID via FUN_TOKEN_TO_GUID, then resolve GUID -> object via the non-throwing FUN_OBJECT_RESOLVE_BY_GUID (unit|player mask) for the fast guild-key compare, and GUID -> name via the NameCache for the roster fallback. This avoids the throwing resolver entirely, and -- because the token->GUID step goes through our TokenExtensions hook -- now supports focus / nameplateN, which the old grammar mirror silently treated as literal names. Matches what 3.3.5's Script_UnitIsInMyGuild does (resolve to a GUID first). No grammar to keep in sync with the engine anymore. Behavior otherwise unchanged (self, guildmate/other-guild target, NPC, OOR raid member, literal name, empty slot all verified case-by-case). |
||
|
|
f55779f87e |
item: fix UseItemByName ignoring the unit target for all but current target
UseItemByName resolved the unit token (arg 2) AFTER FindByArgInBags, which stomps the Lua stack (clears it and pushes bag-slot numbers for PackBagSlot). So ResolveUnitGuid read a leftover slot number instead of the token: IsString failed, the GUID came back 0, and the engine fell back to its default target. That default is the player's current target for a targeted-use item, so "target" appeared to work while "focus", "party1", "mouseover", etc. silently did nothing useful. Resolve the target GUID before the bag walk (as the sibling UseAtUnit already does). ResolveUnitGuid only reads slot 2 and resolves a C string -- no stack stomp -- and leaves arg.name (slot 1) intact for FindByArgInBags; the GUID is a plain value by the time the stack is blown away. |
||
|
|
88d76c04ad |
item: add IsUsableItem / C_Item.IsUsableItem (on-use usability)
Item analog of IsUsableSpell, returning (usable, noMana) for an item's on-use ability -- not equippability. Gates on the item having an ON_USE spell, its use requirements (RequiredLevel, AllowableClass/Race), then the on-use spell's castability via the engine helper FUN_SPELL_IS_USABLE (0x006E3D60), which sets noMana on power shortfall. Shares the on-use spell-slot walk with C_Item.GetItemSpell: promoted Item::Spell::FindOnUseSpellIDInRecord to the header so both use it instead of re-deriving the trigger scan. |
||
|
|
63c003db26 |
Add GameTooltip:IsEquippedItem; share tooltip-item resolver; fix GetItem for CGItem/auction tooltips
Introduce Item::TooltipItem::CurrentID -- the single "what item is this tooltip showing" resolver. It trusts the link-path itemID (+0x398), and otherwise resolves the CGItem GUID (+0x380) but only when no unit / gameobject / spell id is set, since the clear does not zero the item GUID and it goes stale after the tooltip moves on. - GameTooltip:GetItem / HasItem now route through CurrentID: fixes GetItem returning nil for CGItem tooltips (bag / equipped / merchant / loot) and HasItem false-positiving on a unit tooltip after an item hover. - Add GameTooltip:IsEquippedItem() (3.3.5 backport, registry index 63), resolving the displayed item via CurrentID + the equipment-slot walk. - SetHyperlinkCompareItem: the comparisonTooltip (4th arg) fallback uses CurrentID; stat deltas now show by default and hide only for an explicit false / 0 (was: show only for a truthy shift). - GetItem round-trips the random-suffix id in the link for auction/compare items (no CGItem instance) via the compare descriptor. - FrameXML GameTooltip_ShowCompareItem falls back to self.compareLink, so a caller can hand it an explicit link when the tooltip's item state was rebuilt out from under it (e.g. an AH addon appending source lines). - Offsets: compare-descriptor + FontString offsets; drop the duplicate tooltip item-id/guid offsets in favor of the canonical OFF_TOOLTIP_*. |
||
|
|
d01e51d862 |
Add GameTooltip:SetHyperlinkCompareItem (item comparison tooltips)
Backports the 3.3.5+ shopping-tooltip method, fully native (no lua_pcall): fills a tooltip with the item currently equipped in the given item's slot — a grey "Currently Equipped" header, the equipped item's tooltip, then a green/red per-stat delta breakdown gated on shiftButton. - Extract the stat engine (base record + on-equip-spell auras + random suffix) out of item/Stats.cpp into the shared Item::StatAccum, reused by C_Item.GetItemStats/GetItemStatDelta and the compare deltas. - Build via the engine's own item-tooltip builder; prepend the grey header by shifting the line FontStrings, replicating the show/hide protocol, keying on the visible flag (no stale text) and resetting cell color. - Delta colors sourced from ColorData.h via a new constexpr ByTag helper. - offset selects the slot for two-slot items (rings/trinkets/1H weapons); shiftButton gates the deltas (true/1 vs false/0/nil); a comparisonTooltip 4th arg lets it run link-free, 1:1 with the retail call. - FrameXML GameTooltip_ShowCompareItem consumer with a dynamic, backdrop-derived anchor gap. |
||
|
|
2968f51661 |
GetItemStats: cover Turtle equip-spell stats; exact effect value
Cross-checked against Turtle's server source (patch_1172): ItemModType is unchanged vanilla (0-7) and ApplyItemEquipSpell applies only ON_EQUIP, confirming special stats are all equip-spell auras. - Value now uses the engine's CalculateSimpleValue = EffectBasePoints + EffectBaseDice (new OFF_SPELL_RECORD_EFFECT_BASE_DICE = 0x10C) instead of a hardcoded +1; equal for the fixed-die stat auras but exact. - Decode the additional stat auras Turtle puts on custom gear: dodge % (49), parry % (47), block chance % (51), spell crit % (57/71), and flat health (34) / mana (35) folded into the existing keys. Adds shield block value from the record's m_block. New keys ITEM_MOD_DODGE_RATING, ITEM_MOD_PARRY_RATING, ITEM_MOD_BLOCK_RATING, ITEM_MOD_CRIT_SPELL_RATING, ITEM_MOD_BLOCK_VALUE (percent stats keep vanilla-native values). Documents the expanded key set in docs/API.md. |
||
|
|
dbd3f7f6a5 |
GetItemStats: add weapon DPS and equip-spell stats
Weapon DPS (avg damage across the slots / swing time) is emitted under ITEM_MOD_DAMAGE_PER_SECOND_SHORT, matching 3.3.5's GetItemStats. Vanilla stores the "special" gear stats (crit, attack power, spell power/healing, hit, mp5, defense) as on-equip spells rather than stat slots, so decode each item's SpellTrigger == ON_EQUIP spells - and the random-suffix equip enchants - through the SPELL_AURA_* effects and fold them into the modern GetItemStats keys. Percent stats (crit/hit/defense) are reported as the raw vanilla percentage under the *_RATING key, since vanilla has no (level-dependent) rating conversion; e.g. Krol Blade's +1% crit is CRIT_MELEE_RATING = 1, not the 13 rating TBC/Era would show. Generic attack power subsumes its paired ranged-AP aura; rarer auras with no clean key (percent AP, per-weapon-line skill, procs) are skipped. Documents the full key set and its sources in docs/API.md. |
||
|
|
2f5cec35ea |
Add C_Item.GetItemStats / GetItemStatDelta
Read an item's stats out of the cached ItemStats_C record and return them keyed by the FrameXML global-string names WoW's GetItemStats uses (ITEM_MOD_*_SHORT, RESISTANCE0..6_NAME). GetItemStatDelta returns the per-stat difference (item2 - item1). Random suffixes are resolved from the link's third item:id:enchant:SUFFIX:unique field through ItemRandomProperties.dbc -> SpellItemEnchantment.dbc: type-3 (equip-spell) enchants defer to the spell's SPELL_AURA_MOD_STAT / MOD_RESISTANCE effect (value = EffectBasePoints + 1), type-4 add a direct resistance. Reported set stays consistent with the base record - base attributes, armor, and the six resistance schools - so a plain item and its suffixed variant report the same categories. Adds OFF_SPELL_RECORD_EFFECT_BASE_POINTS, VAR_ITEMRANDOMPROP_RECORDS/ COUNT, and OFF_ITEMRANDOMPROP_ENCHANT to Offsets.h. |
||
|
|
644aa21459 |
Add C_Item.IsItemGUIDInInventory
Returns whether an item with the given "0x..." GUID is currently carried
by the player. Parses the GUID, then scans the 19 equipment slots plus
bags 0..4, comparing each item's instance GUID (+0x08 -> +0x00, the same
read GetItemGUID uses). Reuses the existing ResolveEquipmentSlot /
ResolveBag / GetBagSlotCount iteration.
Scope matches retail: equipment slots count (verified in-game —
IsItemGUIDInInventory(GetItemGUID({equipmentSlotIndex=1})) is true), bags
count, bank does not (GetItemCount(itemID, true) covers the bank). Returns
false for a malformed / zero GUID.
Factored the CGItem GUID read into a shared ReadItemGuid helper (also used
by GetItemGUID). Documented in docs/API.md and the README Item row.
|
||
|
|
a77d8f3fac |
Add Enum.InventoryType
Registers Enum.InventoryType (equip-type enum) as a hardcoded mirror of Blizzard's 0..34 spec, via the same RegisterIntegerEnum path as Enum.PowerType / Enum.AddOnSecurityStatus. Values 0..28 are the ones vanilla items report; 29..34 (profession / equippable-spell types) are post-vanilla, included so backport code referencing those keys resolves. The field names (IndexHeadType, Index2HweaponType, …) aren't present in engine data and don't derive cleanly from the INVTYPE key strings, so a static mirror is the correct approach — it's a fixed API contract, not engine-driven. For the live set of slot keys the engine actually has, use C_Item.GetItemInventorySlotKey. Documented in docs/API.md and the README enum row. |
||
|
|
766d128a5d |
Add C_Item.GetItemSubClassInfo / GetItemInventorySlot{Info,Key}
Three item-taxonomy lookups backported to the C_Item namespace, reusing
the ItemSubClass.dbc scan and INVTYPE key table already in the tree.
- GetItemSubClassInfo(classID, subClassID) -> subClassName,
subClassUsesInvType. Name is the localized ItemSubClass.dbc verbose
form (short-name fallback). subClassUsesInvType comes from the flags
field at record +0x10, bit 0x200 — set on exactly the armor material
types (Misc/Cloth/Leather/Mail/Plate), clear on weapons/shields/etc.
Bit derived by dumping ItemSubClass.dbc and verified against the 1.15
client (Cloth true, One-Handed Swords false, Shields false).
- GetItemInventorySlotKey(inventorySlot) -> the equipLoc key
("INVTYPE_HEAD"), straight from the engine's INVTYPE table.
- GetItemInventorySlotInfo(inventorySlot) -> the localized slot name
("Head"), resolved via the FrameXML global of that key so it's
localized on non-English clients.
All three return nil for out-of-range / missing input. Documented in
docs/API.md and the README Item row.
|
||
|
|
d9102bae3b |
Relicense source headers from LGPL to GPL v3
The repo was internally inconsistent: the LICENSE file is GPL v3 but every src/ header carried the LGPL v3 notice and the README said "LGPL v3 or later". LGPL was also the wrong fit — this is an injected mod plus a bundled addon, not a library other code links against, so LGPL's linking exception buys nothing. It's also required: src/voicechat/Tts.cpp is ported from awesome_wotlk's VoiceChat.cpp, which is GPL v3, and a derivative of GPL code cannot be relicensed under more permissive terms. Dependencies stay compatible — MinHook (BSD-2) and the nampower-mirrored packet shapes (BSD) are GPL-compatible, and SAPI is covered by the system-library exception. Swept "GNU Lesser General Public License" -> "GNU General Public License" across all 257 src/ headers and changed the README license line to match the GPL v3 LICENSE file. Comment-only; no build impact. |
||
|
|
17f44f93f8 |
Add C_Item.GetEnchantInfo(enchantID)
Resolves an item-enchantment ID (the enchantID from
C_Item.GetWeaponEnchantInfo, and item permanent-enchant IDs) into its
SpellItemEnchantment.dbc record:
{ enchantID, name, effects = {{type,amount,arg},...}, spellID }
- name: localized display name ("Crusader", "Brilliant Mana Oil").
- effects: each active slot's ITEM_ENCHANTMENT_TYPE / amount / arg.
- spellID: convenience for spell-type enchants (1/3/7) — the proc/
equip/use spellID, e.g. Crusader -> 20007 "Holy Strength", to chain
into C_Spell.GetSpellDescription.
Record layout verified by parsing the on-disk DBC against known
records (Crusader 1900: type 1, arg 20007; Sharpened+3 id 13: type 2,
amount 3; Reinforced Armor+8 id 15: type 4, amount 8): Type[3]@+0x04,
Amount[3]@+0x10, EffectArg[3]@+0x28, Name[8]@+0x34. The engine's
by-ID readers only touch name/flags/condition, so the effect columns
couldn't be pinned from disassembly — the extracted dbc/ dump was the
oracle. Verified in-game across all three example enchants.
Placed in C_Item (not C_Spell): the id originates from
C_Item.GetWeaponEnchantInfo and the concept is an item enchantment.
Source-item is not derivable (no back-reference, no client reverse
index).
|