mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
efcdc54a50e22a3181ded47a992401d46f819d45
781
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
efcdc54a50 |
feat(baselib): string.gsub takes 5.1 string and table replacements
1.12.1's str_gsub (0x7FD0E0) is Lua 5.0's. Its replacement argument
differs from 5.1 in four ways: a table is rejected ("string or function
expected"); in a replacement string, %0, and %1 when the pattern has no
captures, raise "invalid capture index" (add_s checks every %n with
check_capture, 0x7FCE20); a function that returns nil or false deletes
the match instead of keeping it; and one that returns a table deletes
it too instead of raising an error.
The first two only ever raised errors, so the 5.1 behavior cannot break
an existing addon. The function rules can: SuperAPI's
CombatText_AddMessage returns nil to delete the player's own " [0x...]"
GUID from heal text. So function replacements keep 1.12.1's behavior,
and only string and table replacements change. A scan of every gsub
call in the installed addons and the stock FrameXML found no other code
that depends on the old string or function results.
str_gsub's match loop, anchor, count and buffer stay the engine's. Two
parts are replaced:
- The 60-byte replacement-type gate at 0x7FD15E (lua_gettop / isstring /
lua_type == function, then luaL_argerror) becomes a call to a
__fastcall check with ECX = L that accepts a number, string, function
or table and raises "string/function/table expected" otherwise.
- The one call to add_s (0x7FD203 -> 0x7FD2A0, __fastcall ms/b + s/e on
the stack, ret 8) goes to a function with the same signature. A
function replacement calls the engine's add_s unchanged. A string or
number gets 5.1's add_s, and a table gets 5.1's lookup: the first
capture or whole match as the key, a nil or false value keeps the
match, and any other non-string value raises "invalid replacement
value". Both use the engine's push_onecapture (0x7FCF40, plus 5.1's
whole-match case for index 0 with no captures), luaL_addlstring
(0x6F51F0) and luaL_addvalue (0x6F5270).
Both patches check the original bytes or call target and are skipped
when they differ.
The table-replacement shim in StringLib is removed. It wrapped the
pattern in an outer capture so a closure could return the whole match,
and deleted the match for a missing key when the pattern had a
back-reference. string.gsub and gsub are the engine's function again.
|
||
|
|
a7ce7555f0 |
fix(softinteract): anyinteract yields when the target is out of reach (#121)
* fix(softinteract): anyinteract yields when the target is out of reach
GetAny treated Reach::Out — the cursor's Unable form — as a usable
target, so with a target too far away the Interact Key pressed the inert
target instead of the nearest object it could interact with.
Prefer the target only while the cursor says it can be used now
(Reach::Now), and fall back to softinteract otherwise. A target behind
the camera still wins while it is in reach: the cursor verdict does not
look at facing.
* docs(api): anyinteract needs the target to be in reach now
The token section said a target that is too far away still counts, which
the implementation no longer does.
* fix(softinteract): anyinteract keeps an out-of-reach target when nothing is picked
Retail 12.1.5, targeting an NPC that is out of reach: facing away from
everything (softinteract nil), anyinteract is the target; facing a nearer
NPC, it is that NPC. The previous change returned 0 in the first case,
so the Interact Key lost the engine's own out-of-reach handling on the
target (the "need to be closer" error, or the click-to-move walk).
GetAny now reads the target's cursor verdict once: in reach wins, then
softinteract, then the target while it is interactable but out of reach.
* feat(interact): honor looseTargeting in C_PlayerInteractionManager.InteractUnit
On retail the Interact Key on a nearer NPC opens its dialog while a
farther unit stays targeted; with no target it targets the NPC. The key
calls InteractUnit("anyinteract") with looseTargeting at its default,
true, which ClassicAPI ignored, so the right-click's select replaced the
target.
FUN_ON_SPRITE_RIGHT_CLICK (0x00492820) is the active-player gate, the
select (FUN_SET_SELECTION_BY_GUID, 0x00493540), then the object's
right-click virtual (vtable +0x60, call at 0x00492881) with
FUN_GAMEUI_IS_KEY_DOWN(0). The select stores only units, so only a unit
other than the current target would move it. With looseTargeting and a
target, that one case runs the gate and the virtual without the select;
every other case still calls the engine function, which nampower also
detours for its right-click guards. The global InteractUnit keeps
targeting.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
65c6b0b271 |
feat(action): spell search, slot item and #showtooltip action queries
C_ActionBar.FindSpellActionButtons, HasSpellActionButtons and IsOnBarOrSpecialBar find a spell on the bars. A slot matches on the spell ID stored in VAR_ACTION_TABLE under the spell tag, the same test 4.3.4's PutActionInSlot makes, so a macro or item that casts the spell does not count and a rank matches only itself. A name resolves through the engine's spellbook resolver. IsOnBarOrSpecialBar also reads the shapeshift bar's spell array (pointer at 0x00B71108, count at 0x00B71104, as Script_GetShapeshiftFormInfo 0x004B45C0 reads them) and the pet bar's spell entries (types 1-5, spell ID in the low 16 bits, as Script_GetPetActionInfo 0x004BDC50 reads them, gated on the pet GUID). Enum.ActionBarSet is registered; all 120 slots are its Mkb set. IsStackableAction (global, 1/nil) and C_ActionBar.IsStackableAction (bool) answer 4.3.4's IsStackableAucItem: the slot's item has a max stack above 1. C_ActionBar.GetItemActionOnEquipSpellID returns the item's first spell with trigger 1 (on equip). The item is the item-by-ID action's, or the one a macro's #showtooltip / #show resolved to, as 4.3.4's CGActionBar::GetItem returns it. Both peek the item cache and never query it. C_ActionBar.IsMacroActionWithShowTooltip parses the macro's body with the parse Macro::ShowTooltip hands the tooltip over on, so it answers while that module yields or a publisher owns the macro. |
||
|
|
5f94fb98bd |
feat(action): C_ActionBar.GetSpell
C_ActionBar.GetSpell(actionID) returns the spell an action-bar slot casts, or 0. It is the engine's own slot resolver (0x004E5A50), which the cooldown, usable and range readers already go through: a spell action is its spell, a macro is its cached primary spell (+0x564, the one #showtooltip sets), and an item-by-ID action is the first on-use spell in its item cache record. An empty slot, a slot outside 1..120, an equipment set or a macro whose macro is gone gives 0. The spellbook flag the resolver also hands back is not part of the answer. |
||
|
|
426f6b6ec9 |
fix(container): free slots count the bank and use the engine's counter
GetContainerNumFreeSlots and GetContainerFreeSlots now take the main bank (-1) and the bank bags (5..10) while a banker is open. The main bank is gated on the banker GUID (0x00BDD038); bank bags get the gate from the engine's container-GUID getter (0x004F93E0), which answers 0 for them while the bank is closed. A bag's empty slots are counted by the engine's own CountFreeSlots (0x00622910, __thiscall on the bag's inventory list), and its slot count comes from that live list instead of the item record. The backpack and main bank are ranges of the player's list, walked slot by slot. Nothing walks PackBagSlot per slot any more, so the Lua stack is left alone. A container that is not there (keyring, empty bag slot, closed bank) now returns only 0, leaving bagFamily nil. The bag view SortBags kept for itself moves to Container::Bag so both modules share it, and Item::Location::EquippedBagInventory becomes BagInventory (1..10) beside a new BagContainer. C_Item.GetItemData's bagFamily now goes through BitmaskForRecord, so a bag whose family field is empty reports the same family there as it does from GetItemFamily (a Soul Pouch was 0 there, 0x4 here). |
||
|
|
72f0e5d98f | docs(action): range and usable events move to the Events section | ||
|
|
ceb6aaf46b |
feat(action): action range and usable events
ACTION_RANGE_CHECK_UPDATE(slot, isInRange, checksRange) and
C_ActionBar.EnableActionRangeCheck(slot, enable). Enabled slots are
checked on each world tick while a frame is registered for the event,
with IsActionInRange's own answer (Action::Range::Answer, the macro
unit redirect included), and fire on change. Enabling is counted per
slot, and each enable makes the slot's next check fire, because retail
buttons take their first state from the event. A new Lua state starts
with no slot enabled.
ACTION_USABLE_CHANGED(changes) carries { slot, usable, noMana } for
each slot that changed. The engine's bulk refresh 0x004E5C00 already
compares each slot's pair against the caches IsUsableAction reads
(0x00BC6B60 / 0x00BC67A0). Its per-slot call at 0x004E5C15 is
redirected to record the slots whose pair differs, and its
ACTIONBAR_UPDATE_USABLE signal at 0x004E5C53 to send that event
unchanged and then the new one. No hook.
|
||
|
|
3849b7513b |
feat(statusbar): the standard fill moves the bar texture's rect
1.12's CSimpleStatusBar::OnFrameUpdate (0x007833C0) draws the fill by cropping. InstallBarTexture (0x007831F0) sets the texture's SetTexCoordModifiesRect flag (+0x124), and the update writes the filled part into the coordinates. The crop shrinks the drawn quad but leaves the texture's rect at the full bar, so a region anchored to GetStatusBarTexture() stays on the bar's far edge. Reverse, center, rotated and tiled bars already moved the texture's points. The OnFrameUpdate hook now replaces the engine's update for every bar. It runs the base frame update (0x0076B2C0), clears the crop flag, and moves the texture's four points in from the bar's edges with CLayoutFrame SetPoint and doResize, as 4.3.4's OnLayerUpdate does. The fraction comes from the bar's fill-fraction virtual (+0x98), so SetValue, the ease and SetTimerDuration all move the rect. doResize queues the texture for the layout pass before the draw, so anchored regions follow in the same frame. An empty fill keeps a zero-width rect on the start edge (CalculateRect 0x767A20 has no size test), so its anchors still resolve. The crop path and the code that handed a bar back to it are removed. A standard vertical bar now shows the bottom part of its image. |
||
|
|
48822978c6 |
feat(statusbar): ExponentialEaseOut interpolation
bar:SetValue(value, interpolation) and SetMinMaxValues(min, max, interpolation) take Enum.StatusBarInterpolation. With ExponentialEaseOut the fill eases from what it showed to the new value; GetInterpolatedValue, IsInterpolating and SetToTargetValue read and end the ease, and SetTimerDuration's interpolation argument now chases the timer the same way. The curve was measured in a retail 12.1.5 client at 77 and 30 frames per second and fits to under 1%: each frame closes the gap in the fill FRACTION by exp(-18 * elapsed), whatever the range, and the frame whose gap before its step is under 0.001 snaps to the target. The same probe on 1.12 matches: k = 18.0, a full-bar ease done in 0.38 s against retail's 0.39. SetValue stores the target at once (GetValue returns it, OnValueChanged runs once, with it); a new eased value goes on from the shown fill, and an Immediate one, or SetToTargetValue, snaps. SetMinMaxValues with the ease keeps the fraction shown and eases to the new one. A hidden bar does not ease. Only a target that held still since the last frame may snap: an eased timer starts at a near-zero gap, and retail chases it until the timer ends. The ease lives where the timer does, so StatusBar::Timer becomes StatusBar::Display: one state per bar holding the timer, the ease and the fraction drawn. The co-hook on the bar's GetFillFraction virtual (0x783380) answers that fraction, so the ease keeps 1.12's texture crop and StatusBar::Fill's styles. Advance runs at the head of CSimpleStatusBar::OnFrameUpdate (0x7833C0) for shown bars and now takes the pass's elapsed, which is the step retail takes. SetValue and SetMinMaxValues stay the engine's Lua methods (0x78F690, 0x78F4B0, read from the method table at 0x87B010), registered over by wrappers that read the interpolation argument and the fraction shown, call the engine method for its checks, errors and setter, then start or stop the ease. Both engine methods read no argument past their own. |
||
|
|
f8a796ae04 |
feat(duration): duration text bindings, Format methods, GetTotemDuration
A font string can now count down by itself. A binding from
C_DurationUtil.CreateDurationTextBinding() takes a font string
(SetFontString), a duration object (SetDuration) and a format: either
SetFormatter(formatter), which writes a NumericRuleFormatter's text for
the remaining seconds, or SetTextFormat(formatString, components), where
each "{}" takes one component's property (Enum.DurationTextBindingProperty)
through its own formatter. SetExpiredText and SetZeroDurationText give
fixed texts, SetUpdateInterval spaces the updates out, and SetEnabled /
Enable / Disable start and stop it. The getters, Copy, Assign,
SetToDefaults, UpdateFontString, GetFormattedText and the Can* checks
are there too; the color curves are not. Duration objects gain
FormatElapsedDuration, FormatRemainingDuration and FormatTotalDuration
on the same formatter. Each answer was probed in a retail 12.1.5 client,
and the same probe matches on 1.12.
A binding is a userdata over a reference-counted native object, like the
duration object and the formatter, and it keeps both of those by
reference, so a change to the duration shows at the next frame. An
enabled binding takes a reference of its own, because it must go on
updating with no Lua object left; a Game::ReloadAutoRegister disables
every binding before the Lua state goes. The text is set through
CSimpleFontString::SetText (0x771D80), only when it differs from the
font string's own text buffer (+0xF0).
The updates run at the head of the UI render root (0x764330), before
the frame pass runs any OnUpdate or draws: Tick::FrameTick gains
AutoSubscribeBefore for this. At the tail, where FrameTick and
WorldTick subscribers run, the text would draw a frame after a timer
bar's fill, which the same pass computes; the probe caught that as a
"3.0" where retail showed "2.9". Nothing is mid-draw at the head, so the
formatter's call into str_format is safe there.
A binding keeps a font string pointer, and 1.12 hands a destroyed font
string's block back to the region pool, where it can come back as
another font string. The new FontString::Destruction co-hooks
CSimpleFontString::~CSimpleFontString (0x770E50, decompiled; its
deleting destructor 0x770E20 calls it, then frees the block) and runs
its listeners first, like Frame::Destruction does for frames. The
binding drops the pointer there and writes nothing after.
GetTotemDuration(slot) now returns a duration object, as retail's does:
the totem's span from its spawn stamp to its expiry, in exact
GetTime() seconds rather than GetTotemInfo's whole seconds, or a zero
span for an empty slot, since retail's return is never nil. Each call
returns a new object.
|
||
|
|
aff52e0ef6 |
feat(statusbar): timer bars, duration objects and Unit*Duration
A status bar can now fill by itself from a duration, with no Lua on each frame. bar:SetTimerDuration(duration [, interpolation [, direction]]) takes a duration object from C_DurationUtil.CreateDuration(), and Enum.StatusBarTimerDirection picks ElapsedTime (fills) or RemainingTime (empties). GetTimerDuration() returns it. UnitCastingDuration(unit) and UnitChannelDuration(unit) return the time span of a unit's cast or channel as a duration object. The duration object is a userdata like the NumericRuleFormatter: a pointer to a reference-counted span (start, total, mod rate) that every Lua object and every bar holding it own a reference to. Times are GetTime() seconds read through Time::Clock::NowSeconds, so they agree with GetTime() exactly. Its methods set the span from a start, an end or both, and read the start, end, total, elapsed and remaining time, the two percents and the started / expired / active state, in real or base time (Enum.DurationTimeModifier). The answers were probed in a retail 12.1.5 client and the same probe matches on 1.12. 1.12 already draws a bar's fill from a virtual, not from its stored value: CSimpleStatusBar::OnFrameUpdate (0x7833C0) crops the bar texture to the fraction its vtable slot +0x98 returns (0x783380, (value - min) / (max - min), or 0 for an empty range; disassembled). The timer co-hooks that function, so a timed bar keeps 1.12's texture crop. StatusBar::Fill's reversed, centered, turned and tiled layouts now take their fraction from the same virtual, so they follow a timer too. Fill's OnFrameUpdate co-hook calls Timer::Advance first, which marks the fill changed when the share moved and caches the share it drew. Shown bars update on every frame; hidden bars do nothing and are right on their first frame shown. As in retail, the timer stores 0 for the value and the range (written directly, so no OnValueChanged runs), SetValue leaves it running, and SetMinMaxValues ends it: Frame::MinMaxChanged's co-hook on the range setter (0x783270) clears the timer first. The bar keeps the duration object, not a copy, so a change to the object shows on the next frame. ExponentialEaseOut is accepted and draws as Immediate for now. UnitCastingDuration and UnitChannelDuration share one per-unit lookup with C_Spell.UnitCastingInfo / UnitChannelInfo, so they take the same unit tokens and have the same limits. Each call returns a new snapshot; it does not follow pushback or the end of the cast. |
||
|
|
2396d44f10 |
fix(frame): GetWidth / GetHeight / GetSize keep 1.12's scaled size
For a region with no set size, 1.12's Script_GetWidth (0x007A1E00) and
Script_GetHeight (0x007A2030) return the rect span without dividing by
the region's layout scale. The value is the size times the effective
scale: a 160-high track at a UI scale of 0.91 answers 145.6.
|
||
|
|
932e6ed82f |
feat(texture): wrap modes and tiling
texture:SetTexture(file, wrapModeHorizontal, wrapModeVertical), the XML hWrapMode / vWrapMode attributes, texture:SetHorizTile / GetHorizTile / SetVertTile / GetVertTile and the XML horizTile / vertTile attributes. Wrap. 1.12 fixes a texture's wrap when its file loads. CSimpleTexture::SetTexture (0x00770200) builds the flags word with CGxTexFlags (0x0058A980) from one wrap argument for both axes, and TextureCreate (0x00449D90) caches the handle under the name and that word, so a repeating copy of a file is its own shared texture. The device reads one bit per axis (3 for U, 4 for V), repeat or clamp, so the mirror and border modes clamp. A texture with a mode or a tile flag loads through a co-hook on that SetTexture: the same body, with a repeat per axis. The engine's same-file early-out (0x0044AC70) ignores flags, so the co-hook also compares the held image's wrap (its device texture's flags at +0x3C, or a loading BLP handle's at +0x150), and for the same file it swaps in the other copy and keeps the pixel shader. Changing a mode or a tile flag reloads the held file the same way. The Lua method is registered again so it stores the wrap arguments before the engine handler (0x0079BB40) runs: true or "REPEAT" repeats, anything else clamps. Tiling. A tiled axis repeats, and each non-zero coordinate on it becomes the texture's length in script units over the image's size in texels. The script units are the engine's own coordinate push: DivideByScreenScaleX (0x0041AE40) of aspect (0x0041AD70) x 1024 x length, over the effective scale. The texels are the device texture's width and height (+0x24 / +0x28): the file's size, halved only past the GPU limit and untouched by BaseMip. The layer batch keeps a pointer to the eight coordinates (0x00772FD0), so the count is written whenever an input changes: after each corner store, after both native SetTexCoord forms (0x00770410, 0x007704C0), on a tile change, and after CSimpleTexture::Emit (0x007706E0), whose device lookup loads the image. A tile change counts against the held image before the repeating copy of the same file replaces it, since the copy has no size until it is drawn. A texture showing an atlas does not tile (the atlases are parts of their files), and neither does one with SetTexCoordModifiesRect on. SetAtlas clears modes and tiling. A tiled status bar texture takes StatusBar::Fill's anchored layout instead of 1.12's crop, which would size it by the count, and its fill sets no coordinates. An XML <TexCoords> that moves a tiled axis off 0..1 logs "Invalid TexCoords value (horizTile is on)" at error level (new Xml::Error) and falls back to the whole image. Also corrects the AtlasData.h note on the atlas tile flags: 4 is horizontal and 2 is vertical. |
||
|
|
eb0b70bc5e |
feat(xml): rotation, degrees, registerForDrag and group parentArray
Four more later-client XML attributes, each applied only when present and non-empty, after the engine has loaded the node. - Texture `rotation` (degrees) and FontString `degrees` / `radians` (`radians` wins when both are given), parsed with SStrToFloat (FUN_SSTR_TO_FLOAT): Texture::Transform's rotation about the default pivot. The bodies of texture:SetRotation and fontstring:SetRotation move into SetTextureRotation / SetFontStringRotation, which the Lua methods and the Xml::TypeLoad subscribers both call. - Frame `registerForDrag`: the names, split on spaces and commas with Storm's tokenizer (FUN_STORM_STR_TOKENIZE) as registerForClicks is, passed to Frame:RegisterForDrag itself (FUN_SCRIPT_FRAME_REGISTERFORDRAG 0x00776D60) as its own Lua call. That function ORs LeftButton 1, MiddleButton 2 and RightButton 4 and stores the mask at frame+0xFC; there is no setter to call instead. - AnimationGroup `parentArray`: the group is appended to region[key]. The append moves out of Xml::ParentKey into Xml::AppendToArray, which frames, regions and groups now share. Tested in game with an XML test addon: rotation="90" and degrees="90" read back as pi/2, two groups land in parentArray in load order, and a frame with registerForDrag="LeftButton" drags. |
||
|
|
238e35ae53 |
feat(animation): from/to alpha, setToFinalAlpha, target keys, scale from/to
Later clients' animation attributes and the methods behind them, on the animation port's own objects. Alpha fromAlpha / toAlpha (SetFromAlpha / SetToAlpha / GetFromAlpha / GetToAlpha): an absolute alpha. Each update the target's alpha becomes from + (to - from) x progress, through Region::SetAnimAlpha, which takes AddAnimAlpha's target rule but sets instead of adding: a frame's own alpha through its vtable setter, a texture's or font string's vertex alpha through FUN_REGION_GET_COLOR / FUN_FONTSTRING_SET_COLOR. Earlier orders apply at full progress before the current order updates, so the last write wins. Setting either end turns the mode on, an unset end is 0, and SetChange returns to the relative change. Absolute values and the 0 default follow Blizzard's own code: it starts fades with SetFromAlpha(region:GetAlpha()) and fades in with toAlpha="1" alone. AnimationGroup setToFinalAlpha (SetToFinalAlpha / IsSetToFinalAlpha): when the group finishes (Finish included), Region::KeepAnimAlpha makes the alpha each alpha animation's target ended on the stored alpha, so the end restores that. Stop restores the stored alpha as before. targetKey / childKey (SetTargetKey / SetChildKey), with SetTarget, SetTargetName, SetTargetParent and GetTarget: a key path from the animation, where $parent steps to the group, then its region, then that region's parent; childKey "X" is "$parent.$parent.X". The steps among the animation objects are taken by Region::FindRegionByKey, and the rest goes to the relativeKey resolver in Xml::Anchors, now public with a switch for its leading-global rule. A name or key is looked up again on Play, as 4.3.4 looks up `target`; the setters also look it up at once and return whether they found a region. GetTarget returns the group's region when there is no target. Scale fromScaleX / fromScaleY / toScaleX / toScaleY (SetScaleFrom / SetScaleTo / GetScaleFrom / GetScaleTo): the scale goes from `from` to `to`, passed to AddAnimScale as 1 - scale. SetScale sets the end, so 4.3.4's scale is the case from = 1 and its results do not change. Tested in game with an XML test addon: childKey and targetKey resolve, the absolute alpha and the last-write-wins rule give each order's end value, setToFinalAlpha keeps 0.5 after the group finishes, a group without it restores alpha 1, and the from/to scale values load. |
||
|
|
5b7fe94d4d |
feat(xml): alpha, scale, desaturated, indented and other XML attributes
Later clients read these attributes in their XML loaders; 1.12's do not. Each is now read after the engine has loaded the node (Xml::FrameLoad for frames, Xml::TypeLoad for the rest) and goes through the setter the matching Lua method uses. Each applies only when present and non-empty, so an element's own value overrides its template's. Frames: - scale: Frame:SetScale's path (0x00775140). A negative scale is refused, anything else goes to SetFrameScale (FUN_FRAME_SET_SCALE 0x0076AC10, __thiscall(frame, float, force), ret 8) without force. A Model keeps `scale` as its model scale, which its own loader reads. - dontSavePosition, propagateKeyboardInput: the existing frame flags, through FUN_FRAME_SET_FRAME_FLAG. Textures and font strings: - alpha: parsed as the frame loader parses its own `alpha` (SStrToFloat, clamped to 0..1, truncated to a byte), then set as Texture:SetAlpha and FontString:SetAlpha set it (0x0079B580, 0x0079CB70): the region color from FUN_REGION_GET_COLOR with its alpha byte replaced, through FUN_FONTSTRING_SET_COLOR. It applies after the node's <Color>. - desaturated (textures): Texture::Desaturation's full amount, the same as SetDesaturated. It applies whenever present; an empty value is false. - indented (font strings): the style bit SetIndentedWordWrap sets. Status bars: - reverseFill, rotatesTexture, fillStyle: StatusBar::Fill's modes, read after the status bar loader has set the BarTexture. An unknown fillStyle name changes nothing. Tested in game with an XML test addon: every attribute set its value, and parentKey, wordwrap and countInvisibleLetters still load. |
||
|
|
2eef939b5a |
feat(xml): registerForClicks and wordwrap attributes
1.12's loaders read neither attribute: the Button loader (0x007788C0) has no registerForClicks, and the font string loader (0x00770F40) reads nonspacewrap but not wordwrap. Both were silently ignored, so ported templates got the default click mask and wrapping text. Both are read in the loader hooks Xml::ParentKey already owns, after the engine's loader and before OnLoad, and only when present and non-empty, so a node's value beats its template's and an OnLoad call still overrides it. No new hooks. registerForClicks follows 3.3.5's CSimpleButton::LoadXML. Storm's tokenizer (0x0064AE50, the one 3.3.5 calls) splits the value on spaces and commas. Each name ORs in its bits through Frame::MouseRegistration::MaskForName, the RegisterForMouse name table (3.3.5's MouseButtonStringToBitmask, AnyUp / AnyDown included). The result replaces the mask through the engine's own setter 0x00779730 (__thiscall(button, mask), ret 4, writes only +0x330). wordwrap goes through FontString::WordWrap::Set, the body of fontstring:SetWordWrap: it clears the font's override of the no-wrap style bit and lays the string out again when the value changes. Tested in game: WowStyle1DropdownTemplate's Text (wordwrap="false") now reports CanWordWrap() = nil. |
||
|
|
36f3661b98 |
feat(lua): GetCallstackHeight, GetErrorCallstackHeight, SetErrorCallstackHeight
Adds the three call stack heights an error handler uses to start its
stack at the code that failed:
debugstack(GetCallstackHeight() - (GetErrorCallstackHeight() - 1))
A height counts levels as lua_getstack (0x006FBAA0) does, and so as
debugstack does: C functions and lost tail calls count, and level 1 is
the caller.
1.12.1 records no error height, but every error report runs one C
function, FrameScriptCallErrorHandler (0x00703B40, __fastcall(L)). It
pushes the seterrorhandler function (registry ref 0x008722CC), moves it
under the message and lua_calls it. Nothing calls it directly: state
open pushes it as a C closure and refs it (0x008722C8). Every script
pcall passes that closure as the errfunc, so Lua calls it at the point
of the error before the stack unwinds; a chunk that fails to compile is
reported by a pcall of it (0x00704AE0). ClassicAPI's securecall,
hooksecurefunc and script runners pass the same ref.
So while any handler runs, that closure's level sits directly above the
code that failed. GetErrorCallstackHeight walks the levels with
lua_getstack and lua_getinfo "f", finds the innermost one whose function
is 0x00703B40 (lua_tocfunction, 0x006F3720) and answers the height below
it, or nil when no error is being reported. There is no hook, and
nothing is recorded, so a handler that fails part way leaves nothing
behind.
SetErrorCallstackHeight sets the height for a handler called with no
error raised. It applies only while no 0x00703B40 level is on the stack,
so a value left set by a failed handler cannot move a later error's
stack. A new Lua state starts with no value set.
Users:
- The Lua error window takes its stack this way, so it starts at the
failing code even when another addon wraps the handler.
- CallErrorHandler and assertsafe set the height around their direct
handler call, so they report from their caller.
- Game::Lua gains GetStack, GetInfo and ToCFunction; SourceLocation uses
them in place of its own copies.
Docs: the xpcall and coroutine notes said error() returns without
raising. Stock error (0x00702970) ends in lua_error (0x006F4440) and
raises. pfUI replaces the global error with one that prints and
returns, which is what those notes described.
Tested in game: with seterrorhandler wrapping the old handler, a nil
index in a local function f showed a stack that starts at f.
|
||
|
|
99f72aa631 |
feat(ui): UI_SCALE_CHANGED event
Fires (no payload) each time the game applies the interface scale to UIParent. In 1.12 every scale change goes through one function, SetUiParentScale (0x00494550, void __stdcall(float), ret 4). It raises the value to 0.64, calls SetScale with force (0x0076AC10) and drains the layout queue (0x00768ED0), and does nothing while UIParent (0x00B4B44C) is null. It has six callers: - the uiScale cvar callback (0x00490770, two sites) - the useUiScale cvar callback (0x004907F0, two sites) - OnDisplaySizeChanged (0x00492E90) when useUiScale is on - the automatic scale ApplyAutoUiScale (0x00492F70) One MinHook on it fires the custom event after the original returns, only while UIParent is set. The game UI's Initialize stores UIParent (0x00490077) and its Shutdown clears it (0x00490CA4), so the event never fires on the glue screen. Each path calls the setter once, so one change fires one event; a resize fires it before DISPLAY_SIZE_CHANGED. Tested in game: useUiScale on, uiScale 0.8 and useUiScale off each fired one event with the new scale (0.91, 0.8, the automatic 0.9). |
||
|
|
9e5c0c558a |
feat(autocomplete): C_AutoComplete name completion (API only)
Adds C_AutoComplete.GetAutoCompleteResults, C_AutoComplete.IsRecognizedName, Enum.AutoCompleteEntryFlag and Enum.AutoCompletePriority, and the cvars autoCompleteResortNamesOnRecency, autoCompleteWhenEditingFromCenter and autoCompleteUseContext. ClassicAPI only answers the queries; an addon draws the list of names. 1.12.1 keeps no autocomplete list, but it keeps every list the names come from, so each query reads them where the client keeps them: - party: the four GUIDs at VAR_PARTY_GUIDS (0x00BC6F48), names from the name cache, online from the member stats block - raid: the VAR_RAID_MEMBER_PTRS slots (0x00B712A8) and their online bit - guild: the GuildMemberInfo roster at 0x00B72704, GUID at +0x00 and the online word at +0x48 (stored at 0x004D0C22, tested by GetGuildRosterInfo at 0x004D13C5). Read only while the player's guild key is set, the test IsInGuild (0x00516DE0) makes, because the client keeps the old roster after a /gquit - friends: the 50 slots of the social singleton Whisper partners are the one list the client does not keep. The chat dispatch hook (FUN_0049A870) reports each whisper and whisper inform (types 6 and 7, not the addon language -1) with the sender GUID it already resolves. Logging out clears the list. Names match case-insensitively by UTF-8 code point; Text::Utf8::CompareI now takes a character limit. Results come most recent whisper first, then by name. A result's priority is its closest tie: friend, guild, group, whisper. GetAutoCompletePresenceID and GetAutoCompleteRealms are constant answers in Compat.lua. The three cvars are on a new Social page of the options panel. |
||
|
|
b3b950f2d8 |
feat(spell): spell alerts and proc glows (API only)
Adds C_SpellActivationOverlay.IsSpellOverlayed (and the global
IsSpellOverlayed), Enum.ScreenLocationType, and the four
SPELL_ACTIVATION_OVERLAY_* events. Nothing is drawn: an action-bar or
UI addon draws the alerts and the glows from these.
Glows come from the engine's own reactive-spell list. AddSpellToBook
puts every learned spell whose record has AttributesEx4 0x200 on the
list at 0x00B71150 (count 0x00B7114C), one 8-byte {spellID, usable}
entry per name. FireUsableEvents (0x004B31C0) retests the list with
the engine's usable check, stores each answer, then signals
SPELL_UPDATE_USABLE (0x107). The module subscribes to that signal
through Event::SignalHook and reads the stored answers, so the verdict
is the engine's (rage, target health, aura states, and the hidden
combo point behind Overpower) and no new hook is needed. A usable entry
glows every spellbook spell with the same name, which is the list's own
identity rule, so a bar slot with any rank glows. On stock 1.12.1 this
is Execute, Overpower, Revenge, Riposte, Counterattack, Mongoose Bite
and Hammer of Wrath; Turtle's Spell.dbc changes the set by itself.
Alerts come from two Blizzard rows whose aura exists unchanged in 1.12:
Shadow Trance (Nightfall art, glows Shadow Bolt through its class mask
via Spell::Lookup::IsFitToFamily) and druid Clearcasting
(Natures_Grace art). An Aura::Source observer reconciles on the
player's aura add/remove, rescanning the descriptor so counts can't
drift. The texture is a path; 1.12 has no file data IDs.
On world entry, HIDE fires with no spell ID and every active alert
fires SHOW again, so a /reload redraws them. Glows already lit before a
/reload do not re-fire; a button reads IsSpellOverlayed when it draws.
Logging out clears the state without events.
Event::EnteringWorld gains an observer list, because it claims
PLAYER_ENTERING_WORLD in the signal chain and later subscribers never
see it. Event::Custom's reservation cap goes from 96 to 128: the four
new events filled the old cap exactly, and a name past the cap is
dropped silently.
|
||
|
|
5dcf10a9fd |
fix(player): name cache keeps one copy of each player and honors renames
The persistent name cache copied every name reply into its own map, so each player the engine named this session was held twice. The copy also went stale. On a rename the server sends SMSG_INVALIDATE_PLAYER (0x31C) and HandleNameInvalidate 0x00555600 frees the engine's record, but our copy kept the old name, and GetPlayerInfoByGUID / UnitNameFromGUID fell through to it. The store now holds only the players the engine's name cache (0x00C0E228) does not: - A Net::PacketDispatch subscriber reads SMSG_NAME_QUERY_RESPONSE (0x51) in the same order as HandleNameQueryResponse 0x005551A0 and drops our entry just before the engine stores its record. This replaces the hook on NameCacheStore 0x0055F310. The backstop save runs before the drop, so no save misses the player. - The same subscriber drops our entry on SMSG_INVALIDATE_PLAYER. - The engine empties its cache only at world entry: NameCacheClear 0x00560400, called from CGGameUI::InitializeGame through 0x00555740. A hook there copies the engine's records into the store first, while the store still holds the realm they came from. - At exit the engine frees the cache from its atexit handler (NameCacheSave 0x0055EC70). Storm's exit handler 0x0064CC30 runs every atexit handler before ExitProcess, so DLL_PROCESS_DETACH was too late to read it. At the first world entry the clear hook registers our save with the exe's own _atexit (0x00409AEF). Handlers run newest first, so ours runs before the engine's. Detach now calls Shutdown, which never reads the engine's cache. - A save writes our store, then the engine's records, so a load applies the engine's data over ours. - C_PlayerCache.RememberPlayer leaves alone a player the engine holds. One hook removed (0x0055F310), one added (0x00560400). |
||
|
|
3ef6c4ffed |
fix(player): name cache keeps each player's realm and whole UTF-8 names
The persistent name cache cut names at 16 bytes. A Chinese character is 3 bytes in UTF-8, so a 6-character name lost part of its last character. The limit is now the engine's own: the name cache store (0x0055F310) copies the name with SStrCopy(dst, src, 0x30) and the realm with SStrCopy(dst, src, 0x100), now PLAYER_INFO_NAME_SIZE and PLAYER_INFO_REALM_SIZE in Offsets.h. A longer name from Lua is cut on a UTF-8 lead byte, never inside a character. Entries are now keyed by GUID, the engine name cache's own key, and keep the record's server name (+0x30, empty for a player on this realm). The by-name index uses the form the engine itself shows for a player from another realm: ClientChatHandler (0x0049D560) builds the sender as name, "-", and the realm with spaces and tabs removed. A bare name stands for this realm. Player::FullName builds and parses that form. Two players with one name from two realms no longer replace each other, C_PlayerCache.GetPlayerInfoByName takes "Name-Realm" (a chat sender name as it comes), and the persistent fallbacks of GetPlayerInfoByGUID and UnitNameFromGUID return the stored realm. A "Name-Realm" skips the by-name search and the friends list, which keep no realm. The engine name cache walk moved from Unit::Identity into Player::Info, its one caller. The cache is one flat file per realm, WTF\ClassicAPI\NameCache-<realm>@<realmList>.txt, in a v5 format split on tabs (a realm can hold spaces): guid, name, realm, class, race, sex. The v4 file under WTF\ClassicAPI\<realmList>\<realm>\ is migrated on first load and deleted, with its emptied folders, once v5 is saved. The old import from the per-account path is gone. The store loaded once per process and saved to whatever realm was current, so logging out into another realm wrote the first realm's players into the second realm's file. It now records the file it holds: every access compares that with the current realm's file, and on a change saves the old realm's entries to their own file before loading the new one. A failed rename leaves the cache dirty for the next flush. Verified on Octo: all 63,178 N'Zoth v4 entries migrated unchanged, 13 of 13 C'Thun entries migrated, the v4 folders were removed, and a N'Zoth to C'Thun switch in one session kept the two files apart. Fixes #119 |
||
|
|
1ef8c5597a |
fix(player): UnitNameFromGUID returns the name cache's realm
CGUnit_C::GetUnitName (0x00609210) takes a realm out-pointer as its stack argument, not the flags word Offsets.h called it. For a player whose name-cache record has a non-empty server name (record +0x30) it stores a pointer to that string, and otherwise leaves the pointer alone (0x0060926B-0x00609283). Vanilla's Script_UnitName (0x00517020) passes &realm there and returns it as UnitName's second value. The record's server name is the realm string SMSG_NAME_QUERY_RESPONSE carries: Tortoise sends it empty, a cross-realm server fills it. UnitNameFromGUID pushed a hard-coded "" instead. NameFromGuid now passes the out-pointer through, as Script_UnitName does, and gains a step between the friends list and the persistent cache: the engine name cache record itself (FUN_PLAYER_INFO_LOOKUP with no callback, a passive peek), which also gives the realm for players out of range. Before, a player who whispered from far away resolved only with the persistent cache on. UnitSpellTargetName shares NameFromGuid and finds those players too. The realm is "" when the record has none, or when the name came from the friends list or the persistent cache, which stores no realm. Retail documents both returns as non-nil strings. GetNameAndServerNameFromGUID in the addon's PlayerUtil returned GetRealmName(), the local realm, for every GUID. It now returns GetPlayerInfoByGUID's realm, as retail's UnitUtil does, so a player on the local realm gets "" and code that appends "-" .. realm only when it is non-empty works. Seven files declared their own function-pointer type for 0x00609210, all with the wrong int *outFlags argument. Unit::Identity::NameForUnit is now the one wrapper. The other six callers pass no realm and behave as before. Offsets.h gives the getter's real signature (RET 4) and what it stores. API.md's GetPlayerInfoByGUID and UnitNameFromGUID entries describe the realm and the four sources. |
||
|
|
84171bef2d |
fix(unit): mirror timers clear on leaving the world, empty slots say UNKNOWN
The engine's handler for the three mirror-timer SMSGs (0x005E7990) only reads each packet and signals MIRROR_TIMER_START / _PAUSE / _STOP, so GetMirrorTimerInfo and GetMirrorTimerProgress read a table of our own. A MinHook on that handler fed it by reading the packet and putting the cursor back. The table now reads START (0x1D9) and STOP (0x1DB) as a Net::PacketDispatch subscriber, and the hook is gone. CGPlayer_C::Release (0x005E9AA0) runs StopMirrorTimers (0x005E9B90) for the active player: MIRROR_TIMER_STOP for all three types, with no packet. The table never saw it, so a breath timer stayed after a logout or a loading screen. Release then calls LeaveWorldUI (0x00490A80), which fires PLAYER_LEAVING_WORLD through the no-arg dispatcher. An Event::SignalHook subscriber clears the table on that event. What the functions return: - GetMirrorTimerInfo returns an empty slot as "UNKNOWN" with zeros, the name helper 0x005E7AE0 gives for no type, instead of nothing. Code that tests for "UNKNOWN" on PLAYER_ENTERING_WORLD called its setup with nil before. paused is a number, as the event's %d is, and spellID is a seventh value. - A PAUSE packet no longer changes the table. Tortoise never sends one: it resends START with the paused byte, which the table keeps. - GetMirrorTimerProgress is value + scale * elapsed with no clamp. A timer started paused holds its value. Names match through SStrCmpI, and a name that is not a timer type returns nil. - The time comes from Time::Clock. 0x0042B790 truncates the tick itself and returns it in EAX, so the GetTickCount workaround for an FPU return had no cause. Offsets.h drops the CDataStore readers, the handler and the PAUSE opcode, which nothing reads now, and its comment gives the verified signatures and packet layout. Both functions get API descriptors under the MirrorTimer system. API.md's section is rewritten to match. |
||
|
|
38d5c6c7b6 |
fix(unit): ClassicAPI's unit events reach markN and the soft tokens
ClassicAPI fires its own unit events (UNIT_AURA_DELTA, the remote UNIT_SPELLCAST_*, the power, group-member, distance, incoming-resurrection and targetable events) once per token through Unit::Identity::TokensForGUID. That took the engine's tokens from its reverse map FUN_UNIT_TOKENS_FROM_GUID (0x00515C50) and then added its own short list: focus and nameplateN. The engine's unit events get their ClassicAPI tokens from a second list in Unit::TokenEvents, which also has markN, softenemy and softfriend. So a soft enemy got UNIT_HEALTH but never UNIT_SPELLCAST_START. That list is now the public Unit::TokenEvents::TokensOf, capped at the caller's room and empty before the player object exists, as before. TokensForGUID appends it to the engine's tokens, so both kinds of event reach the same tokens, and a new token goes in one place. nameplateN now comes before focus, the order TokensOf already used. API.md's soft enemy and soft friend section now says that their tokens fire unit events, as the focus, nameplateN and markN sections do. |
||
|
|
f9ec92014c |
feat(target): show softenemy and softfriend names as the target's
Retail shows a soft unit's overhead name the way it shows the target's: a soft enemy past nameplate range keeps its name, whatever the UnitName cvars say. 1.12 decides an overhead name in CGUnit_C::ShouldShowName (0x6070A0), which its only caller, the name draw PLAYERNAMEDESC::UpdatePlate (0x6C6EE2), asks every frame. In order: no name when CanSelect (vtable +0x58) refuses the unit, or when it has a nameplate (+0xE60) or a chat bubble (+0xE64); the active player by UnitNameOwn; the target always; then the UnitName mask. A hook gives a soft unit the target's branch: the first three tests, then 1. The player is never a soft unit, so the own-unit test does not apply. In nameplate range the plate shows and the name does not, as for the target. The name draw runs inside the scene (the model draw callback 0x6C7780), so the hook reads the soft GUIDs cached on the UI frame tick, as the selection circle does, and never picks there. Nothing invalidates: the verdict is asked fresh each draw. |
||
|
|
264af04ee3 |
feat(cooldown): countdown formatter and C_StringUtil.CreateNumericRuleFormatter
Addons can now choose the countdown text and its color for each range of time left. Cooldown:SetCountdownFormatter(formatter) and GetCountdownFormatter() take a NumericRuleFormatter from C_StringUtil.CreateNumericRuleFormatter(). Its breakpoints each give a threshold, an optional step, rounding (Enum.NumericRuleFormatRounding), min and max, a format string, and optional div/mod/step components, one for each format argument. Color codes in the format string pass through. The formatter is a full Lua userdata, the first in the DLL. Its block holds a pointer to a reference-counted native object. Every Lua object and every frame that uses it hold one reference, so the GC finalizer (__gc) and the frame's deleting destructor can run in any order. lua_newuserdata (0x6F4560, __fastcall, block at Udata + 0x10, read from the disassembly) is new in Offsets.h. lua_touserdata reuses FUN_FRAMESCRIPT_GET_OBJECT, which is that function. One metatable per Lua state lives in the registry. Its __metatable is false, and the identity check compares a value's metatable with it. 1.12 has no newproxy, so the only finalizer an allocation can run is ours. Thus no addon code can change a formatter while it formats. The text goes through 1.12's own str_format (0x7FD3D0). Its closure is made once per state and kept in the registry, because FormatNumber runs from addon timers and lua_pushcclosure allocates on each push. The rounding is x - fmod(x, step), plus a step away from zero when the rounding needs it. Only that arithmetic matches retail to the last bit: Up of 0.7 by 0.1 gives 0.7000000000000001 and of 0.6 gives 0.6, but ceil(x / step) * step gives 0.6000000000000001. The cooldown shares the formatter and gives it the unrounded seconds left. The formatter replaces the built-in text and both thresholds, and every gate stays. The cached countdown text is now a heap std::string, because a formatter's text has no length limit. The frame frees it, and its reference, in DeletingDestructor. A probe addon recorded 229 results in retail 12.1.5. The same probe on 1.18.1 matched 197 of them. The other results come from 1.12's own str_format (%e exponent digits, %q, %d past the int range, its error wording), from field storage on the object (not ported), and from addresses and times. |
||
|
|
090cfc3bfd |
feat(lua): global wipe, the table.wipe alias
On a stock 1.12.1 client, ScrollBoxListView, ScrollUtil, Menu and the DebugTools table inspector failed with "attempt to call global `wipe'": those ports call bare wipe(), and only Turtle's client defines that global. Stock 1.12.1 has only the table.wipe that ClassicAPI registers. 3.3.5 makes the alias in FrameScript's compat preamble, next to tinsert and tremove (wipe = tab.wipe). 1.12's preamble is older than table.wipe, so Wipe.cpp now registers the same C function as the global wipe as well as table.wipe, with a LuaGlobals descriptor. CallbackRegistry, MixinUtil and SecureTypes lose their "1.12 has no global wipe" notes and their table.wipe locals, and now match retail. |
||
|
|
d1cdb47c3e |
feat(unit): restore UnitFacing
UnitFacing(unit) returns the unit's facing in radians (0 = north, counter-clockwise, 0..2pi), or nothing when the token has no unit. The facing comes from the object's GetFacing virtual, vtable slot 6. The unit and player vtables (0x80C4F8 / 0x80AF78) both hold CGUnit_C::GetFacing (0x5F1F30) there, read from the binary: it loads the mover at +0x118, pushes its facing +0x1C and returns CMovement::TransportFacingToWorld (0x7C4AE0), which adds the transport's facing and wraps once into [0, 2pi]. Unit::Position::Facing wraps the call next to the shared position read. GetPlayerFacing moves to the same read. It used to load the float at +0x9C4 (the mover's +0x1C) directly, which is the facing relative to the transport, so on a boat or zeppelin it returned the wrong angle. The OFF_UNIT_FACING offset goes with it. |
||
|
|
1e1463cf9a |
feat(unit): UNIT_IN_RANGE_UPDATE and UNIT_DISTANCE_CHECK_UPDATE
UNIT_IN_RANGE_UPDATE (unitTarget, isInRange). Nothing in the client reacts to a distance: the player moves every frame while it moves, and other units in view are moved a little each frame between their movement packets. So a world-tick pass checks the units, only while a frame is registered for the event. The pass walks the event's subscriber chain (Event::Custom::ForEachListener, which FireValues now uses too): a frame registered with RegisterUnitEvent adds its units (Frame::UnitEvent::Units), and a plain registration adds pet and each party and raid member and their pets. A token fires when Unit::Range::InRange changes for it. UnitInRange now calls the same function. A filter unit that is not a unit token is dropped after one protected IsUnitToken check, since the engine's resolver raises a Lua error for it. UNIT_DISTANCE_CHECK_UPDATE (unitTarget, isInDistance) is true while the client holds a group member's object. UpdateRaidMemberRecord (0x004BADC0) has four E8 callers, which are exactly a player object entering the object table (CGPlayer_C::PostInit 0x005DEC43, PostUpdate on reactivation 0x005DECAF) and leaving it (the release slot 0x005E9ACF, ~CGPlayer_C 0x005DD6AB for an object never released). The calls point at a site that notes a party or raid member's GUID (IsRaidMemberOrPet, not the active player), and the next world tick fires for each of its tokens with whether the object table holds it then. The release slot runs before the manager moves the object to the released table, so a fire in place would still show the member to UnitIsVisible. No loaded DLL references the function or the sites. |
||
|
|
c21e44e086 |
feat(unit): UNIT_AREA_CHANGED fires when a group member changes zone
DiffPartyRecords (0x005E5510) already sets bit 0x80 when the zone in a party record (+0x14) differs, but SignalPartyRecordChanges (0x005E5720) raises nothing for it. The existing SignalSite redirects (the calls in ReadPartyMemberStats and ComparePartyRecord, and the AddPartyMember tail) now fire UNIT_AREA_CHANGED (unitTarget) on that bit, after the engine's own events, once per token of the member. The server sends the zone only to members that cannot see the player. A member in view is built with the player's own zone (BuildPartyRecord stores s_zoneId), the same zone GetRaidRosterInfo gives for a held object, so ComparePartyRecord sets the bit when a member comes into view from another zone. CGPlayer_C::PostInit skips ComparePartyRecord for the active player, so "player" gets no event. |
||
|
|
e76616de83 |
feat(player): PLAYER_MOUNT_DISPLAY_CHANGED fires when the player's mount changes
1.12.1 reacts to a unit's new UNIT_FIELD_MOUNTDISPLAYID in CGUnit_C::OnMountDisplayChanged (0x005FFA50): dismount from the old display, mount the new one with the mount-up effect, refresh the loop sound, quest marker and name. The field's type watcher OnMountDisplayFieldChanged (0x00604570) resolves the unit and calls it with the old value from one E8 call (0x0060459B), only on a real change. That call now reaches a function that runs the handler, then fires PLAYER_MOUNT_DISPLAY_CHANGED (no payload) when the unit is the player. VanillaHelpers calls the handler directly after a local mount morph and patches neither address, so a cosmetic morph fires nothing. |
||
|
|
92794a1822 |
feat(unit): UNIT_TARGETABLE_CHANGED fires when a unit's selectability flips
1.12.1 reacts to a changed UNIT_FIELD_FLAGS in CGUnit_C::OnUnitFlagsChanged (0x005FF580), which the flags field's type watcher OnFlagsFieldChanged (0x006044B0) calls with the old flags from one E8 call (0x006044DB). It handles looting, disarm, reaction, PvP and the aura bit, but nothing reads UNIT_FLAG_NOT_SELECTABLE (0x02000000). Unit::FlagsChanged now owns that call: it runs the handler, then each subscriber with the unit and the flags before and after, since a call site can be redirected only once. Unit::Targetable subscribes and fires UNIT_TARGETABLE_CHANGED (unitTarget) once per token of the unit when the not-selectable bit flips. |
||
|
|
ab0991f054 |
feat(unit): UNIT_CONNECTION fires when a group member goes on or offline
A party record's status byte (+0x08) carries the online bit UnitIsConnected reads. 1.12.1 changes it in three places, and none signals the flip: - The party member stats packet: ReadPartyMemberStats (0x005E5110) ends in SignalPartyRecordChanges (0x005E5720) with the status change bit. The redirected call that already adds the generic power events now also fires UNIT_CONNECTION (unitTarget, isConnected) when the old and new records differ in the online bit. - The group list (0x7D): the server reports a logoff only there. AddPartyMember (0x004E82D0) copies a kept member's previous record and sets the online bit, then stops. Its call now diffs the previous record against the stored one (DiffPartyRecords, 0x005E5510) and runs the same SignalPartyRecordChanges path, so the engine's status events and UNIT_CONNECTION follow. - A raid member outside the player's party has only a raid slot, whose status byte RebuildRaidRoster (0x004BA5F0) sets from the same list. Its call now compares each returning member's online bit before and after and fires UNIT_CONNECTION on a flip; party members are skipped, since AddPartyMember ran first. isConnected is a real boolean, pushed through FireValues. |
||
|
|
09693af5b9 |
feat(unit): UNIT_POWER_UPDATE, UNIT_POWER_FREQUENT and UNIT_MAXPOWER
1.12.1 calls type-wide field observers for every unit whose watched bytes change: ClntObjMgrSetTypeMirrorHandler (0x00468070) puts a record on the global list of a (bank, field), and CGUnit_C::RegisterFieldWatchers (0x006041F0) uses it for the engine's own unit handlers, among them OnPowerFieldChanged on the power block, which only refreshes usability. Two handlers join those lists, one record per POWER1..5 and MAXPOWER1..5 slot, so the callback's field offset is the power type. They fire UNIT_POWER_UPDATE and UNIT_POWER_FREQUENT, or UNIT_MAXPOWER, with (unitTarget, powerType) once per token of the unit. Every client power change is a server update, so FREQUENT fires with UPDATE. Each in-world registration pass removes and re-adds the records through 0x00468240: the first pass of a session runs in CGGameUI::InitializeGame, after MirrorInitialize (0x0047F840) has rebuilt the tables a record's copy offset comes from, and the removal keeps /reload from stacking a second record. The list array has no other writer, so nothing frees a record behind us. A group member the client cannot see has no unit to watch; its power comes in the party member stats packet. ReadPartyMemberStats (0x005E5110) and ComparePartyRecord (0x005F0B80) end in SignalPartyRecordChanges (0x005E5720), which fires the per-type power events for the changed record bits. Both E8 calls now reach a function that calls it and then fires the generic events for the same bits, the member's and its pet's. |
||
|
|
f24b7e594b |
feat(unit): UNIT_SPELL_HASTE fires when a unit's spell haste changes
1.12.1 turns unit-field changes into events by index: FUN_0051bbb0 watches unit field i when slot i of the static event-name array at 0x00BE1198 is named, and FUN_0051bd50 signals event i once per token of the unit. UNIT_MOD_CAST_SPEED, the field UnitSpellHaste reads, is index 139 (OFF_UNIT_MOD_CAST_SPEED / 4), and slot 139 has no name, so the engine never watched it. Event::Custom::EngineName names slot 139, and the engine's own watchers fire the event for every token. Nothing else signals 139 by number: it is above the glue band and not in the chat-type event table. |
||
|
|
e2a34bd18a |
feat(unit): UNIT_TARGET fires when a unit's target changes
1.12.1 already turns unit-field changes into events. FUN_0051bbb0 registers a watcher on unit field i for each named slot i of the static event-name array at 0x00BE1198, and the watcher (FUN_0051bd50) signals event i once per token of the unit through the broadcast FUN_00515e50. The field index is the event id. UNIT_FIELD_TARGET is index 10, and the watcher's size selector still gives it the 8 bytes of a GUID, but slot 10 has no name, so the engine never watches the field. Event::Custom::EngineName names such a slot. It writes the name into the static array at load, before any world init or unit watch. World init copies the array into the live event table (0x0048FEA1), and the engine's own watchers then fire the event for every token, with focus, nameplateN, markN and focustarget included. The entry joins the reservation list with a fixed slot, so it is documented, kept across /reload, and not counted by Grow. Slot 10 is in the glue band. Its one by-number signal is the glue realm-list rebuild (0x0046E73D), which only CGlueMgr::Idle reaches. |
||
|
|
9967cc0839 |
feat(lua): Spell objects, ContinuableContainer and TableBuilder
Ports from retail's Blizzard_ObjectAPI and SharedXML, in Blizzard's own text, from the _forever_ build (the newest interface code on disk): - Util/Spell.lua: Spell:CreateFromSpellID and SpellMixin. - Util/ContinuableContainer.lua: one callback for a group of item and spell objects. - Util/IndexRangeDataProvider.lua: CreateIndexRangeDataProvider, which ScrollBoxListView already expected. - Util/TableBuilder.lua: CreateTableBuilder, for the existing ScrollUtil.RegisterTableBuilder. - FrameXML/CallbackRegistrant: CallbackRegistrantMixin and CallbackRegistrantTemplate. AsyncCallbackSystem.lua gets its ASYNC_SPELL type and SpellEventListener back, so it is the _forever_ text again. New in the DLL for SpellMixin: - C_Spell.IsSpellDataCached, C_Spell.RequestLoadSpellData and SPELL_DATA_LOAD_RESULT. Every spell is client data, so a spell that exists is cached, and a request fires the event before it returns: (spellID, 1), or (spellID, nil) for an ID with no spell. Retail marks the event synchronous, and AsyncCallbackSystem relies on that. - C_Spell.GetSpellDescriptionForItemLocation. The item tooltip expands a spell's text with the same arguments GetSpellDescription passes, so it returns that text. The item location is still required. Verified in game: IsSpellDataCached(133) and (999999) are true and false, Spell:CreateFromSpellID(133) calls back with (133, 1), a container with item 19019 and spell 133 calls back, CreateIndexRangeDataProvider(5) has size 5, and GetSpellDescriptionForItemLocation(133, slot 1) equals GetSpellDescription(133). |
||
|
|
d92464b86c |
feat(tradeskill): trade links follow 3.3.5
Profession links are now built and opened the way 3.3.5's CGTradeSkillInfo does it. A received link opens in the engine's own TradeSkillFrame. The ClassicAPI viewer is gone. The link is 3.3.5's format: trade:<spellID>:<rank>:<maxRank>:<GUID>:<bits>|h[<spell name>]. The first field is the profession spell, not the skill line. The GUID replaces the name. A reader whose name cache does not hold the linker sends the name query and opens the link when the answer arrives. The bits cover every SkillLineAbility row of the profession, as 3.3.5's link run does. 1.12's DBC is sorted by ID and does not group a profession's rows into one run, so the rows here are taken in ID order. A link opens only when the reader's row count matches it. The 1.12 list build (0x004FCA20) is 3.3.5's RefreshList without the link branch. Three call-site patches add that branch: - the spell list comes from the link, - the ability rows use the linker's race and class, - the rank is the linker's. Two patches on TryCastSpell's toggle calls record the cast spell (3.3.5's m_spellID). They also make a cast while a link shows open the player's own list instead of closing the window. The game shutdown drops the link, as 3.3.5's does. Enchanting gets the same in the Craft window. Its rows are filtered by castUI, because its recipes have no TRADESPELL bit. GetCraftListLink and IsCraftLinked are the Craft window's twins of the 3.3.5 functions. GetTradeSkillLine, GetCraftDisplaySkillLine and GetCraftName give the linker's values while a link shows. Util/TradeSkillLink.lua now ports 3.3.5's linked mode, which hides Create, Create All and the count controls, and keeps the link buttons. Any spell whose Effect[0] is TRADE_SKILL can be linked. 1.12's SkillLine.dbc has no canLink column. Removed: C_TradeSkillUI.GetTradeSkillListLink, GetCraftListLink and GetTradeSkillListRecipes. Old links no longer open. Not yet verified in game. |
||
|
|
fec127c1af |
docs(item): DoesItemExistByID is true for any positive ID
The entry said a cache miss returns false and starts a load. The function returns true for any positive item ID, cached or not, and loads nothing. ContinueOnItemLoad depends on that. |
||
|
|
37ee71c663 |
feat(item): C_PaperDollInfo.GetTemporaryEnchantmentInfo
Retail's per-slot temporary enchant, the function its deprecated GetWeaponEnchantInfo is now built from. It reads the same temporary enchant slot as C_Item.GetItemTempEnchantInfo, in retail's shape: an INVSLOT_ number in, and a TemporaryItemEnchantInfo table out (enchantID, remainingTimeMs, chargesRemaining, hasExpirationTime), or nothing when the slot has no temporary enchant. A slot outside 1..19 also returns nothing, so the engine never sees it. hasExpirationTime is the descriptor duration gate that the shared reader already tested before it asked for the time left. C_Item.GetItemTempEnchantInfo stays as the ClassicAPI extension for a weapon in a bag (#47). The docs link the two. |
||
|
|
6259e22480 |
feat(lua): ItemUtil from retail
Util/ItemUtil.lua is now the ItemUtil table of retail
Blizzard_FrameXMLUtil/ItemUtil.lua, in retail's own text. As its header
lists, it leaves out ItemButtonUtil and DoesAnyItemSlotMatchItemContext
(retail drives them from frames this client does not have), the transmog
mixin, the currency path of GetItemDetails, and GetCraftingReagentCount
(reagent and account banks).
New for what it calls:
- Enum.BagIndex in the DLL, with Classic Era's names and this client's
indices: Keyring -2, Bank -1, Backpack 0, Bag_1..4 = 1..4 and
BankBag_1..6 = 5..10. Era's bank bags start at 6, after its reagent
bag. The indices live in Offsets.h now, and container/Search.cpp drops
its local copies.
- C_PaperDollInfo.GetInventorySlotInfoForInvSlot in the DLL. It takes the
first PaperDollItemFrame.dbc row with that SlotNumber, and walks the
rows the way the engine's GetInventorySlotInfo (0x004C81B0) does.
- C_Container.GetContainerNumSlots and C_Container.PickupContainerItem as
Lua aliases of the stock globals in Compat.lua, next to
C_ActionBar.ShouldShowKeyring, which is always true.
- ContainerFrame_GetContainerNumSlots and NUM_TOTAL_BAG_FRAMES from
retail's ContainerFrame.lua, and GameTooltip_SuppressAutomaticCompareItem.
Nothing reads that flag, because nothing compares items automatically.
docs/API.md covers all of it, plus Item objects and
C_Item.GetItemIDForItemInfo.
Verified in game: Enum.BagIndex.Keyring is -2, the backpack has 16 slots,
ShouldShowKeyring is true, slot 18 returns the ranged row with checkRelic
true, GetEmptyEquipSlotTooltip(1) is "Head", and FilterOwnedItems({6948})
finds a Hearthstone in the bags.
|
||
|
|
635c74d518 |
fix(smf): ScrollByAmount stops where ScrollUp stops
ScrollByAmount moved the offset straight to the clamped target, and the clamp is retail's count - 1, where the oldest message sits alone on the bottom line under empty space. 1.12's own ScrollUp (0x788610) stops sooner, at +0x350 (4.3.4's m_atTop), which the layout sets once every message back to the oldest fits the height (0x788A37). A chat wheel built on ScrollByAmount (pfUI's) scrolled chat up until it was nearly empty. The engine has two scroll families, in 1.12 and 4.3.4 alike: ScrollUp and PageUp stop at m_atTop, and ScrollToTop and SetScrollOffset go to the oldest record. Retail defines ScrollUp as ScrollByAmount(1) and ScrollToTop as SetScrollOffset(GetMaxScrollRange()), so ScrollByAmount now steps the engine's ScrollUp / ScrollDown (0x788610 / 0x788650), the loop PageUp (0x7885B0) runs, and SetScrollOffset / GetMaxScrollRange keep count - 1. The clamped target still bounds the steps: a hidden frame never lays out, so its ScrollUp never finds the top and wraps. Verified in game: ScrollByAmount(1000) on ChatFrame1 stops with the oldest message on the top line and an offset below GetMaxScrollRange(). |
||
|
|
5d0568f759 |
feat(lua): Pools follows retail, with securecallmethod
Pools.lua is now retail Blizzard_SharedXMLBase/Pools.lua, on the SecureTypes and ProxyUtil ports the Menu backport already uses. CreateObjectPool, CreateFramePool and the rest alias the secure variants as on retail, so they return proxies that expose only the pool methods. CreateFramePool takes retail's (frameType, parent, template, resetFunc, forbidden, postCreate, capacity); a table specialization goes through FrameUtil.SpecializeFrameWithMixins; CreateObjectPool works without a reset function; Pool_HideAndSetToDefaults is new. The ClassicAPI-only CreateUnsecuredActorPool and CreateUnsecuredFontStringPoolCollection are gone (nothing used them). Two differences, noted in the header: no secret-value check on release (1.12 has no secret values), and a forbidden pool makes normal frames (no CreateForbiddenFrame). The TOC loads SecureTypes and ProxyUtil before Pools, as retail's does; Pools reads both at load. SecurePoolCollectionMixin:Release calls securecallmethod, now in src/baselib/SecureCall.cpp next to securecallfunction, on both Lua states: object[method](object, ...) with a raw lookup, an error goes to the error handler and the call returns nothing. That follows retail's API documentation; it is not probed. docs/API.md covers it. Verified in game: securecallmethod returns the method's result, a frame pool hides its internals behind the proxy while acquire and release keep the count, and a frame pool collection runs a table specialization's OnLoad, acquires, and releases through securecallmethod. |
||
|
|
503368623f |
feat(localization): BreakUpLargeNumbers, AbbreviateNumbers, AbbreviateLargeNumbers
Retail's number formatters (LocalizationDocumentation.lua) and
C_StringUtil.GetDefaultAbbreviationBreakpoints. Retail moved them from
FrameXML into C in 12.0.0, so the behavior is taken from probes of an enUS
retail client, recorded in src/localization/Numbers.cpp:
- BreakUpLargeNumbers drops the fraction of a whole number or one 1000 or
more in size and groups it with LARGE_NUMBER_SEPERATOR while the
breakUpLargeNumbers cvar (retail's, default on) is set; other numbers
keep one decimal, rounded half away from zero. natural writes a million
or more in words ("1.2 million", "123 million").
- AbbreviateNumbers walks retail's default breakpoints, or
options.breakpointData, or the Asian table for options.locale koKR /
zhCN / zhTW. Retail's defaults name THIRD_ and FOURTH_NUMBER_CAP_NO_SPACE,
which its clients do not define, so billions and trillions carry no
letter there and here.
- AbbreviateLargeNumbers walks FrameXML's old thresholds, rounds to a whole
number outside the Asian locales, and falls back to BreakUpLargeNumbers.
The asian natural-word scales (1e4 / 1e8 / 1e12) are read off the strings,
not probed. options.config (CreateAbbreviateConfig) is not backported.
Every locale file, and a new koKR.lua, gets DECIMAL_SEPERATOR, FIRST/SECOND_NUMBER_CAP[_NO_SPACE]
and FIRST..FOURTH_NUMBER from the matching Classic GlobalStrings; the
German, Spanish and French words carry |7 plural tokens, which the grammar
pass does not expand yet.
FormattingUtil gains retail's GetCostString and GetItemCostString on top.
docs/API.md documents the four functions, the cvar and
Constants.MoneyFormattingConstants; README.md lists them.
Verified in game: every probed retail value reproduces exactly (BreakUp
with and without natural, AbbreviateNumbers with defaults, Asian locale
and custom breakpoints, AbbreviateLargeNumbers), the cvar toggles the
separators, and GetItemCostString shows the amount and item icon.
|
||
|
|
77b304ae68 |
feat(smf): RemoveMessagesByPredicate
ScrollingMessageFrame:RemoveMessagesByPredicate(predicate), retail's: the predicate is called with each message's GetMessageInfo values, oldest first, and the messages it returns true for are removed; the rest keep their order. It covers 4.3.4's RemoveMessagesByAccessID / ByExtraData, whose int fields the retail-shaped records here do not have. 1.12's ring has no compaction of its own; the removal is 4.3.4's RemoveLines loop over it: every kept record moves forward in ring order to the first free slot (freeing the text it lands on, nulling the one it left), the position moves back by the removed count, and the extra-argument tables move with their records. Then the engine's own layout (0x00788750) from the record at the kept scroll offset, clamped to the oldest, and its re-arm (0x00788B80) - a layout at the bottom keeps the fade state, so 4.3.4 re-arms after - or its Clear (0x007882B0) when nothing is kept. The predicate runs for every message before anything moves, through the engine's error handler; a predicate that errors keeps that message, as retail's safesecurecall does. GetMessageInfo shares its record lookup and value push with it. |
||
|
|
c965e49117 |
feat(smf): BackFillMessage
ScrollingMessageFrame:BackFillMessage(text, r, g, b, ...), retail's: the
message becomes the oldest, for rebuilding a frame from history newest to
oldest (Blizzard_CombatLog's refilter adds each entry with it).
The ring's writer 0x00788150 has one slot rule: the one after the newest.
BackFillMessage writes the slot 4.3.4's AddMessage(..., addToTop) picks —
the free one before the oldest, (pos - count + 1) mod max once the count
has grown — and fills the record as the writer does: a Storm copy of the
text, AddMessage's colour (clamped, x255 + 0.5 truncated, alpha 0xFF; the
font's without r, g, b), shown, the frame's two times, id 0, and the extra
arguments kept for GetMessageInfo. Nothing already in the ring moves, so a
scrolled-up frame keeps its view; at the bottom the lines are laid out
again from the newest, as the writer does.
A frame at its line limit drops the message, as retail's CircularBuffer
PushBack does ("Won't overwrite front"); 4.3.4 overwrites the oldest slot
there, which Blizzard_CombatLog never reaches.
|
||
|
|
7cb6cda101 |
feat(smf): TOP insert mode
SetInsertMode(SCROLLING_MESSAGE_FRAME_INSERT_MODE_TOP) now shows the newest message at the top, older ones below it, as retail's mixin does. 1.12's line layout anchors each line once, when it makes it, through one SetPoint call (0x00788975). That call is redirected: lines of a TOP frame take the TOP anchors, every other line keeps the engine's own arguments. The layout remakes the lines when the frame resizes, so the redirect covers that too. A mode change re-anchors the existing lines with the layout's own steps and refreshes the display. Insert mode moves out of Scroll.cpp into InsertMode.cpp. |
||
|
|
5ab497f2c7 |
feat(smf): scroll offset, insert mode, display-refreshed callbacks
Retail's ScrollingMessageFrame SetScrollOffset, GetScrollOffset, GetMaxScrollRange, ScrollByAmount, SetInsertMode / GetInsertMode with the SCROLLING_MESSAGE_FRAME_INSERT_MODE_* globals, and AddOnDisplayRefreshedCallback, which ScrollUtil's InitScrollingMessageFrameWithScrollBar calls. The offset is the engine's own: SetScrollFromBottom's body (0x00788700) is 4.3.4's SetScrollOffset step for step, and GetCurrentScroll is GetScrollOffset under retail's name. The setters clamp to 0..GetNumMessages()-1 first, as retail does; the engine wraps. 1.12's layout stacks lines bottom-up only, so the insert mode is BOTTOM and SetInsertMode raises an error for anything else. The callbacks run after the frame's own update (0x00788460, OnUpdate then the fader), where retail's OnPostUpdate runs them, for a frame the line layout, AddMessage or ScrollByAmount marked. The layout hook moves out of Text::InlineTexture into ScrollingMessageFrame::Layout, which owns it and fans out to both. |