mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
v1.16.0
1089
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
99de63755b |
CreateFrame("Cooldown") (#106)
* feat(frame): CreateFrame("Cooldown") builds vanilla's cooldown Model
Later clients have a native Cooldown frame type; vanilla draws cooldown
sweeps with a Model from FrameXML's CooldownFrameTemplate, driven by
CooldownFrame_SetTimer, and its CreateFrame rejects the type name
("Unknown frame type 'Cooldown'"). Ported code writes
CreateFrame("Cooldown", name, parent, "CooldownFrameTemplate") and then
calls CooldownFrame_SetTimer - Zygor Guides Viewer 2.0 does it while
building its guide window, which stopped there.
In the CreateFrame hook, build a "Cooldown" request as "Model", defaulting
the template to CooldownFrameTemplate when none is given.
Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0):
CreateFrame("Cooldown", nil, UIParent, "CooldownFrameTemplate") returns a
Model, and Zygor's guide window builds.
* feat(frame): give the Cooldown frame 4.3.4's methods
4.3.4's CGCooldown_Scripts registers SetCooldown, SetReverse,
GetReverse, SetDrawEdge and GetDrawEdge. The Cooldown frame built by
the CreateFrame hook now has the same five: SetCooldown takes start
and duration in seconds and errors as 4.3.4 does when either is not a
number, the setters read their value as 4.3.4's StringToBOOL does,
and both flags start false.
The hook marks each frame it builds as a Cooldown. The methods keep
their state per marked frame, SetCooldown drives the sweep through
CooldownFrame_SetTimer, and a marked frame reports its type as
"Cooldown" from GetObjectType / GetFrameType and answers
IsObjectType("Cooldown"). Every other frame delegates to the engine's
own type methods.
The reverse and draw-edge flags are stored and reported, but do not
change how the sweep draws: the sweep has no reversed form and no
edge. The five methods sit on the Model registry, so a Model that was
not built as a Cooldown raises the wrong-object-type error when one
is called on it.
---------
Co-authored-by: Jared Reni <jaredreni@gmail.com>
v1.16.0
|
||
|
|
7cd891e86c |
fix(bindings): follow 4.3.4's bindings, modified clicks and key state
Modified clicks: IsModifiedClick, GetModifiedClick, SetModifiedClick, GetNumModifiedClickActions and GetModifiedClickAction, with 4.3.4's <ModifiedClick> Bindings.xml node and its 18 defaults. Each binding set loads, saves and copies them through co-hooks on the engine's own binding-set steps, in 4.3.4's "modifiedclick" file lines. [mod:] asks IsModifiedClick, as 4.3.4's macro conditions do. Direct actions run as 4.3.4's ExecKey runs them: SPELL / ITEM / MACRO on key release through 1.12's spellbook, item and macro functions, cast at you for SELFCAST and at your focus for FOCUSCAST; CLICK sends the frame a mouse down and up, with 4.3.4's virtual-click button logic built from the button's own methods. RunBinding no longer runs them. While a key binding runs, its own modifiers count as released for every modifier read, the engine's IsKeyDown included. Overrides follow 4.3.4: two lists per key, checked inside the key lookup at both of 1.12's lookup steps; GetBindingAction takes checkOverride; isPriority is loose; "" removes; the owner must be a frame. ActionButtonUseKeyDown (default 0) and 4.3.4's action-button key handlers, ported onto 1.12's bars. |
||
|
|
6e50577565 |
fix(target): follow 4.3.4's TargetNearest and TargetDirection
TargetNearest, TargetNearestEnemyPlayer and TargetNearestFriendPlayer now run the engine's own tab cycle (FUN_00493F60), which is 4.3.4's TargetNearestEnemy: units in front first, the targetNearestDistance / targetNearestDistanceRadius ranges, no critters or unseen units, and the 3 s / 1 s snapshot shared with the native functions. A co-hook on its predicate adds 4.3.4's types 0, 2 and 4 as three new modes. TargetNearest now cycles any unit, as in 4.3.4. TargetDirectionEnemy / TargetDirectionFriend are now 4.3.4's CGGameUI::TargetDirection, built on 1.12's GetScreenCoordinates, the camera's forward vector and the tab search's tests: facing is a screen direction relative to the camera, the search starts at the target when it is on screen, the cone is at least 22.5 degrees, and a hit locks further calls until the new TargetDirectionFinished(). |
||
|
|
024c6d2021 |
feat(chat): prefix %t with the target's raid marker, as 4.3.4 does
4.3.4's chat parser prefixes both of its name codes, %f and %t / %n,
with {rtN} when the unit carries a raid marker and a name was found.
1.12's %t already resolves the name the same way, so the hook only
writes the marker in front of the %t pair and the engine still fills
in the name.
Rename Chat::FocusToken to Chat::ChatTokens; %f and %t share the name
lookup and the marker helper.
|
||
|
|
4b47059788 |
feat(debugtools): build /fstack with GameTooltip:SetFrameStack
Replace the Lua EnumerateFrames walk with the engine method, as Blizzard_DebugTools does. /fstack also accepts "true" for hidden frames. |
||
|
|
1aa5a07823 |
feat(tooltip): add GameTooltip:SetFrameStack, as 4.3.4 does
Mirror 4.3.4's CGTooltip::SetFrameStack: walk the engine frame list,
hit-test the layout rect against the cursor, name each frame the way
4.3.4 does, sort by strata and level, and fire the new
OnTooltipSetFrameStack script before Show. Every input already exists
in 1.12; the new offsets are verified against the binary.
GetMouseFoci now replays the engine's mouse-focus pass instead of
calling Lua getters: it walks the per-strata mouse input queues and
calls the engine's hit test, so hit-rect insets and scroll clipping
apply as they do for GetMouseFocus.
Also fix the FUN_REGION_GET_RECT comment: the rect is
{bottom, left, top, right}, not {top, left, bottom, right}.
|
||
|
|
00f32e0e2f |
feat(xml): load <Attributes> on frames, as 4.3.4 does
4.3.4's CSimpleFrame::LoadXML reads an <Attributes> child through LoadXML_Attributes; 1.12's frame loader (FUN_XML_FRAME_LOAD) walks its child elements and silently skips the unknown one, so ported templates lost every attribute. Each <Attribute name= type= value=> is now set the way 4.3.4 sets it: type nil/boolean/number/string (default), converted with the loader's own helpers (FUN_XML_ATTR_TO_BOOL, new FUN_SSTR_TO_FLOAT), stored without firing OnAttributeChanged (through our SetAttributeNoHandler, so unit/type* behave as when set from Lua), and malformed entries logged through the loader's status sink with 4.3.4's warning texts (VTBL_XML_STATUS_ADD, level 1). FUN_XML_FRAME_LOAD was already hooked by Xml::ParentKey, and MinHook takes one hook per address, so Xml::FrameLoad now owns it and fans out after the engine loads each node (the RunnerHook / WorldTick pattern). ParentKey's frame binds and the attribute loader subscribe; its node helpers and loader-safe wrapper push moved there too. OFF_COBJECT_LUA_REGISTRY_REF duplicated OFF_COBJECT_LUA_REF (both 0x08) and is folded into it. Verified in-game with a test addon: template attributes inherited and overridden by the frame's own, number / boolean / nil types, a mixed- case name, values present by OnLoad, no OnAttributeChanged on load, and the three FrameXML.log warnings. |
||
|
|
5537432662 |
docs(frame): describe 4.3.4's attribute and mouseover behavior
OnAttributeChanged takes (self, name, value) and nested changes fire their handlers; mouseover follows SecureButton_GetModifiedUnit; the 3-arg GetAttribute and SetAttribute's required value. Drops the implementation paragraphs. |
||
|
|
5962ccc83d |
fix(frame): follow 4.3.4's attribute system and unit-frame mouseover
Compared against 4.3.4's CSimpleFrame attribute code and CGWorldFrame::OnLayerUpdate: - OnAttributeChanged gets (self, name, value) as real arguments, like 4.3.4's RunOnAttributeChangedScript, plus the this/arg1/arg2 globals. It used to fire through the no-argument invoker with globals only, so a modern function(self, name, value) saw name == nil. The engine's runners only carry %d/%s values, so Frame::ScriptArgs gains RunWithValues for arguments already on the Lua stack. - No recursion guard: a handler that sets attributes fires their handlers too, as in 4.3.4. The guard silenced every nested OnAttributeChanged on every frame. - SetAttribute requires the value argument; the 3-arg GetAttribute form needs exactly four arguments and treats a nil prefix/suffix as empty; usage errors name the frame like the engine's (GetName ?: <unnamed>). - The mouseover unit of a hovered frame comes from FrameXML's SecureButton_GetModifiedUnit, pcalled under the engine's error handler, as 4.3.4 does, so unitsuffix and modifier-qualified unit attributes count. 4.3.4 asks protected frames; with no protection in 1.12 the analog is a frame that has attributes. The mouseover tooltip stays (4.3.4 shows it only over the world frame). - SecureStateDriver.lua is 4.3.4's file again: it drives itself through SecureStateDriverManager attributes and reads OnUpdate's elapsed, both of which the guard and the old no-argument handlers had ruled out. - Game::Lua::ObjectLuaRef / PushObject / ObjectDisplayName replace the copies in ScriptArgs and Modern. Verified in-game: handler arguments and globals, a nested handler firing, both usage errors, the nil-prefix lookup, mouseover following shift-unit / unit, and a visibility state driver. |
||
|
|
f5acea6060 |
fix(coroutine): follow 4.3.4's coroutine library
Compared against 4.3.4's stock Lua 5.1 co_funcs (lbaselib.c), opened by
luaopen_base in FrameScript_Initialize:
- status: a coroutine mid-resume of another one is "normal", not
"suspended". Test what the engine's own resume body (0x006F67B0)
tests - ci > base_ci AND CI_YIELD on the CallInfo - instead of
ci > base_ci alone. Resuming it now fails with 5.1's "cannot resume
normal coroutine".
- running: push the thread with the exec-context field set, as every
engine push does; it was left as whatever the stack slot held, which
lua_pushvalue copies into the script context. The main thread is read
from G->mainthread (+0x50, set by f_luaopen) instead of an L captured
at registration.
- Registered on the glue state too.
- 5.1's error texts ("cannot resume %s coroutine"); too many arguments
or results raise, and the results check reserves the slot for true.
- wrap re-raises a non-string error object unchanged through the raw
lua_error (LUA_RAW_ERROR, 0x6F4440); a string still gets luaL_where.
Verified in-game: "normal" status and its resume error, the lifecycle
and running(), an error in the body is not read as a yield, and the
wrap error text.
|
||
|
|
a86f1219c3 |
fix(frame): follow 4.3.4's HookScript, so a hooked handler keeps its args
HookScript's HookThunk was a C closure, which Frame::ScriptArgs treats as
wanting no positional args, and it called the old handler with none - so
a modern SetScript("OnShow", function(self) ... end) saw self == nil as
soon as anything hooked it. It also padded the hook to 9 args and only
detected OnEvent by exact case.
Follow 4.3.4's FrameScript_Object::HookScript instead:
- an unset script gets the hook itself, so GetScript returns it;
- a set one gets the same wrapper hooksecurefunc installs (4.3.4 uses
FrameScript_HookWrapper for both), exposed via HookSecureFunc.h: the
old handler and the hook get the script's own args, and a hook error
goes through the engine's script error handler.
ScriptArgs' HandlerWantsArgs looks inside that wrapper (C function
compare, upvalues at CClosure +0x10 per lua_pushcclosure), so a hooked
script takes the positional path only when either side declares
parameters. The usage error names the frame as the engine does:
vtable+4 GetName, else its "<unnamed>".
Verified in-game: old and hook both get self; OnEvent gets (self, event)
with no padding; an unset script stores the hook; a three-deep chain;
a hook error is reported after the old handler ran; both error texts.
|
||
|
|
338c6777d6 |
feat(hooksecurefunc): follow 4.3.4's hooksecurefunc
Compared against 4.3.4's Script_hooksecurefunc / FrameScript_HookWrapper (taint bookkeeping aside, which 1.12 has no counterpart for): - The hook runs under lua_pcall with the engine's frame-script message handler as errfunc, so a broken hook is reported like any script error instead of being dropped silently. The original's results still reach the caller. - The wrapper is installed with lua_rawset, so a target's __newindex never runs. The original is still read with lua_gettable, so an inherited method can be hooked. - Registered on the glue state too: 4.3.4 registers it from FrameScript_Initialize, which runs for both states. - 4.3.4's error texts, and its lua_isstring name check, so a number name works. - _G is pushed and inserted at index 1, so both call forms share one layout. The comment saying pushvalue(GLOBALS_INDEX) crashes was written in the commit that fixed LUA_PUSH_VALUE (it pointed at lua_remove); the engine's lua_pushvalue resolves the pseudo-index. The 11.0 unhookable-name list stays. lua_rawgeti moves into Game::Lua now that ScriptArgs is not its only caller. Verified in-game: a hook error is reported and T(3) still returns 3 6; __newindex does not run and an __index method hooks; a number name hooks; all three error texts. |
||
|
|
aeb3bdf07b |
feat(playercache): resolve GetPlayerInfoByName through the engine's name search
C_PlayerCache.GetPlayerInfoByName read only the persistent NameCache, so it returned nothing for every name while that cache was off, even for a player standing next to you. It now resolves the name to a GUID first (Player::Info::GuidFromName): the engine's own by-name search behind TargetByName (party and raid members, including out-of-range ones, then every visible player), then the friends list, then the persistent cache. The result is built from that GUID by the same code as GetPlayerInfoByGUID. The engine search is wrapped once as Unit::Identity::FindGuidByName, which UnitTokenFromName now uses too. |
||
|
|
1caf9fde18 |
feat(luasyntax): give strings 4.3.4's shared metatable
4.3.4 ships stock Lua 5.1, whose createmetatable gives every string one
metatable { __index = string } in G(L)->mt[LUA_TSTRING]. 1.12 differs in
one line of each reader: lua_getmetatable returns 0 for a non-table, and
luaT_gettmbyobj returns nil. Co-hook both so a string reads a per-state
metatable instead, and drop the index-continuation hook that answered
with the string table directly.
getmetatable("") now returns the metatable, so libraries that extend it
(StatLogic: getmetatable("").__index.trim = trim) work, and a replaced
or function __index resolves through the engine's own code. A method
lookup costs what 4.3.4's does: luaH_getstr for "__index", then the
lookup in string.
Verified in-game: getmetatable("").__index == string, methods, nil on a
missing key, extending __index, a function __index, the write / call /
arithmetic errors, tostring, and the kill switch.
|
||
|
|
d496ff2aa7 |
feat(string): string.trim and string.join, as later clients expose them (#94)
* feat(string): string.trim and string.join, as later clients expose them
Later clients put strtrim / strjoin on the string table too (string.split
was already registered), so (" x "):trim() works and libraries capture
them at file scope - AceConfigCmd-3.0 does strtrim = string.trim and then
calls it for every toggle/slash command ("attempt to call a nil value").
Not verified in-game yet: these register the existing strtrim / strjoin
functions a second time, under the string table. The testkit check for
them (string methods, the chars argument, the globals agreeing) runs at
the next login, and I'll add the result here.
* docs(string): document string.split and cite 4.3.4's compat.lua
string.split was registered but undocumented. 4.3.4's compat.lua aliases
all three str* globals onto the string table (str.trim / str.split /
str.join), so name it as the source and list the three the same way.
strsplit takes the separator first, so its method form is called on the
separator.
* fix(string): bind the str* globals to their string-table functions
Each Register* call mints its own closure, so registering one C function
as both strtrim and string.trim gave two values and strtrim ~= string.trim.
4.3.4's compat.lua binds each pair by assignment (gsub = str.gsub, strrev
= str.reverse, str.trim = strtrim, str.split = strsplit, str.join =
strjoin), so the globals now alias the string-table entries by value via
RegisterGlobalAlias, as tinsert already does. Verified in-game:
strtrim == string.trim and ClassicAPI.strtrim == strtrim.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
8b96fccfe9 |
refactor(addons): pass an addon file's name and table as real arguments
4.3.4 hands each addon file (addonName, addonTable) as real call
arguments: LoadAddOn puts one table on the stack and
FrameScript_ExecuteBuffer's wrapper path pcalls every file of the addon
with the name and that table. We injected a source preamble instead,
`local arg={"<Name>", __addonns("<Name>"), n=2};`, backed by a gated
global.
An addon file that uses `...` now compiles as a vararg function, and
the file loader gets a C closure that calls it with the name and the
addon's table. The __addonns global and its one-shot gate are gone.
Only the immediate-run file funnel gets the closure, never loadstring,
whose chunkname is forgeable; GetAddOnLocalTable reads the same table.
|
||
|
|
9d3bdfb6ad |
feat(focus): follow 4.3.4's focus, and give every unit event to focus, nameplates and marks
Every unit event the engine fires now reaches focus, nameplateN and
markN, as 4.3.4 does for its focus: the unit gets a script-registration
bit, so the engine watches its fields, and whatever the engine fires
for the unit fires for the token too.
- A co-hook on the registration recompute (FUN_0060c520) keeps bit
0x8000 on units with one of these tokens. Post-init runs it too, so a
unit coming back into range is watched again. 0x2000 is SuperWoW's
and WeirdUtils' sparkle bit on every unit.
- nampower replaces the broadcast (0x00515E50) and the combat feedback
(0x00494600) with detours that never call the original, so neither
can be co-hooked. Their 38 + 4 CALL/JMP sites, which no loaded DLL
touches, are redirected to functions that call the original address
and then fire for the unit's tokens. Sites are found by a .text scan
and patched only when the counts match Ghidra's xrefs.
- The tokens gain UNIT_COMBAT, UNIT_NAME_UPDATE, UNIT_PORTRAIT_UPDATE,
UNIT_MODEL_CHANGED, UNIT_CLASSIFICATION_CHANGED and group-stat
updates. TokenObserver now serves only focustarget: with SuperWoW
every unit is engine-watched, so an observer would double-fire.
Focus drop rules follow 4.3.4 where 1.12 has the data: out of range is
kept for you, your pet, a party or raid member or their pet (the
engine's own target rule); death while not friendly, or arrival already
dead and not friendly; becoming not selectable. Death and the flag act
on the change. 1.12 has no duel exception and no SMSG_BREAK_TARGET.
%f in sent chat (4.3.4's ChatParserParseText) becomes the focus's name,
with a {rtN} prefix when marked, or FOCUS_TOKEN_NOT_FOUND.
The .text bounds move into Offsets.h (shared with interface/Export).
The focus still survives /reload; focustarget events stay as a
ClassicAPI extension.
|
||
|
|
42d037f080 |
fix(text): lay out inline-icon lines the way 4.3.4 does
Chat lines with icons ran past the frame edge after
|
||
|
|
af4a379311 |
feat(equipmentset): follow 4.3.4's equipment manager
UseEquipmentSet now behaves like 4.3.4's CGEquipmentManager: - in combat only the weapon slots swap (one COMBAT_SWAP message); - missing items and full bags report through UI_ERROR_MESSAGE; - bank items are used only while the bank is open, and then equip straight from the bank; - a swap in flight or an item on the cursor refuses the call. EQUIPMENT_SWAP_FINISHED now fires when the swap settles instead of during the call: success when the paperdoll matches, failure on an SMSG_INVENTORY_CHANGE_FAILURE for one of the moved items, or when the paperdoll stops changing short of the target. Its failure value is nil, not 0. CanUseEquipmentSets and the set buttons are blocked meanwhile. GetEquipmentSetInfo uses 4.3.4's GetSetStatus counts and strict IsSetEquipped; GetItemIDs and GetItemLocations return all 19 slots with the 0/1/-1 markers; set buttons also grey when a replaced item is locked. Set names go through a port of ScrubString. Item tooltips get the "Equipment Sets:" line (dontShowEquipmentSetsOnItems hides it). |
||
|
|
2b9d0e7127 |
fix(player): fire HEARTHSTONE_BOUND on SMSG_PLAYERBOUND
The server re-sends SMSG_BINDPOINTUPDATE at login and on every map change, which needed two gates to filter out. SMSG_PLAYERBOUND (0x158) is sent only from the bind spell effect, right after the bind-point update, so it needs no filtering. 1.12 handles it in the shared player packet handler FUN_005E38C0. Subscribe through Net::PacketDispatch instead of hooking the bind-point handler, which drops one MinHook and the two unused offsets. |
||
|
|
a68fb0a6be |
fix(frame): keep a scroll child clipped when its ScrollFrame moves (#60)
* fix(frame): keep a scroll child clipped when its ScrollFrame moves A frame a ScrollFrame draws carries a "scrolled" flag (0x2000 at +0xB4): the strata pass skips it and the ScrollFrame draws it inside a viewport cut to its rect. SetScrollChild sets the flag through the setter at 0x0076A400, which also marks the scroll child (0x4000) and recurses into child frames. SetParent sets a moved frame's flag from its new parent through the same setter, and the recursion doesn't stop at a ScrollFrame, so moving a frame that holds a ScrollFrame under an unscrolled parent cleared the flag on the scroll child and everything in it. The strata pass then drew them whole, past the ScrollFrame's edges. AceGUI-3.0 builds each widget under UIParent and then moves it into its container, so every AceGUI ScrollFrame spilled: AceConfigDialog-3.0's pages drew below the Interface Options window (61 frames under Zygor Guides Viewer 2.0's "Display" scroll child had lost the flag). Hook the setter to keep a frame marked as a scroll child scrolled when a value is only being passed down (third argument -1). SetScrollChild's own calls are unchanged. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): AceConfigDialog-3.0's Interface Options pages clip and scroll inside their box; on the "Display" page no frame under the scroll child lacks the flag any more (61 did before), and a ScrollFrame built under UIParent and then moved keeps its content, its content's children and a child added afterwards scrolled. * docs(frame): describe ScrollFrame clipping without version history State what stays clipped and when, with AceGUI-3.0 as the case it serves. Remove the vanilla comparison and the engine flag explanation; the comment in src/frame/ScrollChildren.cpp already records them. * fix(frame): skip scroll children the way 3.3.5's setter does 3.3.5's CSimpleFrame::SetBeingScrolled (0x00490F60) does not pass the scrolled value into a child frame marked as the scroll child, and its direct call is not gated: a scroll child that is itself given a new parent takes the new parent's value. The hook forced any scroll child scrolled on a pass-down call, which also kept a directly reparented scroll child clipped to its old ScrollFrame. Skip a scroll child only inside the setter's own recursion, told apart by a depth counter (the setter is its only nested caller). SetParent's and SetScrollChild's direct calls run unchanged. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
721f32ac77 |
feat(map): keep the closed world map on the player's zone (#71)
* feat(map): keep the closed world map on the player's zone
GetPlayerMapPosition("player") reads the map the world map is set to,
open or closed, and returns 0,0 off it. The 3.x FrameXML resets that
map to the player's zone in WorldMapFrame_OnHide and in WatchFrame's
PLAYER_ENTERING_WORLD and (map closed) ZONE_CHANGED_NEW_AREA handlers;
vanilla has neither, so after zoning the closed map stays on the old
zone. Do the same resets from the bundled addon. Zygor Guides Viewer's
travel steps read the player's position this way.
Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0):
after logging in, the closed world map is on the player's zone (Darkshore)
and GetPlayerMapPosition("player") returns the player's position there.
Not checked yet: changing zones with the map closed (the
ZONE_CHANGED_NEW_AREA reset) and closing the map on another zone (the
OnHide reset).
* docs(map): describe the closed world map without version history
State what the map does and when it goes back to the player's zone,
and add that a zone change does not move the map while it is open.
Remove the 3.x and vanilla comparison and the FrameXML handler names;
the code comment in Util/WorldMap.lua already records them.
* docs(readme): keep Highlights for major features
Single-behavior fixes (faction while loading, <Script file> paths, the
closed world map, the quest completed line, SetParent frame levels,
frame alpha, OnSizeChanged sizes) each had a row in the Modern client
behaviors table. Remove those rows and point to docs/API.md, where each
fix keeps its own section.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
fcdc24471c |
fix(spell): latch remote channels on +0x228 like the player's
The broadcast +0x228 field lags another unit's channel start by up to ~1 s, and UnitChannelInfo returned nothing until it caught up. So the UNIT_SPELLCAST_CHANNEL_START it fires from the SMSG_SPELL_START stamp disagreed with the getter, and cast bars that poll on the event (pfUI nameplates) missed the channel whenever the field was late. Mirror the player's confirmed latch per remote channel: the packet stamp stands until the field has shown the spell, and a confirmed field that clears before endMs is the channel ending early. That drops the entry and fires CHANNEL_STOP, where it used to run out the full computed duration (no packet reports a remote interrupt on Turtle). |
||
|
|
58f5b4f78e |
fix(spell): keep remote channel times through the SPELL_GO cast-slot clear
The engine's SPELL_GO handler calls ClearCastingSpell on the caster for every spell, including a channel at the moment it starts. Our co-hook treated that as an abort and evicted the SMSG_SPELL_START cache entry, so UnitChannelInfo never had start/end times for another unit's instant channel (bandages). ClearCastingSpell only ends the cast slot; a channel's lifetime is the +0x228 field UnitChannelInfo already gates on, so that route no longer evicts channel entries. The failure packets still do. Fixes #102 |
||
|
|
6be4aac9fb |
feat(macro): resolve every macro's display the way 3.3.5 does
Compared Macro::ShowTooltip against 3.3.5's decompiled MACRONODE::Parse, FindSpellID and GetFullIconPath (WoW/Source/Ui/UIMacros.cpp) and fixed the differences: - Every macro body is parsed, directive or not. A question-mark macro with no #show now shows its first action's icon, and its button follows that action's cooldown, count and usable state; the tooltip stays the engine's (Kind::Implicit). #show counts anywhere in the body, not only on line 1. - "#showtooltip none" stops the parse: the macro keeps its own icon and holds no spell, instead of greying out. - /castrandom and /userandom show their first entry (3.3.5 cuts the value at the first comma); they used to grey the button. - /equip and /equipslot lines are collected and resolve to items only. - Bare numbers 1..23 are inventory slots, the equipped bags included. Edits now always end in a repaint, as 3.3.5's EditMacro does: the engine repaints a macro's buttons straight after its parse, before our rescan, so a re-parsed body is marked and repainted on the next tick, and a reader's catch-up defers its repaint instead of firing ACTIONBAR_SLOT_CHANGED from inside a button handler. Implicit macros are also parked across the unlearn sweep, so a condition-picked value can't delete a macro from the bar. |
||
|
|
a6270469e1 |
refactor(chatbubble): move the bubble list offsets into Offsets.h
C_ChatBubbles.GetAllChatBubbles defined the engine's bubble list head (0x00B6F038) and link offset (+0x318) as file-local constants. Move them to Offsets.h as VAR_CHAT_BUBBLE_LIST_HEAD / OFF_CHAT_BUBBLE_LINK_NEXT, documented as 3.3.5's CGChatBubbleFrame list and the engine walks they mirror. No behavior change. |
||
|
|
a8f73623c4 |
perf(nameplate): enumerate the engine's shown-plate list, not every object
NamePlate::Walk walked the whole object hash table every frame (and on every C_NamePlate.GetNamePlates call) to find units with a plate. 1.12 keeps the same shown-plate list as 3.3.5's s_namePlates (head 0x00C4D92C, next at plate+0x4E0), each plate carrying its unit's GUID (+0x4E8). Walk that list and resolve each plate's unit by GUID, as the engine's own NamePlateClearAll (FUN_0060F890) does; a plate still counts only while unit+0xE60 points back at it. PlateReassigned becomes one read of the plate's GUID instead of a scan of the tick's snapshot. GetNamePlates now returns the engine's order (farthest from the screen centre first). The old comments claiming the list was unsafe to read and that release callers "transiently zero +0xE60" are replaced: the list is re-sorted only by main-thread engine code, every plate on it is bound, and every FUN_00608A10 caller is a real release. |
||
|
|
47b258ad95 |
fix(text): size, space and align inline icons by the engine's own rules
The inline-texture backport placed icons with hand-tuned constants: a 0.18 x font lead/trail pad, a 0.6 x font vertical centre, a -1px region nudge, and written sizes taken as raw screen pixels. Replace all of them with the rules from the 3.3.5 / 4.3.4 clients (decompiled; the size formula's helpers confirmed against the real 4.3.4 binary): - A written size multiplies by fontPx / (14 x ddcWidthScale), so it follows the text's size, the UI scale and the resolution, and then by the fontstring's layout scale, as 3.3.5 does. Size defaults follow ParseEmbeddedTexture: ":0:2" is a width ratio, ":20:0" is font-wide. - An icon starts at the previous glyph's ink edge (bearing + cell width) plus the face's outline gap, found by replaying the run's placements with the emitter's own glyph helpers; the next glyph starts at the rounded icon edge. - Vertical alignment follows the node's justify-V (node+0x50). - Offsets move only the drawn icon; a positive offsetY now moves it up. GetCoinTextureString now matches 3.3.5: default height 14, a space between denominations, and retail's 2:0 coin offset in the strings. The four Coordinate statics at 0x00832A40 get their real names (VAR_COORD_DDC_WIDTH_SCALE and siblings). Known gap: the fs-level wrap callers can't see the fontstring, so they budget icons at layout scale 1. |
||
|
|
ac6bd552d5 |
fix(addons): rebuild the file index with the engine's own clear on /reload
Rescan re-ran the boot indexer on two subtrees, which only adds files, and skipped its whole run when the index's built latch was 0. The SavedVariables unload pass clears that latch whenever it writes a new SV file, so on that /reload no new folder, metadata change or display-array rebuild happened. Call FUN_VFS_INDEX_CLEAR (0x00646FC0) instead - the clear the engine itself uses after its own file writes - and drop the latch gate. The next lookup rebuilds the index from disk, so deleted files drop out too. AddOns::Toc::FindValue now matches lines the way the TOC parser does: skip a UTF-8 BOM, break lines at CR or LF, and accept any spaces after "##" before the key, which must be followed directly by ':'. Callers pass the bare key. Also correct the notes that said a first-ever SavedVariables file stays unreadable until restart; the engine's unload pass already handles it. |
||
|
|
2a05baee8d |
feat(cvar): GetCVar returns nil for an unknown cvar (#82)
* feat(cvar): GetCVar returns nil for an unknown cvar
Later clients return nil from GetCVar for a name they do not know; vanilla
raises "Couldn't find CVar named '<name>'". Ported code uses the nil as
a feature probe - LibCamera-1.0 opens with
if not GetCVar("cameraYawE") then return end, which throws at file load
on vanilla.
Co-hook Script_GetCVar: a string name that FUN_FIND_CVAR (the lookup
Script_GetCVar and C_CVar.DoesCVarExist share) does not find yields nil.
Everything else, including non-string arguments, runs the engine function
unchanged. The glue state registers the same function, so both match.
Verified in-game (1.12.1 client via VanillaFixes): GetCVar with an unknown
name returns nil at file load, without an error.
* feat(cvar): GetCVarDefault stops raising for an unknown cvar
Script_GetCVarDefault has the same isstring -> tostring -> FUN_FIND_CVAR
-> raise shape as Script_GetCVar, so it gets the same co-hook. Both now
return no values for an unknown name, matching 1.15.9 (`/dump` prints
"empty result" for each) instead of a single nil.
Docs: describe behavior only, without version or vanilla-gap notes.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
80ef0e2988 |
feat(lua): give modern XML handler bodies their implicit parameters (#84)
* feat(lua): give modern XML handler bodies their implicit parameters
Later clients compile an XML handler body as a function whose parameters
name the script's arguments - self, then elapsed / button, down /
event, ... and so on. Vanilla compiles it as a zero-parameter chunk and
publishes the frame and arguments only through the this / argN globals,
so a ported <OnLoad>self:Foo()</OnLoad> indexes a nil global.
Zygor Guides Viewer 2.0 has 85 such bodies; 13 fail at load.
For a chunk compiled by the XML script funnel FUN_00704C70 (return
address 0x00704C8C, engine-built chunkname "<Frame>:<Script>") whose body
reads self - or reads one of its script's parameter names and none of
this / argN - wrap it as return function(self, <names>, ...) ... end,
reusing the vararg path's materialize-the-inner-function shape.
Frame::ScriptArgs already pushes (self, arg1..argN) in that order. Vanilla
bodies are untouched, so FrameXML and 1.12 addons keep their globals and
no names are shadowed.
`event` alone doesn't trigger the wrap. Vanilla sets a global `event`
during OnEvent dispatch, so FrameXML's own
<OnEvent>ActionButton_OnEvent(event)</OnEvent> bodies (about 250) already
work; a body that also reads self still gets (self, event, ...), which
binds the same value.
Adds RET_LUA_SCRIPT_COMPILE (found by scanning FUN_00704C70 for the E8
call to luaL_loadbuffer; the same scan reproduces RET_LUA_FILE_COMPILE),
an XmlHandlerArgs transpile toggle, and a 6th _classicapi_TranspileStats
return counting wrapped handlers.
Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0):
probe XML bodies see self in OnLoad, elapsed in OnUpdate, button in
OnClick ("LeftButton") and event in OnEvent; Zygor's bodies load without
an error, and 112 of the 36,627 chunks compiled that session were wrapped.
* fix(lua): match 3.3.5's handler parameters; treat ... as a modern body
OnSizeChanged binds (self, w, h), as 3.3.5's wrapper does, not
(self, width, height); the table now names its 3.3.5 source.
A handler body with a ... expression is wrapped with its named
parameters. Lua 5.0 can't compile one, so only a body written for later
clients has it, and the plain vararg wrap gave an OnEvent body's ...
(self, event, args) instead of the arguments after event.
The docs list each script's names and drop the version history, and say
the values need SetModernScriptArgs on.
* fix(frame): pass OnSizeChanged the size in GetWidth/GetHeight units
FUN_FRAME_ON_SIZE_CHANGED (0x0076B660), the only code that fires
OnSizeChanged, pushed the frame's screen-rect size in raw layout units:
a 20 x 10 frame's handler saw (0.0092, 0.0046). 3.3.5 divides out the
frame's layout scale (OnFrameSizeChanged, 0x0048FA20) and converts with
the chain 1.12's own GetWidth uses (Game::InternalToPixel) before the
script runs.
A co-hook now does both: convert, then divide by the frame's effective
scale (OFF_REGION_EFFECTIVE_SCALE). Verified in game at a 0.91 UI
scale: (19.99993, 9.99997) against GetWidth/GetHeight's (20, 10).
Converting alone gave (18.2, 9.1). The vmethod uses the values for
nothing else, and neither stock FrameXML nor any installed addon reads
OnSizeChanged's arguments.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
5df5ce00cf |
fix(xml): resolve <Script file> subdirectory paths relative to the XML file (#80)
* fix(xml): resolve <Script file> subdirectory paths relative to the XML file The XML file processor joins <Include file> onto the including file's directory, but <Script file> only when the value has no backslash (strchr at 0x006EE06E); a value with one is loaded from the game root. So <Script file="widgets\AceGUIWidget-Button.lua"/> inside Libs\AceGUI-3.0\AceGUI-3.0.xml fails with "Error loading widgets\AceGUIWidget-Button.lua" - all 23 AceGUI-3.0 widget files in Zygor Guides Viewer 2.0, and every other addon that embeds AceGUI-3.0. Later clients resolve it relative to the XML file. Co-hook the XML file processor (FUN_XML_LOAD_FILE) to track the file being processed, and at the <Script> call into FUN_LUA_LOAD_FILE (return address RET_XML_SCRIPT_FILE_LOAD) retry a backslash path that does not exist as given against that file's directory, only when the joined file exists. Root-relative paths that load on vanilla are unchanged. FUN_LUA_LOAD_FILE is already co-hooked by AddOns::SavedVarsFirst, which now calls Xml::ScriptPath::Resolve first. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): a probe addon's <Script file="sub\File.lua"/> loads from its XML file's folder, and Zygor's AceGUI-3.0 option pages, built from those widget files, work. * refactor(xml): share the Lua file-loader hook; collapse .. in Script paths FUN_LUA_LOAD_FILE now has one owner, Script::LoadFile, which runs path rewriters and then suppressors. Xml::ScriptPath is a rewriter and AddOns::SavedVarsFirst a suppressor, so neither module reaches into the other's hook. Xml::ScriptPath joins onto the XML file's folder with each \..\ collapsed first, as FUN_XML_LOAD_FILE does before its own joins; the tracked pointer is the caller's uncollapsed path, so an XML file reached through <Include file="..\x.xml"/> joined onto a path with .. in it. The user docs no longer name later clients or what 1.12 does. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
1297b9522a |
feat(macro): accept a macro name in GetMacroInfo/EditMacro/PickupMacro/DeleteMacro (#96)
* feat(macro): accept a macro name in GetMacroInfo/EditMacro/PickupMacro/DeleteMacro
2.0+ clients take `index or "name"` in all four; vanilla raises
"Usage: DeleteMacro(index)" (etc.) for a name. Co-hook each script
function: a non-numeric string first argument becomes the macro's
1-based index via FUN_MACRO_NAME_TO_SLOT (the GetMacroIndexByName
resolver), and an unknown name becomes 0, which each original treats
like any out-of-range index (GetMacroInfo returns nils, the others do
nothing). Zygor Guides Viewer clears its scratch macros with
DeleteMacro("ZygorGuidesMacro" .. i) every time a step starts.
Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0):
an unknown name is a no-op in all four, and Zygor's DeleteMacro calls on
every step start run without an error. The known-name path hasn't run
in-game yet: the test character has no macros.
* docs(macro): say what EditMacro returns for an unknown macro name
An unknown name leaves EditMacro returning the first empty slot's index
(or 0 when every slot is full), the same as an out-of-range index and as
3.3.5; the section said all three non-GetMacroInfo functions "do
nothing". Also drop the patch-version mention.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
b3188ced2a |
feat(tradeskill): add GetTradeSkillRecipeLink and IsTradeSkillLinked (#75)
* feat(tradeskill): add GetTradeSkillRecipeLink and IsTradeSkillLinked GetTradeSkillRecipeLink(index) links the recipe in a trade-skill row as an enchant: link carrying the recipe's spell ID, in the form the client's own GetCraftItemLink (0x004F72A0) gives an enchanting formula (|cffffffff|Henchant:%d|h[%s]|h|r, format at 0x0084D410), with the spell's name in the client's locale. Rows are read as the engine's row functions read them, so a header row (spell ID -1) returns nothing. Vanilla's window only links the item a recipe makes. IsTradeSkillLinked() returns nil: on this client the trade-skill window and its functions only describe the player's own professions, since a received trade: link opens ClassicAPI's separate viewer. Zygor Guides Viewer 2.0 calls both on TRADE_SKILL_SHOW to record the recipes the player knows. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): in the First Aid and Cooking windows, all 15 recipe rows link the row's own spell (checked against GetSpellInfo) and header rows return nothing; IsTradeSkillLinked() returns nil. * fix(tradeskill): match 3.3.5's GetTradeSkillRecipeLink and show its links GetTradeSkillRecipeLink now builds 3.3.5's link: gold, "Profession: Recipe" (the profession from the engine's SkillLineAbility lookup FUN_006de040, for the player's race and class), gated on SPELL_ATTR_TRADESPELL. Empty names are pushed as the record holds them, and the index is checked as a double before the cast, the way the engine truncates and compares unsigned. IsTradeSkillLinked returns (nil, nil), as 3.3.5 does. Both globals get doc descriptors. 1.12's SetHyperlink accepts enchant: only for records with +0x0C == 3, which no trade-skill recipe has, and raises "Unknown link type" for the rest. Tooltip::Hyperlink now shows the spell tooltip for a trade-spell enchant: link, as 3.3.5 does. That also fixes clicking SuperWoW's GetTradeSkillItemLink(index, 1) links; its SetHyperlink patch at 0x00532210 runs after this co-hook and handles only quest:. SPELL_ATTR_TRADESPELL moves to Offsets.h now that two files use it. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
f55893fdf4 |
feat(frame): Button:Set/GetNormalFontObject and Frame:IsProtected (#93)
* feat(frame): Button:Set/GetNormalFontObject and Frame:IsProtected - button:SetNormalFontObject / GetNormalFontObject: 3.0's names for vanilla's SetTextFontObject / GetTextFontObject; delegate to them. Zygor Guides Viewer 2.0 and AceGUI-3.0 call the new names. - frame:IsProtected() returns false, false: vanilla has no protected frames (the secure system arrived in 2.0). AceHook-3.0 asks before hooking scripts. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): Zygor sets its guide window's tab fonts with SetNormalFontObject while it builds, without an error. Not yet checked: that the font set reads back through GetTextFontObject and the reverse, and IsProtected's two values; the testkit check for those runs at the next login. * docs(frame): drop version and implementation notes from the new methods The SetNormalFontObject and IsProtected sections named the patches the APIs came from, said what 1.12 lacks, and described how the methods are implemented. User docs describe the contract only. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
e0b2e56070 |
feat(frame): multiply frame alpha into child frames, as 3.x does (#70)
* feat(frame): multiply frame alpha into child frames, as 3.x does A frame now draws at its own alpha times its parent's drawn alpha, and GetAlpha returns the frame's own alpha. Vanilla keeps one alpha per frame and copies it into the children that exist when SetAlpha runs: - an XML frame with alpha="0" drew its child frames at full alpha, because the attribute is applied before its <Frames> are built; - a child's own alpha was overwritten whenever its parent's changed; - a frame created or reparented under a transparent frame drew opaque. Zygor Guides Viewer's border glow is the first case. It is an alpha="0.0" frame whose child holds the glow textures, so on vanilla the glow covered the guide frame from login until the first step flash. Co-hooks the engine's alpha setter, SetParent, the frame destructor and frame GetAlpha. Own alpha lives in a table keyed by frame. The engine's byte holds the drawn value, so region recolors and the Model family's model alpha read it unchanged. Children are recomputed through their own vtable setter, as the engine's copy-down calls it. Vanilla code that shows a child under a transparent parent (parent:SetAlpha(0); child:SetAlpha(1)) now leaves the child hidden, as 3.x does. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): Zygor's guide frame no longer shows its border glow from login. With own alphas 0.5 / 0.8 / 1.0, a child and a grandchild draw at 0.4; the child of an XML frame with alpha="0" keeps its own 1.0 and draws at 0; a child keeps its own 0.5 while its parent goes to 0.2 and back to 1; a frame with its own 0.6 draws at 0.3 under a 0.5 parent and at 0.18 once moved under a 0.3 one. * fix(frame): match 3.3.5's effective-alpha math and read it from the byte - Multiply child alpha by truncating (a*b/255), as 3.3.5's CSimpleFrame::UpdateAlpha and GetEffectiveAlpha do, instead of rounding. - GetEffectiveAlpha reads the frame's alpha byte, which Frame::Alpha keeps at the drawn value, instead of multiplying GetAlpha up the parent chain. This is 3.3.5's Script_GetEffectiveAlpha. Drops the now-unused FUN_SCRIPT_REGION_GETPARENT. - Drop the reload cleanup of the own-alpha table. The frame destructor hook already removes each frame's entry, and a frame that outlives a /reload would have lost its own alpha. - Rewrite the API.md frame-alpha and GetEffectiveAlpha sections as user-facing behavior. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
20dc9fc962 |
fix(frame): move a frame's children along when SetParent sets its level (#61)
* fix(frame): move a frame's children along when SetParent sets its level Vanilla's SetParent gives the frame its new parent's strata and level + 1, but calls the level setter without its children flag, so the frames under it keep the levels they had. A panel built on its own and then moved into a raised window draws its contents behind that window: Zygor Guides Viewer 2.0's AceConfigDialog-3.0 panel in the Interface Options window had its widgets at levels 1-4 under a window at level 5. Hook the level setter (0x0076A4F0) and pass the children flag on SetParent's two calls, recognized by their return addresses. The setter then moves each same-strata child by the same amount, recursively. Script SetFrameLevel and the setter's other callers are unchanged. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): the AceConfigDialog-3.0 panel's widgets draw above the Interface Options window, and none of its 18 frames sit below the window's container any more. A frame with a child and a grandchild moved under a level-20 frame sits at 21/22/23, and at 0/1/2 once moved to no parent. * refactor(frame): patch SetParent's children flag instead of hooking the setter The two `push 0` that pass the level setter's children flag from SetParent become `push 1`, which is what 3.3.5's SetParent passes. This drops the MinHook on the level setter, which 11 call sites share, and the return-address checks. Each site's bytes are checked before the write, as in Quest::CompleteMessage. Docs: describe only the current behavior in API.md and the README row. Verified in-game: a frame with a child and a grandchild moved under a level-20 frame sits at 21/22/23, and at 0/1/2 once moved to no parent. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
51d226f67d |
feat(tooltip): SetHyperlink takes full links and spell:/quest: links (#68)
* feat(tooltip): SetHyperlink takes full links and spell:/quest: links
Vanilla's GameTooltip:SetHyperlink matches only a bare `item:` or
`enchant:` payload and raises "Unknown link type" for anything else,
including the full |cff..|H..|h[..]|h|r links 2.0+ GetItemInfo and chat
hand out. Co-hook it:
- a full link is reduced to the payload between |H and |h;
- spell:<id> builds the SetSpellByID tooltip;
- quest:<id> shows the cached title and objectives text (tokens
expanded by the engine's quest-text substituter); an uncached quest
leaves the tooltip empty and queues the quest query once;
- everything else runs the engine function on the payload.
Quest::Cache::Lookup gains `unique`, the engine's own dedup flag (the
last _GetRecord argument, previously passed as an unused 0), so a
tooltip redrawn every frame waits on one queued callback.
Zygor Guides Viewer reads quest titles with
SetHyperlink("|Hquest:<id>:1|h[q]|h") and item names with full links.
Verified in-game (1.12.1 client via VanillaFixes): on a
GameTooltipTemplate tooltip, a full Hearthstone link shows Hearthstone's
tooltip, "spell:133" shows Fireball's, and "quest:957" shows Bashal'Aran's
title and objectives.
* refactor(tooltip): share the C tooltip line helpers; tidy SetHyperlink
- Add tooltip/Lines.h (Clear / Add / Show over the engine's tooltip clear,
raw add-line and Script_Show) and use it in place of the four local
copies in Hyperlink, CompareItem, totem/Tracker and equipmentset/Tooltip.
EquipmentSet keeps its exact colors as packed constants.
- SetHyperlink quest colors come from UI::ColorData (HIGHLIGHT_FONT_COLOR,
NORMAL_FONT_COLOR) instead of hand-packed doubles.
- spell:<bad id> now clears the tooltip, like quest:<bad id>, instead of
leaving the previous tooltip's lines.
- Rewrite the SetHyperlink API.md section in plain English without version
or vanilla-gap notes.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
eb3c32094c |
feat(pvp): add IsActiveBattlefieldArena (#77)
* feat(pvp): add IsActiveBattlefieldArena Stock 1.12 has no arenas, so it answers nil there. Turtle-lineage clients add arena matches, run in instances IsInInstance reports as "pvp": in a "pvp" instance their scoreboard asks for arena scores over the hidden TW_ARENA channel, only an arena answers, and the scoreboard keeps the reply in WorldStateScoreFrame.arenaData until the world states update outside an instance. isArena follows that state, as the scoreboard's own arena view does (Octo's FrameXML, patch-4.mpq: WorldStateFrame.lua and Turtle_ArenaUI.lua). isRegistered is always nil: the reply has no rated flag, and the client's queue window only joins skirmishes. Zygor Guides Viewer 2.0 calls it, unguarded, to decide whether to set its corpse arrow when the player is dead outside a battleground. Verified in-game (OctoWoW 1.12.1 client via VanillaFixes): outside an instance it returns nil, nil. The arena branch has not been exercised in a match yet. * refactor(pvp): answer IsActiveBattlefieldArena from DBC data in C The Lua version read Turtle's scoreboard state (WorldStateScoreFrame.arenaData), which is nil until the server's TW_ARENA reply lands and depends on Turtle's FrameXML. The client's own data already marks an arena: a pvp-type map (Map.dbc instanceType 3) whose area carries AreaTable flag 0x80, the flag Script_GetZonePVPInfo reports as isArena. Check the zone as well as the subzone, since the arena maps' areas are top-level zones. The type-3 gate keeps the open-world rings (Gurubashi, The Maul) out. Returns booleans, as retail does; isRegistered is always false. Offsets.h: add OFF_AREATABLE_FLAGS, AREA_FLAG_ARENA and VAR_PLAYER_SUBZONE_AREA_ID, and correct the zone-change handler's second argument (the subzone ID, not the parent area ID). * docs(pvp): note the server only ever creates arena map 26 tortoise-wow's GetBattleGrounMapIdByTypeId sends its one arena type, BATTLEGROUND_BR, to map 26 (Blood Ring); map 28 (Lordaeron Arena) is client data only. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
26ca1b4e84 |
feat(quest): print "<quest> completed." for chain quests too (#76)
* feat(quest): print "<quest> completed." for chain quests too The client prints ERR_QUEST_COMPLETE_S on SMSG_QUESTGIVER_QUEST_COMPLETE only for a quest with no next quest in its chain. The handler (and the callback it leaves for a quest not yet cached) skips the message when the cached record's NextQuestInChain (+0x24) is set, so a turn-in in the middle of a chain printed only the experience and money lines. Zygor Guides Viewer 2.0 completes a turn-in step only on that line, so its steps for chain quests stayed open until the next login. NOP the two `jne` over the message (0x005DC4DC, 0x005DC756), after checking the bytes, so every turn-in goes through the engine's own message path: same text, sound and CHAT_MSG_SYSTEM chat type, ahead of the experience and money lines. That later clients print the line for every turn-in is an inference, not read from a later client's binary: the 3.3.5a build of Zygor Guides Viewer completes chain turn-ins on this line the same way. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): mid-chain turn-ins (The Harvest Golem Mystery 40470, The Red Crystal 4811, As Water Cascades 4812, Bashal'Aran 956, Buzzbox 323 1002) print "<quest> completed." and Zygor completes the turn-in step at once; a quest at the end of its chain prints it as before. * docs(quest): the completed line's order depends on the quest cache When the quest record is not cached at turn-in, the callback 0x005DC710 prints the line on the record's arrival: after the experience and money lines, and after QUEST_TURNED_IN. Stop promising a fixed order. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
7331922070 |
fix(build): quote the /DEF path so source trees with spaces link (#59)
* fix(build): quote the /DEF path so source trees with spaces link
CMAKE_SHARED_LINKER_FLAGS passes /DEF:${CMAKE_CURRENT_SOURCE_DIR}/src/ClassicAPI.def
unquoted, so a checkout under a path containing a space (e.g.
C:\Projects\Classic API\ClassicAPI) splits the argument and the link fails
with LNK1181: cannot open input file 'API\ClassicAPI\src\ClassicAPI.def'.
Quote the path; the DLL output is unchanged.
Verified: Release/Win32 build now links from a path with a space.
* fix(build): list the .def as a target source instead of a /DEF flag
CMake now emits a quoted /DEF: on every generator, so the hand-escaped
path in CMAKE_SHARED_LINKER_FLAGS goes away, and the .def becomes a link
dependency: editing an export relinks the DLL instead of needing a clean
build.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
27d8f90f03 |
fix(unit): UnitFactionGroup("player") answers while addons load (#79)
* fix(unit): UnitFactionGroup("player") answers while addons load
Script_UnitFactionGroup resolves "player" through the in-world unit
descriptor, so it returns nil at file scope, ADDON_LOADED and
VARIABLES_LOADED and only answers from PLAYER_LOGIN. UnitName, UnitRace
and UnitClass already answer then, and later clients answer
UnitFactionGroup too, so ported addons read it at file scope. AceDB-3.0
does exactly that to build its "<faction> - <realm>" profile key, and
fails to load on nil ("attempt to concatenate local 'factionKey'").
Co-hook the engine function: when it answers nothing for the "player"
token, fall back to the login-time race byte (VAR_PLAYER_RACE_BYTE) and
the same race -> faction-group chain its player branch uses. That chain
moves out of C_CreatureInfo.GetFactionInfo into a shared
Creature::Info::FactionGroupForRace; GetFactionInfo's behavior is
unchanged. Once the player object exists the engine answers by itself.
Adds FUN_SCRIPT_UNIT_FACTION_GROUP (slot 13 of table 0x00850438).
Measured in-game before the fix (Octo 1.18.1 client, Human):
UnitFactionGroup("player") = nil at file load / ADDON_LOADED /
VARIABLES_LOADED, "Alliance" from PLAYER_LOGIN; UnitName/UnitRace
answer at every stage.
Verified in-game after the fix (same client and character):
UnitFactionGroup("player") is "Alliance" at file load, ADDON_LOADED and
VARIABLES_LOADED, and AceDB-3.0 sets up Zygor Guides Viewer 2.0's saved
settings.
* fix(unit): keep UnitFactionGroup's in-world nil; describe both engine branches
Script_UnitFactionGroup reads the live faction template when the unit's
object is in the world, and only falls back to the name cache's race when
it isn't. The race fallback now runs only under that same condition (no
player object), so an in-world nil (e.g. charmed by a monster) stays nil
instead of turning into the race's faction. Comments and API.md now say
which engine branch the fallback mirrors.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
35ef1228eb |
feat(lua): give each pass of a for loop its own loop variables, as in 5.1 (#66)
* feat(lua): give each pass of a for loop its own loop variables, as in 5.1 Lua 5.0 declares a for loop's variables once for the whole loop (its parser's forbody activates them before entering the loop block), so every function made in the body shares one variable, which is nil once a generic for ends. Lua 5.1 declares them per pass, and 5.1 code relies on it. Zygor Guides Viewer 2.0's recent-guides menu gives each entry `checked = function() return ... guide.full end`; on 1.12 it errored with "attempt to index a nil value" whenever the menu opened. A new transpile pass rewrites such a loop to the 5.1 manual's own equivalent, `for __cf_k, __cf_v in e do local k, v = __cf_k, __cf_v;`, on the same line. It applies only to loops whose body contains a function, and not when the body assigns to a loop variable (5.0 carries that into the next pass and 5.1 doesn't). Chunks whose blocks don't balance are left alone. The trigger scan follows blocks and brackets without allocating. Toggle: "ForLoopScopes". Tested offline on the rewriter's own code: 21 targeted cases, and 1,417 addon and Classic Era FrameXML files (67.7 MB). 184 loops were rewritten, and every rewritten file still compiles under Lua 5.1. The pass adds about 0.03-0.05 s over the whole 67.7 MB. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): the recent-guides menu opens without an error, and functions made in a generic for, a numeric for and a pair of nested loops each return their own pass's values. * refactor(lua): close loop upvalues per pass in the compiler instead of rewriting source Replace the token-scanning source rewrite with a hook on the parser's forbody. Lua 5.0's loop variables are the loop's control registers, and a function made in the body keeps them open until forstat's block ends. Emitting one OP_CLOSE at the end of each pass, before OP_FORLOOP / OP_TFORLOOP, gives each function its own pass's values. The OP_CLOSE is emitted only when a nested function names a loop variable. markupval already records that on forstat's block, so nothing is guessed from tokens. A loop that captures nothing compiles to the engine's exact bytecode. This fixes the gaps in the source rewrite (indexed and dotted targets, `function v()`, nested elseif, long target lists). It adds no locals, so it can't push a function past the 200-local limit, and it adds no scan to every chunk load. Assignment to a loop variable still steers the loop, as stock 5.0 code may rely on. The ForLoopScopes toggle is gone with the rewrite. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
76cc907bd0 |
feat(tooltip): add GameTooltip:AddTexture on the engine's own routine (#67)
* feat(tooltip): add GameTooltip:AddTexture on the engine's own routine
Vanilla has the 3.x tooltip-texture feature built in and unexposed:
GameTooltipTemplate declares <name>Texture1..3, the XML-OnLoad scan
binds them (tooltip+0x34C), FUN_005303D0 lays the next one out on the
last line (sized to the line, text shifted right) and the tooltip clear
undoes it. Nothing in the 1.12 binary calls that routine; expose it as
GameTooltip:AddTexture. The engine's limits stay: three textures per
tooltip, none on the header line. Zygor Guides Viewer adds guide
images to its tooltips this way.
Verified in-game (1.12.1 client via VanillaFixes): on a
GameTooltipTemplate tooltip with two lines,
AddTexture("Interface\\Icons\\INV_Misc_Bag_08") shows <name>Texture1
with that file, and ClearLines hides it again.
* fix(tooltip): repair AddTexture layout around the engine routine
The engine's texture routine was never called before, and its layout has
two defects. The tooltip clear re-anchors the line below a textured line
at (0, 0) instead of the template's 2px gap, so that line sat too close on
every later tooltip from the frame. And every re-anchor replaces the
line's offset, so a second texture on one line, or one on the line right
below a texture, broke the text alignment.
Tooltip::ClearItemGuid becomes Tooltip::Clear: the one clear co-hook now
also restores the gap below each textured line. AddTexture refuses a
texture on or right below a textured line, accepts only strings, and
returns whether it placed the texture. Correct the Offsets.h description
of the routine and keep the user doc to the contract.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
e9e431e014 |
feat(frame): add SetClampRectInsets / GetClampRectInsets (#69)
* feat(frame): add SetClampRectInsets / GetClampRectInsets Later clients let a frame that is clamped to the screen keep a different rect on screen than its own: SetClampRectInsets(left, right, top, bottom) grows or shrinks the rect the clamp uses. Zygor Guides Viewer 2.0 sets them on its frames while building them (a negative top inset lets a frame's top go off screen), and 3.3.5's own FrameXML uses them too. The engine clamps a frame to the screen inside its rect calculation (0x00767A20): it resolves the edges and, for a clamped frame, slides the rect onto the screen. Hook that calculation: for a frame with insets, take the unclamped rect, grow it by the insets (converted from the frame's units to layout units with the inverse of Script GetLeft's scaling), slide that onto the screen with the engine's own steps and order, and move the frame's rect by the same amount. Frames without insets go through the engine's clamp as before. SetClampRectInsets re-lays the frame out, as SetClampedToScreen does, and (0, 0, 0, 0) clears the insets. Sign convention from 3.3.5's own calls: WorldMapFrame (0, 0, 0, -60) "don't overlap the xp/rep bars", chat frames (-35, 35, 26, -50). Verified in-game (1.12.1 client via VanillaFixes): a clamped 100x100 frame placed 10 above the bottom of the screen stays at 10, moves to 60 with (0, 0, 0, -60) and back to 10 once cleared; a frame placed 20 over the top is clamped to the edge and, with a top inset of -25, keeps its 20 over. GetClampRectInsets returns the insets set. * refactor(frame): address review of SetClampRectInsets Use the existing OFF_REGION_ANCHOR and UI coordinate globals instead of new duplicate offsets, and move the pixel/anchor-unit conversion into one shared Game::PixelToInternal / InternalToPixel pair (replacing the copies in LinePool, Transform and Metrics). Restore only the clamp bit around the unclamped rect calculation so other layout flag bits survive. Add doc descriptors for both methods and drop version/implementation notes from the user docs. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
fbcc1c9ae1 |
feat(editbox): add SetCountInvisibleLetters / IsCountInvisibleLetters (#88)
* feat(xml): read parentKey, function= and button font style= from XML Later clients' XML has three attributes vanilla's parser keeps on the node but never reads. Ported UIs lean on all three: Zygor Guides Viewer 2.0 uses parentKey 69 times (its arrow, skin buttons and step frames), binds its main frame's whole OnLoad with function=, and names button fonts with style=. All three hook the engine's per-object XML node loaders. Those run on the object's layout sub-object ((object+0x24)->vtable[+8], called from the frame builder at 0x006EE4D9 and the region factory at 0x006F2756), so the object is `this - OFF_XML_LOADER_SUBOBJECT`. The loaders: frames FUN_00769820 (every derived frame type's loader calls it first), textures FUN_0076FE20, font strings FUN_00770F40, and Button's FUN_XML_BUTTON_LOAD (CheckButton's calls it first). Each hook runs the engine's loader, then: - parentKey="Name" sets parent[Name] = object on the Lua wrappers, the parent being the object's script-region parent (OFF_REGION_PARENT, which GetParent reads). An unnamed element has no wrapper yet, so it is registered the way the engine's own lazy path does (ScriptRegister(object, NULL), as GetParent does); a named one is never registered here, since SetName already did that under its name. The builder loads content and child frames before it finalizes, so a parent's <OnLoad> already sees its keys, and keys inside a virtual template bind on every frame built from it. - A script element with function="Name" becomes frame:SetScript(<element>, _G[Name]). The loader runs before the builder's finalize, so a bound OnLoad fires at the usual point. - A NormalFont / HighlightFont / DisabledFont with style and no inherits is applied through the engine's own setter for that state with _G[style]. Vanilla reads only inherits there and otherwise leaves the button's embedded font empty, so its text had no font. Adds FUN_XML_FRAME_LOAD / FUN_XML_TEXTURE_LOAD / FUN_XML_FONTSTRING_LOAD / FUN_XML_BUTTON_LOAD, OFF_XML_LOADER_SUBOBJECT and OFF_SCRIPT_REGION_NAME, with their derivations. Verified in-game (1.12.1 client via VanillaFixes, Zygor Guides Viewer 2.0): probe XML gets its parent keys on a Frame, a Texture, a FontString, a button's NormalTexture and a frame inside an inherited template; an <OnShow function="..."/> handler runs; a button with <NormalFont style="GameFontHighlightSmall"/> reports that font object. Zygor's frames build with their keys, its main frame's OnLoad runs, and it loads without a Lua error. * feat(editbox): add SetCountInvisibleLetters / IsCountInvisibleLetters 3.3.5's EditBox can count color codes and hyperlink markup toward its SetMaxLetters limit: SetCountInvisibleLetters(true), or countInvisibleLetters="true" in XML (its macro text, friends broadcast and BNet report boxes). Off is the default. AceGUI-3.0's MultiLineEditBox calls the setter while building. 1.12's SetMaxLetters limit (+0x340) counts only visible letters: its counter (0x0077BC80) skips the markup classes in the edit box's per-byte table (+0x330), so with a limit of 5 "|cffff0000abcdefg|r" keeps "|cffff0000abcde" (checked in-game). That is 3.x's default (off). With the flag on, the limit check's three counts (returns 0x0077C09F, 0x0077C0C1, 0x0077C0E9) count each markup token at its length instead. The counter's other callers, the cursor movement and GetUTF8CursorPosition, are unchanged. For XML, hook the EditBox node loader (0x00779FB0, identified by the "letters"/"autoFocus"/"multiLine" attributes it reads after calling the frame loader) and, after it runs, read the attribute and parse it with the engine's own boolean parser (0x006F1B30, as for autoFocus). The loader follows the node-loader convention of the XML attributes change (OFF_XML_LOADER_SUBOBJECT), which this builds on. Verified in-game (1.12.1 client via VanillaFixes): with SetMaxLetters(12), "|cffff0000abcdefg|r" is kept whole with the flag off and cut to "|cffff0000ab" with it on; an XML EditBox with letters="12" and countInvisibleLetters="true" reports the flag on and cuts the text the same way. * docs: correct GetNumLetters note, drop version comparisons GetNumLetters counts the letters you see (FUN_007992C0 calls the same counter as the limit check), not bytes. Remove the 3.3.5 / stock 1.12 / later-client comparisons from the new XML and edit box sections. * fix(frame): build extra templates' child frames in CreateFrame The multi-template graft called the main vtable's +8 slot, which is the Lua method lookup FUN_00778590, not a node applier, passing the XML node as the Lua state. Its second call (the +0x24 sub-object's node loader) applied the template's content, but <Frames> children are built only by FUN_0076A060 from the finalize step, so an extra template's child frames were never created. Call the node loader, then FUN_XML_FRAME_LOAD_CHILD_FRAMES directly, so OnLoad is not re-run. Correct the notes in Offsets.h and CreateFrame.cpp. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
142faafb13 |
feat(frame): add SetHyperlinksEnabled / GetHyperlinksEnabled (#92)
* feat(frame): add SetHyperlinksEnabled / GetHyperlinksEnabled 3.3.5 has SetHyperlinksEnabled/GetHyperlinksEnabled on ScrollingMessageFrame and SimpleHTML only, so register them on those two types' method tables (0x00CF5294, 0x00CF5328), and hook the three functions both types fire OnHyperlinkEnter/Leave/Click through (0x007A3780, 0x007A37B0, 0x007A37E0) to skip the script while a frame's hyperlinks are off. On stays the default, which is vanilla's behavior. Zygor Guides Viewer 2.0 turns hyperlinks off on the step lines it fills with Gold Guide item lists, and back on when they show guide steps. Verified in-game (1.12.1 client via VanillaFixes): both types report true by default, false after SetHyperlinksEnabled(false) and true again after SetHyperlinksEnabled(true), and a plain Frame has neither method, as in 3.3.5. Not yet checked: the skipped script itself (a click on a link with hyperlinks off), which needs the mouse; that check runs next session. * refactor(frame): gate hyperlink scripts via RunnerHook, keep Leave Replace the three MinHooks on the per-type hyperlink fire functions with a Frame::RunnerHook subscriber keyed on the script slot (+0x320 Enter, +0x330 Click). OnHyperlinkLeave is never suppressed, so a tooltip shown before hyperlinks were disabled still closes. Parse the argument with the engine's loose boolean (default on), as 3.3.5's setter does. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
c243489916 |
Fixed bleed of druid "Pounce" spell not shown under nameplates (#105)
* Attribute Pounce Bleed to the caster * fix(aura): attribute triggered auras from the Spell.dbc trigger link Replace the hardcoded Pounce -> Pounce Bleed table with the DBC link: any effect of type SPELL_EFFECT_TRIGGER_SPELL whose EffectTriggerSpell applies an aura gets the trigger's caster. - Arm the target and attribute on the application hook, so a hit by the trigger that the triggered aura never follows (bleed-immune target) creates no phantom entry. An existing instance from the same caster that the descriptor still lists is refreshed in place, since the server's re-apply fires no OnAuraAdded. - Work for any caster, not only the local player. - Share the target list (hit list, else the caster) and the duration helper with the cast's own aura path. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
917b15640e |
feat(quest): add C_QuestLog.GetInfo and C_QuestLog.GetQuestLogTitle
Both run the engine's Script_GetQuestLogTitle (0x004DF930) and repackage its returns, so title, level, header, collapse and complete/failed state match the stock GetQuestLogTitle. Also registers Enum.QuestFrequency and Enum.QuestClassification. Corrects the Quest::Cache note on +0x14..+0x24: those slots are RepObjectiveFaction, RepObjectiveValue, the two opposite-rep fields and NextQuestInChain, not SuggestedPlayers and friends. The 1.12 wire carries no suggested group size, so suggestedGroup is always 0. |
||
|
|
7ccbbaaf68 |
fix(compat): stop Turtle's Toggle Movement button erroring
Turtle's Options frame sets GroupFrame_ToggleMovement(state) directly as the button's OnClick. With modern script args the handler receives the button as `state`, and `1 - state` errors (Turtle_GroupUI.lua:409). Wrap the global so only a number reaches the original.v1.15.16 |