mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
v1.20.2
1457
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6b36bb10e6 |
fix(spell): report GetSpellPowerCost in displayed power units
The engine's cost helper (FUN_006E31B0) answers in stored units, and
1.12.1 stores rage in tenths, so Shield Slam's 20 rage came back as
cost = 200. Divide by the engine's own display divisor
(GetPowerDisplayDivisor, 0x006E7130: [0x0086F978 + 4*type], 1 for a
negative type; table {1, 10, 1, 1, 1000}) before pushing, the same way
the engine and our UnitPower / GetSpellInfo / combat-log paths do.
Every power amount surfaced to Lua now goes through one helper,
Unit::Power::DisplayDivisor, which calls that engine function. That
retires the duplicate FUN_GET_POWER_DISPLAY_DIVISOR offset, the two
local typedef copies, and UnitPower's direct read of the divisor table
(VAR_UNIT_POWER_DIVISOR_TABLE, now removed).
Fixes #129
v1.20.2
|
||
|
|
6628dcca19 |
fix(loot): keep LootAllCorpses walking past refused and stale corpses
The walk ignored the server's refusal. A failed CMSG_LOOT ("too far
away", not ours, ...) arrives as SMSG_LOOT_RESPONSE with loot type 0;
CGPlayer_C::ReadLootResponse (0x005EB900) shows the error and clears the
held loot target (+0x1D28) without opening a window, and the release
response (0x005EC090) clears it the same way. The walk only advanced on
the loot controller hook or a 180-frame timeout, so each refusal stalled
it for seconds. It now advances as soon as the held target is no longer
the corpse it sent for.
A send the engine refused dropped the whole queue. LootUnit (0x005DF2A0)
sends nothing while the mover flags & 0x20FF are set (moving, turning,
falling), and the walk treated each refusal as "skip this corpse", so
moving during a walk skipped every corpse left. A refused send now stays
the current corpse and is retried each tick; after 3 s the walk ends.
The queue's range check went stale. Range was tested once when the walk
began, but each corpse costs a round trip and the player can move in
between. With CanAutoInteract set, CanLootNow (0x005EC110) skips its own
reach test, so the request went out and the server refused it. Each
corpse is now checked for existence, DYNFLAG_LOOTABLE and reach right
before its send, and skipped when it fails.
The reach test is CanLootNow's own: both units' +0x1F0 reach plus the
engine's leeway, at least its minimum, with both constants read live
(VAR_MELEE_REACH_LEEWAY / VAR_MELEE_REACH_MIN) instead of local copies.
It and the lootable test move to Loot::Request, shared by
GetNearbyLootableUnits and the walk. The step timeout uses Time::Clock
instead of a frame count.
|
||
|
|
55d94c80d6 |
feat(spell): apply autoStand/autoDismount/autoUnshift to interaction, loot, items, attacks and taxis
The three settings only covered casts. Each 1.12.1 gate that refuses an action for the player's stand state, mount or form now passes when the matching setting allows it, and the engine's own action (the stand setter FUN_005ED430, or CMSG_CANCEL_AURA for the mount / form aura) runs just before the action is sent. With the settings at 0 nothing changes. - NPC right-click (0x005F0130): the IsShapeShifted call at 0x005F0150 cancels a form without SpellShapeshiftForm flag 0x8 instead of showing ERR_CANT_INTERACT_SHAPESHIFTED. CanInteractNow (0x00606880), whose only caller is the hover cursor, passes the same form, so the NPC's service cursor shows. - Game objects: the use check (vtable slot 6, 0x005F3130), also the hover cursor's query, passes the mount (0x005F31A8) and the form (0x005F31E1) for an object with no Lock row. The default use's no-spell branch (0x005F35DF, before CMSG_GAMEOBJ_USE) and the mailbox and text use slots dismount (except at a mailbox, FUN_0047CFF0) and cancel the form. A locked object opens by a spell, which the cast path already handles. - Loot: the GetStandState calls of the unit (0x0060BFB7) and corpse (0x005D6C3B) right-clicks stand the player up instead of showing ERR_LOOT_NOTSTANDING. The unit loot step's mount read (0x0060BF98) passes, and LootUnit dismounts before CMSG_LOOT (0x005DF3B3). - Item use (0x005D8D00): the ERR_NO_ITEMS_WHILE_SHAPESHIFTED refusal at 0x005D914D cancels the form and continues. Turtle's exe already skips that test; the stock exe reaches it. - Attack: the mount reads in the attack cursor (0x00482659), the right-click attack (0x0060C1B4), StartAttack (0x005ECC06) and both tests of the attack resolver (0x00613039, ERR_ATTACK_MOUNTED; 0x00613142) pass. StartAttack, after all its tests (0x005ECC56), dismounts when the target is in melee reach (Combat::Swing::InMeleeRange). Otherwise it returns without attacking and shows ERR_OUT_OF_RANGE, except while click-to-move (FUN_0060F900) walks the player there. - Taxi: after the taxi map opener's TAXIMAP_OPENED tutorial call (0x004DBAA2), a map with more than one node stands the player up, dismounts and cancels the form, each when its setting is on. Every site is patched only when it holds the expected stock bytes, which both the Octo and stock 1.12.1 exes do.v1.20.1 |
||
|
|
c0b403ba05 |
feat(model): add PlayerModel:ApplySpellVisualKit
PlayerModel:ApplySpellVisualKit(spellVisualKitID [, oneShot]) shows a SpellVisualKit's effects on the pane's model. In the world, 1.12.1 plays a kit on a unit (0x0060EDF0), through effect objects, spell durations and the unit's own animation, and a pane has none of these. The engine's own kit on a bare model is the char-select ghost (0x004727F0), and this is that routine for any kit on the pane's model: - Each of the nine effect columns (+0x0C) is created as a model from its SpellVisualEffectName file, in the pane's scene. It is attached at the column's attachment (20, 34, 19, 21, 22, 17, 23, 24, 25) when the model has that attachment (0x00712CB0, 0x00712F70), as in 0x00472780. The effects get the frame's light through LightChildren. - Procedure kind 1 sets the tint (an 0xRRGGBB colour stored as a float, scaled by 1/255) and kind 14 the alpha, clamped to 0..1. Both are plain stores (0x00710CF0, 0x00710CB0), as the ghost kit makes them. The kit's animation and sound do not play, which matches retail. An effect model's sequence plays one time. Without oneShot, each effect gets the world's loop callback (KitEffectLoopCallback, 0x0060ED00): a clean end (reason 0) plays the animation again. With oneShot, each effect gets EffectDoneCallback's test (0x005FBF50) and CEffect::Stop's model steps (0x006203E0): clear the callback and hide the model, so its emitters stop and the particles already out finish. A FrameTick drain, which runs after the strata walk, then mirrors DrainDyingEffects (0x0061F680). It detaches a stopped effect (0x00713020) once HasLiveParticles (0x007135C0) is false, or at once when its model has already dropped it. A model's destructor detaches its children first (0x0070E3F5), so the drain never reaches a freed parent. The effects are children of the pane's model, so SetUnit, SetItem or a hide and show clears them.v1.20.0 |
||
|
|
f6b98bc3ec |
fix(dbc): reject negative IDs in DBC::Record
DBC::Record checked the ID against the store's count as a signed int. A DBC column uses -1 for "none", and -1 passed that check, so the helper returned records[0xFFFFFFFF]. On 32-bit that wraps to records[-1], the heap word in front of the index array. A caller that passed an unchecked column read a garbage "record": an empty SpellVisualKit effect column gave the pointer 0xF and crashed. The engine rejects these IDs before it compares with the count: the char-select ghost kit's effect step tests the ID with a signed jl at 0x00472797, then a jg against the count. Record now compares unsigned, so it rejects 0, every negative ID, an ID above the count, and an unloaded store, whose count is -1. PvP::Arena had its own copy of the lookup with the same signed compare. It now calls DBC::Record. |
||
|
|
8f4f574174 |
feat(model): add PlayerModel:SetItem
PlayerModel:SetItem(itemID [, appearanceModID, itemVisualID]) shows one item's own model in the pane: a weapon, shield, helm, shoulder, quiver or ammo, with its skin texture and its glow. A 1.12.1 pane shows whatever its display record names (+0x3F0). SetDisplay (0x00505CB0) stores the record and builds it when the pane is visible, the show path (0x00505D49) builds it again, and the SetUnit helper (0x00505B50) clears it. SetItem gives the pane a record of its own and passes it to SetDisplay. The AttachDisplayModel (0x00505A70) co-hook in Model::DisplayInfo then builds the item instead of a creature. So hide, show, SetUnit, SetDisplayInfo and SetKeepModelOnHide handle an item with no new hooks. The model is built from 1.12.1's own steps: - the item folder by inventory type, from the engine's own Item\ObjectComponents\ path strings (0x00838CD8 on); - model name 0, else name 1, with the texture of the same index; - for a head item, the helm builder's (0x004799A0) path, with the player's race prefix (ChrRaces +0x18) and sex letter (0x00838AB4); - AttachItemModelFile's (0x004798C0) steps: create the model in the pane's scene, load the skin with the item-model status (0x00B424F0) and filter 3, bind it as texture type 2 (0x00710EC0), and attach the item visuals (0x00479700); - AttachDisplayModel's install: SetModelInstance (vtable +0x90), the pane's done callback (0x005062A0 through 0x00711BB0), Stand, and the release of the creation reference. The display's own ItemVisuals row wins over itemVisualID, the rule GetItemDescVisual (0x0062EC70) applies to enchants. The visual's child models get the frame's light and fog callback, now a shared LightChildren helper, so they are not drawn black. An uncached item is queued through Item::Data::WarmCache, and each visible pane that still shows it is built again when the item loads. |
||
|
|
43a989dd56 |
feat(model): add PlayerModel:FreezeAnimation
FreezeAnimation(animation, variation, frame) holds the model in one pose of an animation until the pane loads a new model, as SetAnimation does. frame is the time into the animation in milliseconds, the unit of M2 sequence times. The engine's sequence time is start + (ftol(elapsed * speed) + offset) mod length. So the pane's arm plays the animation through PlayAnimation (0x007121A0) at speed 0 and writes frame to bone 0's slot offset (+0xB8, bone states 0x118 bytes each at [model+0x90]). Speed 0 also puts the end stamp on the start stamp. Update (0x00719370) would then queue the done callback on the next frame, and the pane's done callback (0x005062A0) would arm Stand. The arm therefore sets the slot's done latch (+0xC0), the flag Update itself sets once it has reported done. A held animation never ends. SetAnimation and FreezeAnimation now also mark the pane for one re-arm. A call with the animation that already plays then still starts or ends a freeze, where the per-paint compare alone would skip it. |
||
|
|
0caddb8fe6 |
feat(model): add PlayerModel animation, keep-on-hide and unit methods
Adds SetAnimation, SetDoBlend/GetDoBlend, HasAnimation, SetKeepModelOnHide/GetKeepModelOnHide, CanSetUnit and GetDisplayInfo to PlayerModel (and so to DressUpModel and TabardModel). SetUnit now returns whether the unit exists, and SetCreature takes an optional display ID. Animation. A 1.12.1 pane rests on Stand: its per-paint UpdateModel (0x00505C50) arms Stand (PlayAnimation 0x007121A0 with id 0) whenever key bone -1 plays anything else and no turn is pending. A deadline of 0 counts as passed, so any other animation lasted one frame. SetAnimation gives the pane a resting animation and variation of its own. With one set, UpdateModel is hooked to arm that animation in Stand's place, using the pane's blend setting. Every other pane runs the stock function. The pane's done callback (0x005062A0) arms Stand when the animation ends, so the next paint starts it again and it loops. CSimpleModelFFX's SetModelInstance (0x0076CD30), which every pane model build and hide goes through, clears it, so a new model rests on Stand again. SetRotation turns without the shuffle while a resting animation other than Stand is set. HasAnimation is PlayAnimation's own test on the raw id: the lookup at shared data +0x24 must give an index below the sequence count at +0x1C. It is false until the model has loaded. Keep on hide. The pane's Hide (0x00505CE0) drops its model through slot 36, and its Show (0x00505D00) builds a new one from the unit or display record. With keep on, Hide runs only the base hide (0x0076AD50) and Show runs only the base show (0x0076AE10) while the pane still holds its model. The model then comes back with its try-ons and animation. The SetUnit helper (0x00505B50, behind SetUnit, RefreshUnit and Dress) and SetDisplay (0x00505CB0) only store the new subject while the pane is hidden, so they drop a kept model first. The next Show then builds the new one. Off is the default and matches the stock client. Units and displays. SetUnit runs the engine's method (0x00505D70, which Turtle patches) unchanged. It then reports whether the GUID it stored resolves to a unit (type mask 8), the same test the helper uses before it builds. CanSetUnit is that resolve without the set. GetDisplayInfo reads the display record's ID, or the unit's UNIT_FIELD_DISPLAYID (+0x1F4, field 0x7D). SetCreature with a display ID shows that display through the SetDisplayInfo record. |
||
|
|
8e603a7a0b |
fix(player): make IsLoggedIn false until PLAYER_LOGIN fires
IsLoggedIn returned whether the player GUID was set. That GUID falls
back to the char-select GUID before the world loads, and on a /reload
the live GUID is already set while the addons load. So IsLoggedIn was
true while every addon's files ran, and EventUtil.ContinueOnPlayerLogin
ran its callback at once instead of waiting for PLAYER_LOGIN. An addon
that hooked another addon this way hooked it before that addon had set
itself up.
1.12.1 fires PLAYER_LOGIN from one place: the enter cascade
(0x004908C0) calls FUN_FIRE_EVENT_NO_ARGS with 0x10E at 0x00490959,
once per interface initializer run (login and reload). Its arm byte
0x00B4E260 cannot answer the question directly: the initializer sets
it after the addons load (0x0049011D) and the cascade clears it after
the fire (0x0049095E). That call is now redirected to set a flag just
before the event goes out, and the FrameScript_Initialize cleanup,
which runs before every /reload and /logout, clears it.
IsLoggedIn is now false on glue and during addon load, and true from
the PLAYER_LOGIN handlers on, through world transfers.
UnitGUID("player") keeps its char-select fallback.
|
||
|
|
4726fd7c85 |
feat(model): add DressUpModel try-on hand, enchant glow, sheathing and auto-dress
TryOn now takes retail's (item [, handSlotName, spellEnchantID]) and returns an Enum.ItemTryOnReason. The pane gains IsGeoReady, SetSheathed / GetSheathed and SetAutoDress / GetAutoDress. Hand: TryOnItem (0x00504540) picks a lane at one site, 0x0050492D (mov edx,[edi+0x2C]; cmp edx,0x0D). A 6-byte call there jumps a named hand to the worker's own main-hand (0x0050495F) or off-hand (0x005049B1) path, so its CanHoldBoth (0x00504BC0) eviction, lane store and attach all still run; with no hand it replays the two instructions and the jnz reads their flags. The name is matched like GetInventorySlotInfo matches it: SStrCmpI over the PaperDollItemFrame rows, slot 16 or 17. Enchant glow: the player's AttachEnchantVisual step (0x005EED50) on the attachment AttachItemModel (0x0047A0C0) returns: FindChild (0x00712F00), then AttachItemVisuals (0x00479700) with SpellItemEnchantment +0x58, skipped when the display's own ItemVisuals row exists (GetItemDescVisual's rule, 0x0062EC70). The enchant is the argument, else the link's enchant field, which Item::Arg now parses. Sheathing re-runs the unit's AttachHandItem step on the pane's lanes with the sheathed flag. The lanes keep no display row, so the pane records one: the unit's vtable +0x9C row when SetModelInstance (slot 0x00808438) clones it, then whatever the worker's attach (0x00504AE6) installs; its two evictions (0x00504A0C, 0x00504A55) drop theirs. Each lane keeps its glow too, a player's read through GetVisibleItem + GetItemDescVisual, so a re-hung weapon keeps it. Auto-dress off runs ClearModel (0x00504490) after SetModelInstance unless Dress() is the one rebuilding. TryOn's result reads the gates the worker passes: an uncached record is DataPending, a held type installs, armor needs the component and the ready byte (+0x40C). DressUpItemLink now passes the whole link to DressUpItem, so a Control-click shows the link's enchant, and skips a cached item that IsDressableItem rejects. DressUpItem stays, since Blizzard_AuctionUI and Turtle both replace it. |
||
|
|
3e0c40184b |
feat(cursor): add expanded cursors for NPCs and the fishing bobber
Adds the expandedCursors cvar (default 0; AddOn Options > ClassicAPI > Interface > Cursor). At 1 the hover cursor shows what an NPC offers: an anvil for a repairer, a hearthstone for an innkeeper, a horseshoe for a stable master, and a quest giver's ! or ? (a blue ? for a repeatable reward). The player's fishing bobber shows a fish hook in place of the Interact gear. Each has a gray form beyond reach or when not usable. NPCs: ClassifyHoveredUnit (0x00482200) reaches its NPC flag chain at 0x00482336 for a unit the player can interact with, the unit in ESI and the beyond-reach flag in EBX. The chain's `mov ecx, [esi+0x110]` becomes a call to a thunk. At 0 it replays the instruction and the stock chain runs. At 1 it picks from the quest giver status first (CGUnit_C +0xCB8, read by the meaning of the client's status-to-marker table at 0x0080C454), then the NPC flags in service order: repair, innkeeper, flight master, trainer, spirit healer, banker, registrar/tabard/ battlemaster, auctioneer, stable master, vendor, then gossip or a quest giver IsQuestGiverToTalk (0x005DF490) accepts. It leaves through the chain's own epilogue (0x00482356). Bobber: the fishing node handler's cursor slot (vtable 0x0080BC80, slot 4; GetCursor 0x005F8760 is its one reader) points at a wrapper that runs BaseHandlerGetCursor (0x005F3070) and maps Interact/UnableInteract to the hook. The engine still decides whether the bobber is interactable and usable. Showing a mode past 41: SetCursorMode indexes a 42-slot image table, so its existing hook now sends the new modes to Cursor::Extended::Show. It calls SetCustomCursor (0x00523C40) with the mode's path, so a real file wins, and otherwise does what that function does after its load: copy the 32x32 image into slot 41 (0x00C0BD80), store mode 41, send it (SendCursorImage 0x00523790) and keep the name. The hook also records the new modes while Hover::Mode computes, so the soft-interact pick, its icon and SetUnitCursorTexture follow; a quest cursor has no icon image. Images: the 14 BLPs ship inside the DLL (src/embed/Textures, a new TEXTURES_ROOT pack). Texture::Builtin decodes each once with the engine's BLP reader from memory: BlpParse (0x005A83B0) is BlpOpen without the file read, and BlpReset never frees the file buffer. The reader moves to Texture::BlpReader, shared with the map overlays. Texture loads of the same paths, such as the option label's inline icons, get the same images. The reader refuses a DXT5 file. BlpDecodeLevel (0x005A7F00) converts a DXT level through the matrix InitConvertMatrix (0x005A4FC0) fills, and that matrix has DXT1 and DXT3 converters to BGRA8888 but none for DXT5: BlpDecodeLevel would return 1 with its SMemAlloc buffer unwritten. No shipped cursor is DXT5; the check keeps a later embedded DXT5 file, or a DXT5 map overlay, from being read as heap memory. Game paths now compare through one rule, Common::SamePath (any case, either slash), and the embedded manifests through Embed::FindFile. The embedded addons, the bindings splice and sound muting each had their own copy of the rule; they and Texture::Builtin now share it. The option's header, label and tooltip are translated for every client locale, in Blizzard's own terms for each (NSC, PNJ, 物体, 物件, ...). Release Win32 build is clean. In game, only the soft-interact quest icon was checked so far. |
||
|
|
b3e8d92b03 |
feat(localization): translate the addon options panel into zhCN (#126)
* feat(localization): translate the addon options panel into zhCN A Chinese client kept the English strings for ClassicAPI's own options: the AddOn Options window title and its game-menu button, every page name, header, control label and tooltip, and the AoE Loot binding name, which zhCN only had as a commented-out line. The generic strings enUS gained with those pages were missing from zhCN too: FOCUS_TOKEN_NOT_FOUND, LUA_ERROR, RELOADUI, PLAYER_LIST_DELIMITER, SYMBOLIC_NEGATIVE_NUMBER, SYMBOLIC_POSITIVE_NUMBER and the money texture formats. The locale files load enUS first and the file that matches GetLocale() overrides it, so English clients are unchanged and only zhCN is filled in. Terminology follows the client's own: 插件, 界面, 姓名板, 动作条 and 动作瞄准 for action targeting. The Release Win32 build embeds the new zhCN.lua in the !!!ClassicAPI pack (the packed strings were checked). Not tested in-game. * fix(localization): use Blizzard's zhCN terms in the options panel The backpack options said 背包, which zhCN uses for bags in general, so "ignore backpack" read as "ignore bags" and its tooltip contradicted itself. Use 行囊 for bag 0, as BACKPACK_TOOLTIP and BINDING_NAME_TOGGLEBACKPACK do. Junk is 垃圾 (BAG_FILTER_JUNK), and helpful spells are 有益法术, as in the self-cast option tooltips. Drop the coin-texture and signed-number format strings: they were byte-for-byte copies of enUS.lua, which always loads first. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
0a3f8324ea |
fix(frame): stop a re-anchor during layout from freeing the point being read
Crash #132 at 0x00768323 (FUN_REGION_GET_RECT reading [5+0x3C]): Show lays a frame out before its children leave their layout deferral, so its OnSizeChanged ran; the ScrollBox handler read a region's size, and laying that region out reached an anchor point on a still-deferred child. The point getter (0x007A2F90 / 0x007A3070) ends the relative's deferral with FUN_REGION_LAYOUT_REALIZE(0), which ran the child's OnSizeChanged; that script re-anchored the region, freeing the point, and the getter then read the point again (0x007A2FC5) from freed heap. The getters now end the deferral themselves with the point marked busy. The point's deleting destructor (0x00767D80, the only free path) flags a busy point; a flagged getter returns the layout's undefined value without touching the point, and the point walk (0x007671A0 / 0x007671F0) is run again with the current anchors, up to ten times. Otherwise the engine's own getter reads the value, with the deferred bit hidden so a script that hid the relative again cannot start a second resolve. No hooks: the three getters/destructor are patched in the relative-point vtable (0x0081C44C, their only reference), and the six edge resolvers' calls to the walks are redirected. Adds Common::RedirectSlot for the vtable entries. |
||
|
|
6f3a8ffc1d |
feat(texture): add static creature portraits by display ID (#123)
* feat(texture): add static creature portraits by display ID * docs(api): document static creature portrait functions * Update API.md * refactor(model): bake display-ID portraits on the engine's own path SetPortraitTextureFromCreatureDisplayID now replays 1.12.1's unit portrait bake, BakePortrait (0x00524F60), call for call on a display model of its own, instead of driving a hidden PlayerModel through Lua. The display model is built the way AttachDisplayModel (0x00505A70) builds one, without a frame: M2CreateScene (0x00706E10), then CreateModelFromPath (0x00707350) on the CreatureModelData path, then ApplyCreatureDisplay (0x004797B0). A character display is dressed through the engine compositor with the same code that dresses PlayerModel:SetDisplayInfo, now shared as Model::DisplayInfo:: CreateDresser / PumpDresser / DestroyDresser. The bake's own gate, IsReady(model, 0, 1) (0x00710450), only passes for a model that something has drawn: a BLP texture gets its device texture only when GetTextureDeviceObject (0x0044ACF0) is asked with wait set. The shared M2 still loads on its own, so the gate here is IsLoaded(model, 0, 1) (0x007103D0) plus the dress, and the bake's IsReady(copy, 1, 1) makes the device textures, as it does for the copy of a unit's model. The bake itself is the engine's sequence: copy into a fresh scene, DetachAllItemModels, camera 0, PlayAnimation, save projection, view, viewport and fog (GxMasterEnable 0x0058A210 / 0x0058A1E0), the 64x64 DDC box in the bake's own float order, CameraSetDeviceTransforms, clear colour 0, ClearDevice(3), PortraitLighting, both scene passes, read back through 0x00589CF0, clear, cut the alpha mask in (0x005258A0), restore. It runs at the head of the UI render callback, the same point as an OnUpdate script that calls SetPortraitTexture, behind the bake's device gate (0x0058A260 window active, 0x0058A280 device alive). Each display ID owns one callback texture (TextureCreateWithCallback, which makes its device texture at creation). It is bound with SetImage (0x00770300) at call time and filled in place with GxTexMarkRectDirty (0x0058ACD0), the bake's own path for re-baking a cached portrait. A region the caller re-points before the bake finishes keeps what it was given, so no region is tracked: the request map, the region-destruction subscription and ClassicAPI_CancelPortraitTextureRequest are gone. The function returns nothing, as retail's does. Portraits are kept until logout, the lifetime of the engine's display-ID portrait cache (cleared in ShutdownGame). A display with no portrait camera is done once and stays transparent. Offsets.h: the portrait block is renamed to engine names with calling conventions and sources; the duplicates of FUN_M2SCENE_ANIMATE, FUN_M2MODEL_SET_ANIMATED and GetCameraById are removed, as are the made-up draw-flag and scene-count fields and the raw device-vtable slots. Model::Camera::CameraById is exposed instead of being copied. --------- Co-authored-by: z1xel <ramirezthiago@71gmail.com> Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
3862408e1a |
docs(readme): list the new base-library functions
The Lua row gains debuglocals, debugstack's coroutine argument, difftime, gmatch, math.cosh/sinh/tanh, newproxy, scrub, string.byte and strbyte ranges, string.format's two-digit %n$, %0 in string.gsub and table.removemulti. The Lua errors section says the window shows each error's local variables. |
||
|
|
12a81f7f89 |
feat(baselib): debugstack takes a coroutine
debugstack([thread,] [start [, count1 [, count2]]]) returns the stack of a coroutine when one is passed first, with start defaulting to 0 (the coroutine's innermost level), as 4.3.4's Script_debugstack does. 1.12.1's debugstack (0x703760) has no thread argument. A thread fails its lua_isnumber and lua_isstring checks, so it returns the thread itself, and msg .. debugstack(co) raises "attempt to concatenate a thread value" in the coroutine error paths of WeakAuras, Questie's ThreadLib, MRT and Zygor. The engine function still builds the text, so its line format and its 12/10-level head and tail windows are unchanged, which keeps addons that parse debugstack() for their folder working. It reads levels through six calls on the state it runs on: lua_getstack (0x6FBAA0) at 0x70383F, 0x70386E, 0x703896, 0x7038AD and 0x703998, and lua_getinfo (0x6FBC70) at 0x7038CD. Those calls are redirected to read from the state the new global names for the call: the thread, or the calling state. The engine function has no callers of its own, so the global is its only way in and sets that state for every call; an error part way cannot leave a thread behind for the next call. The global removes the thread argument, inserts 0 as start when none is given, and calls the engine function directly in its own frame, so levels without a thread count exactly as before. |
||
|
|
05fa5845b7 |
feat(baselib): debuglocals, and the error window shows locals
debuglocals([level [, skipFunctionsAndUserdata]]) returns the locals and
then the upvalues of a call level as text, one name=value line each.
It runs only while an error handler runs, as in 4.3.4. 1.12.1's error
function sets no flag for that, but while a handler runs that function
(FUN_FRAMESCRIPT_CALL_ERROR_HANDLER) is a C closure level on the stack;
ErrorCallstack's search for it moves into a header so both modules use
it. level counts as lua_getstack and debugstack do.
Each local comes from lua_getlocal (0x6FBB20, fastcall L/ar + n), then
each upvalue of the level's function (lua_getinfo "f") from
lua_getupvalue (0x6F4660, fastcall L/funcindex + n). Values are
formatted as 4.3.4's FrameScript_PackVariable does, with retail's
spacing (probed: n=7, s="hi", t=<table>{ / k=1 / }): a frame table shows
its name, read from t[0] as FrameScript_GetObject does; a table's fields
show one space in at the top level only; a function shows where it is
defined (lua_getinfo ">nS"). The text stops at 4095 bytes. The second
argument, which retail's error handler passes as true, leaves out
function and userdata values.
Where 4.3.4 would fail inside the handler, this does not: a number key
outside int range is formatted from a copy, not converted in place
(which breaks lua_next), and a key that is not a number or string prints
as its type.
Retail also lists (*temporary) lines, 5.1's names for a level's stack
slots past its locals, including a C level's arguments. 1.12.1's
lua_getlocal is 5.0's and names declared locals only; those slots are
compiler registers that 5.0 and 5.1 allocate differently, so they are
not imitated.
The error window takes the locals as retail's GetErrorData does,
debuglocals(level, true) at the stack's level, and shows them under
Locals ("<none>" when there are none).
LuaCAPI.md had lua_pushupvalues, lua_getupvalue and aux_upvalue one row
off; corrected.
|
||
|
|
6ed0edc947 |
feat(baselib): gmatch, table.removemulti, math hyperbolics, difftime, newproxy, scrub
The base-library names that 1.12.1's Lua 5.0 and its compat.lua do not have: - gmatch: the global alias of string.gmatch (5.0's str_gfind, 0x7FCFA0), set by value like strmatch and strrev. - table.removemulti(t [, pos [, count]]): removes count elements from pos, shifts the rest down with lua_rawgeti/lua_rawseti and returns the removed elements. 5.0 keeps the length apart from the keys, so like the engine's table.remove (0x7FB770) it records the new length with luaL_setn (0x6F4EA0). - math.cosh, math.sinh, math.tanh: luaL_checknumber (0x6F4C80) and the C function. - difftime(t2 [, t1]): C difftime over the two times, next to the engine's date and time globals. - newproxy([false | true | proxy]): an empty userdata from lua_newuserdata. The closure's upvalue is a weak table (its own metatable, __mode "kv") that marks the metatables newproxy(true) makes, so only those can be shared. - scrub(...): replaces each argument that is not a boolean, number or string with nil, in place with lua_replace (0x6F32B0). All are registered on both Lua states. Game::Lua gains RawSetI (lua_rawseti, 0x6F3F60), Replace, CheckLString (luaL_checklstring, 0x6F4BE0), CheckNumber and OptNumber (luaL_optnumber, 0x6F4CD0); string.byte now uses them instead of local typedefs. issecure, issecurevariable and forceinsecure are left out. 1.12.1 has no taint, so they could only return constants, and a constant "secure" from issecurevariable makes AceHook-3.0 refuse every plain hook.v1.19.3 |
||
|
|
1645e6b43c |
feat(baselib): string.byte returns a range of byte codes
1.12.1's str_byte (0x7FC210) is Lua 5.0's: it reads only the start position and pushes one code, so string.byte(s, 1, -1) silently returns the first byte alone. string.byte and the strbyte global now take (s [, i [, j]]) and push the codes of bytes i..j, with j defaulting to i. Negative positions count from the end and the range is clamped to the string. The arguments are read with the engine's luaL_checklstring (0x6F4BE0) and luaL_optnumber (0x6F4CD0), and positions truncate toward zero as the engine's str_byte and str_sub do, so a call without j returns exactly what it did before. Each code takes a stack slot, reserved with lua_checkstack (0x6F2F30). The engine refuses more than 2048 slots, so a range longer than about 2000 bytes raises "stack overflow (string slice too long)". compat.lua set strbyte from the old string.byte when the state opened, so strbyte is re-aliased to the new table entry. |
||
|
|
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.
|
||
|
|
6a24271cd1 |
feat(baselib): two-digit %n$ argument numbers in string.format
1.12.1's str_format (0x7FD3D0) only reads a one-digit argument number: isdigit(p[0]) && p[1] == '$'. In "%10$s" the "10" is read as a width and the '$' as the conversion, which raises "invalid option in `format'". Combat log strings such as ACTION_SPELL_PERIODIC_LEECH_RESULT, "(%10$s %8$s Gained)", cannot be formatted. Replace the engine's 18-byte one-digit branch at 0x7FD4AC with a call to a naked thunk that sets the argument number ([ebp-8]) and the flags scan start (EBX) for both "n$" and "nn$". EAX/ECX/EDX are dead at the site. The engine still tests the first digit with its own isdigit, increments the argument after the site, and does every conversion, so string.format, format and the C callers of str_format all get the change. The patch checks the original bytes and is skipped when they differ. |
||
|
|
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>
|
||
|
|
04790cb6c1 |
feat(options): name the page scroll bars for skins
Each options page's MinimalScrollBar is now ClassicAPIOptionsScrollBarN, numbered like the ClassicAPIOptionsControlN controls, so a skin can find the scroll bars the same way it finds the controls. |
||
|
|
e7ecae56da |
feat(options): key binding rows for ClassicAPI's bindings
The Interact Key page gets rows for Interact With Target and Interact With Mouseover, and Bags and Items gets AoE Loot under a Loot header. A row is retail's settings-page binding row: the binding's name, then a button for each of its two keys. Left click a button and press a key, mouse button 3-5 or the wheel to bind it; Escape cancels; right click unbinds that key. The tooltip on a bound key and the page's output line use retail's strings, added to every locale with Blizzard's translations. The binding is 1.12's Key Bindings window's (Blizzard_BindingUI): the same ALT-CTRL-SHIFT chord order, the same skipped modifier keys, the same KEY_UNBOUND_ERROR check for an action that loses its last key, and the same put-back when SetBinding refuses a key. A change saves at once with SaveBindings(GetCurrentBindingSet()), so it lands in the account or character set in use, as every other control on these pages writes at once. While a button listens, a full-screen button on FULLSCREEN_DIALOG takes keys, clicks and the wheel, as retail's KeybindListener and its input blocker do. A left or right click on it cancels, and so does hiding the page. |
||
|
|
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). |
||
|
|
3a4d291748 |
fix(link): split links with string.split captured at load
LinkUtil.SplitLinkData and SplitLinkOptions looked up string.split on every call. BigWigs (pepopo978 fork) defines a table-returning string:split in Plugins/SpellRequests.lua, which replaces the global, so with it loaded every custom link type resolved to a table, no handler matched, and SetItemRef rejected the link as unknown. string.split is registered in C by the DLL before any addon loads, so a file-local captured when LinkUtil.lua loads always holds the real one. Fixes brues-code/pfUI#73v1.19.2 |
||
|
|
1cdd46958f |
feat(combatlog): 4.3.4 combat log lines in retail-named log files
While combat logging is on, each combat log entry is also written as one CSV line in 4.3.4's PackEvent layout: the subevent, source and dest (GUID, quoted name or nil, flags as hex), the spell prefix, then the suffix blocks the entry carries. Fields are written as 1 or nil, damage values as numbers, and there is no hideCaster, isOffHand or alternate power type. The line is written from Queue before the events fire, so it is written even when no frame listens. The switch is LoggingCombat's own flag (0x00B4FDB8), so /combatlog and LoggingCombat() control both files. Each time the flag turns on, a new file starts, named as retail names it: Logs\WoWCombatLog-MMDDYY_HHMMSS.txt, the local time logging started. The file is a Storm log opened as LoggingCombat opens its own: SLogCreate (0x0065A0C0) with flag 4 (append). Lines go through SLogWrite (0x0065ACE0), which puts the "M/D HH:MM:SS.mmm " stamp in front. The flag is read once a frame on FrameTick and before each line. When it turns off, SLogClose (0x00659EC0) writes the buffered lines and closes the file. This also covers logout: the chat teardown in CGGameUI::ShutdownGame (0x00498700, its only caller) clears the flag, and FrameTick runs on the glue screen too. Storm closes what is still open at exit (0x0065A4B0). LoggingCombat itself is not hooked: it is a jmp into the enable code the chat log shares, and other DLLs add their own logs to it. 1.12's Logs\WoWCombatLog.txt keeps its chat-text lines, written by 0x0049B1E8, for the log readers that parse them.v1.19.1 |
||
|
|
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.
|
||
|
|
84c936faa4 |
fix(compat): hooks wrap the engine's body when wow_turbo got there first
wow_turbo detours about 380 engine functions to its own reimplementations from its DllMain. It yields any function whose prologue another mod has already patched, but ClassicAPI installs from the Load export, which VanillaFixes calls after every DllMain. So wow_turbo always patches first, and MinHook copies its jmp into our trampoline: the hook then calls the reimplementation, not the engine's body. Everything that lives in that body was lost. The script runners (0x00704D50, 0x00704F10) never reached the pcall redirects at 0x00704E79 / 0x00705199, so every handler saw self == nil. The text builder (0x005CDC20) calls its own emitter, so the inline texture emitter hook (0x005CCBE0) and the word-wrap redirects at 0x005CDDD3 / 0x005CDE23 never ran. Before each HookAutoRegister hook is created, a prologue that is a jmp rel32 into wow_turbo.dll gets its five stock bytes back. The bytes come from WoW.exe on disk, found through the loaded image's section table. Then the hook wraps the engine's body. wow_turbo's own rule produces the same state when it loads after a mod that hooked first. It keeps its original in place, logs the overwrite and does not re-patch these entries. Release builds reclaim six: the two runners, the text builder and emitter, GxSetViewport (0x0058AF60) and the selection-circle update (0x00614A90). Nothing changes when wow_turbo is not loaded. |
||
|
|
957d66af49 |
fix(addons): memory usage walks the live objects, as luaC_sizeall does
UpdateAddOnMemoryUsage summed Gc::Tag::SizeOf over the keys of the tag map. That is only safe while every free reaches luaC_freeobj (0x006F7260), whose co-hook erases the key. wow_turbo replaces luaC_collectgarbage (0x006F7340) with a parallel sweep that frees strings, tables, closures, userdata and upvalues itself and sends only threads and protos through freeobj. Dead keys stayed in the map, and the recount read freed blocks: crash 132. The recount now walks the lists the engine sweeps: rootgc (G+0x10), rootudata (G+0x14) and every string-table bucket (G+0x04, size G+0x0C), and looks up the tag of each live object. 3.3.5's luaC_sizeall walks the same lists. A create with no context word now erases its address's entry, so a reused address never carries a dead object's tag, whoever freed it. Dead entries a foreign sweep leaves are never read, and the pool's address reuse bounds them. _classicapi_LuaHeapAudit uses the same walk. Fixes #120 |
||
|
|
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. |
||
|
|
1cdd443e53 |
refactor(text): inline icons take their line's fade when its colour changes
The icon textures have no frame, so the frame alpha fold (0x0077FAC0) skips them and their only alpha is the one copied from their fontstring's colour (colors[0], OFF_FONTSTRING_COLOR_ARRAY). The tick read that colour for every fontstring with icons, every frame, and re-coloured the icons when it changed. Every change of that colour ends in the fontstring's region slot 8, CSimpleFontString::OnColorChanged (0x00772180, `ret 4`): SetVertexColor (0x0077F750) calls it after storing a colour, which is how the chat fader and SetTextColor reach it, and the frame alpha setter (0x0076A690) calls it on each region of the frame. It folds the colour (0x0077FAC0) before it hands it to the built string, so the value is final when it returns. A co-hook on it now copies the colour onto the line's icons in the same call. No other loaded DLL refers to that address. The batch reads a texture's colour through a pointer, so no layer rebuild is needed. The glue value-follow (FadedColor) is unchanged. The tick only deletes orphaned textures now; the per-fontstring applied-colour stamp is gone. |
||
|
|
ada33825ad |
refactor(text): inline icons are placed at build and at move only
Inline icons were placed on three paths: the RebuildString refresh, the paint flush (FUN_TEXT_PAINT co-hook), which recomputed every icon line's placements after every paint and queued any change, and the tick, which applied the queue. Measured over normal play, the paint flush never supplied an icon the rebuild had missed. All it did was re-place icons that had moved, 456 times: almost all by float noise (1e-5 px), each one re-anchoring the icon and rebuilding the fontstring's layer; the rest by up to 0.9 px. That 0.9 px is a move. A fontstring whose size does not change keeps its built string: the rect callback (0x00772D40), SetTextOffset (0x00772100) and the animation translation only move it, through TextBlockSetStringPos (0x0044D600) -> CGxString::SetPosition (0x005CCB10), which re-finalizes the node origin (0x005CDF70) before it returns. The origin is floored to whole render-target pixels, so an icon anchored to the unrounded fontstring rect drifts off its glyphs by up to a pixel. The icons are now placed when the string is built (the RebuildString refresh) and after each TextBlockSetStringPos, from a co-hook on it. No other loaded DLL refers to that address. The move lays the node out first (FUN_TEXT_ENSURE_BUILT, as the rebuild does): a colour change can leave the node unbuilt until the next paint, and with no built lines (+0x9C) the origin finalize returns early with the raw normalized position in the origin, which placed those icons at the bottom-left of the screen. The placement now refuses an unbuilt node. Only nodes with icon records are laid out early. Removed: the paint flush's placement queue, the pool's queue and dirty flag, and the tick's apply. The pool has one entry point, Apply, which skips an icon set equal to the one applied. The paint flush keeps its other jobs (the stuck-blockless re-dirty, the stale-record guard and the baked-alpha mirror); the tick keeps the orphan deletes and the fade mirror. |
||
|
|
dd584703a2 |
refactor(text): place inline icons once, at scale 1
An inline icon texture was given its fontstring's layout scale (layout slot 0x10, as AddRegionToLayer gives a region its frame's), its anchor offsets were divided by that same scale, and every tick read each drawn icon's resolved width back and folded the error into a per-icon correction, re-placing the icon until it settled within 0.5%. The textures have no frame, so that machinery has nothing to correct. The layout constructor (0x00767680) sets the scale (layout +0x58, region +0x7C) to 1.0 and nothing else changes it without a parent. RelativePointGetX/Y (0x007A2F90 / 0x007A3070) place a point at the positioned region's own scale times the stored offset plus the relative edge, so with scale 1 the fontstring-relative edges land exactly. The scale copy and the divide cancelled, and the correction stayed at 1. The icon is now placed with two SetPoints at the raw offsets and the layout realize (0x00768060, SetDeferResize(0), which resizes at once when a resize is pending). Removed: the scale copy, the correction and the per-tick rect readback, and VTBL_LAYOUT_SET_LAYOUT_SCALE, which named the same slot as VTBL_LAYOUT_SET_SCALE. |
||
|
|
5911298acd |
fix(text): inline icons are drawn by their line, as 4.3.4 does
Inline icons were CSimpleTextures registered on the fontstring's parent frame, with their visibility copied from the line once per tick, after the draw. Any line that hid kept its icons for one more frame; once chat lines moved with their text, a line scrolled off the top flashed its icons above the chat frame. 4.3.4's CSimpleEmbeddedTexture has no frame, and the fontstring draws it: CSimpleFontString::Draw queues the string, then QueueTextures. 1.12's equivalent is CSimpleFontString::Emit (0x00772E50), the only caller of AppendToBatch (0x00773080). The icon textures are now made with no frame (SimpleRegionConstruct skips SetRegionParent for a null parent; the frame-alpha fold 0x0077FAC0 tests the parent), anchored to the fontstring and given its scale through layout slot 0x10, as AddRegionToLayer does. A hook on Emit adds a line's icons to the layer batch right after its text, and only when the text went in (the batch count at +0x4 grew), so an icon draws exactly when its line does, in the same frame. The batch copies each texture's handle, blend and colour count when built (0x00772FD0) and reads vertices, texcoords and colours through pointers, so a change to a line's icon set marks the fontstring's layer (NotifyLayerChanged 0x0077FDF0), and moves and fades need no rebuild. 4.3.4 sets the textures up in UpdateString. RebuildString (0x007724A0) now does the same: when its gate passes (layout flags +0x60 bit 1, `test byte [esi+0x60],1`) it replaces the built string, so the line's icons are dropped, the new node is laid out (FUN_TEXT_ENSURE_BUILT) and its placements applied at once. The paint flush stays the backstop. Removed: the per-tick visibility mirror, the freshness expiry, region Show/Hide and re-parenting, and the SMF early apply with its _classicapi_InlineTexEarly toggle; the rebuild refresh covers what it did, and it rebuilt every icon line on every layout. The textures are deleted through their vtable slot 0 (as the frame destructor deletes regions) one tick after their fontstring dies or a reload, once the batches holding them were rebuilt.v1.19.0 |
||
|
|
a6fa06faa0 |
perf(smf): lines a layout keeps on screen keep their font strings
The line layout (0x00788750) shows record (position - i) in line i and sets each line's text through ShowLine (0x00788AF0). When the position moves, by a message at the bottom or a scroll, every line got the text of its neighbour: a copy, a freed built string, a new measure and a new shaping. Before a layout of a shown frame, the line entries are now turned by the distance the position moves (the layout's record minus the scroll record +0x348, the record line 0 shows), so each line that stays on screen is the font string that already holds its text. The layout itself runs unchanged. SetText (0x00771D80) returns at its SStrCmp when the text is the one the line holds, so the line keeps its built string and measured height; SetVertexColor (0x0077F750) skips a repeated colour; the forced Resize only moves the built string, since the rect callback 0x00772D40 rebuilds only on a size change. Only lines that come round get new text. Hyperlink buttons are rebuilt from the lines after every layout, and inline textures are anchored to their line, so both follow. The 0x10-byte entries move whole, as the engine's own array grow 0x00789060 moves them with SMemReAlloc. Two lines get new anchors: the new line 0 goes on the frame, then the old line 0 on the line below it, in that order so no line is anchored to one that depends on it. Both are anchored as the layout anchors a new line, in the frame's insert mode (InsertMode::AnchorLine, now shared). A frame whose last layout placed no line (+0x34C = 0, a hidden frame's layout) is laid out as before, as is a distance as large as the lines. A wrong distance costs only the reuse: the layout still sets every text it shows. The layout's before-listener now receives the record it runs from. |
||
|
|
045ab77508 |
perf(smf): one line layout per update for messages added at the bottom
The ring writer 0x00788150, AddMessage's only callee, lays the lines out (0x00788750) after every message at the bottom, and the layout sets the text of every line it shows. k messages in one update cost k layouts of every shown line, and only the last is drawn. The writer's layout call (0x00788234) is redirected. The layout is put off when its result is known apart from line heights: the frame is shown, it had a message before this one, and its top flag +0x350 is clear (the lines do not reach the oldest message, and a newer message cannot make them). The layout's first store, the scroll record +0x348 = the newest record, is made at once, so GetCurrentScroll and the writer's next check read as before. The put-off layout runs at the first of: - the frame's update, between its OnUpdate script and its fader (the call to 0x0076B2C0 at 0x00788471). The fader, RearmLines and the link-button rebuild read each line's record through node+0xC, and the writer may have reused those records. - the end of the top's update pass, before the second layout-queue drain (0x00768ED0 at 0x00765799) and the draw, so a message added by any OnUpdate draws in the same frame. - RearmLines 0x00788B80 (hooked), which ScrollDown, ScrollToBottom and ScrollToOffset run at the bottom instead of a layout. - GetNumLinesDisplayed (0x00793590, reads +0x34C), overridden on the method registry to lay out first. - any other layout of the frame, which replaces it. Layout gains a before-listener for this, since a layout can run Lua. OnMessageScrollChanged now runs once for the messages a layout covers: the put-off layout gets the scroll record from before the first of them. The writer is put off only when both flush redirects apply. |
||
|
|
ac5df0fab8 |
perf(smf): BackFillMessage shifts in place and skips layouts it cannot change
BackFillMessage made every older message move up one record. It copied the record span into a vector and back, built a new Lua table for the extra arguments, and laid the lines out again on every call. pfUI's combat-log refilter calls it once per frame for up to 300 lines, and its chat history up to 30 times per frame at login. The records now rotate in place (std::rotate over the 0x18-byte records), and the extra-argument tables follow each cycle of the rotation in the same table, so a call makes no garbage. RemoveMessagesByPredicate shares the rotation. A shown frame whose lines do not reach the oldest message (+0x350, the top flag the layout 0x00788750 sets) cannot show the new oldest one. The layout would place the same lines again, so it is skipped. The one thing it would change, each laid-out node's record pointer (node+0xC, written by ShowLine 0x00788AF0), moves one record up with its message. The fader 0x00788460, RearmLines 0x00788B80 and RebuildLinkButtons 0x00788C00 read records only through that pointer, for nodes 0..+0x34C-1. Clear leaves +0x350 at 0 on an empty frame, so the skip also needs existing messages. An empty or hidden frame is laid out as before. |
||
|
|
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. |
||
|
|
f061179646 |
refactor(region): one region destruction signal; inline icons drop the vtable guess
Frame::RegionDestruction co-hooks SimpleRegionDestruct (0x77F6F0), the destructor body every region ends in, and runs its listeners first. It has exactly three callers: the base region's deleting destructor (0x77F6C6), ~CSimpleTexture (0x76FD40, a tail JMP; its only caller is the deleting destructor 0x76FD10) and ~CSimpleFontString (0x770E50, a tail JMP; called by its deleting destructor 0x770E20 and by a subclass's, 0x789320). The texture and font string vtables (0x81C718, 0x81C778) are written only by their constructor and destructor, so no inlined destructor skips the hook. It replaces FontString::Destruction, the font-string-only hook from the previous commit; the duration text binding now listens here. InlineTexturePool kept icon state keyed by font string pointer and judged a key alive by its first word matching a vtable it had seen painted. That guess had a hole: a destroyed font string's block goes back to the region pool and can come back as another font string, vtable and all, and the dead key's icons then served the new one. It also read possibly-freed memory on every tick. Now a destroyed key takes its entry with it at once, so the address starts clean; its icon regions live on with their parent frame and are hidden on the next tick, never inside the destructor that reported the death. A destroyed icon region is dropped wherever it is held, and a live key that loses one is placed again. The learned-vtable sets, IsLiveFontString and IsLiveRegion are gone. The SEH latch stays, for the engine region calls the tick makes from paint-time data. |
||
|
|
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. |
||
|
|
aef68d5ea4 |
fix(nameplate): fire REMOVED and ADDED when a unit moves to another plate
The name-query callback (0x5FB86E) and the creature-cache reply (0x6046C1) call CGUnit_C::ReleaseNamePlate (0x608A10) so the plate is rebuilt with the name, and the next tick takes a plate again through AllocNamePlate (0x6087F0). The free list is FIFO: release links the frame in at the tail and alloc takes s_freeNamePlates[2], the head. So unless the list was empty, the unit gets a different CGNamePlateFrame. The per-tick diff compared GUIDs only. The GUID was in both snapshots, so no event fired, and an addon that keys its state by frame kept the old, hidden frame. A binding is now the (GUID, frame) pair. A unit on a new frame gets NAME_PLATE_UNIT_REMOVED for the old binding, then NAME_PLATE_UNIT_ADDED for the new one. The REMOVED pass now runs before the ADDED pass, so the old binding's slot is free before the new one is assigned. A re-acquire that hands back the same frame still fires nothing. During REMOVED, GetNamePlateForUnit / GetNamePlateForGUID now return the frame being removed before they read unit+0xE60. After a rebind, that field already names the new frame, and the getters would have given the handler the wrong plate. |
||
|
|
cc1e70a641 |
feat(debugtools): modern /etrace
/etrace and /eventtrace now open a backport of retail's Blizzard_EventTrace, the load-on-demand addon ClassicAPI_EventTrace embedded in the DLL. It replaces the old event trace frame in ClassicAPI_DebugTools, and DebugToolsSavedVars with it; the panel saves EventTraceSavedVars. What differs on 1.12.1: - RegisterAllEvents adds the frame to every event slot, so it opens the listener gate of each ClassicAPI event that builds its arguments only for a listener (UNIT_AURA_DELTA, the combat log and cast events). The panel registers all events only while it is shown or logging while hidden; otherwise it keeps PLAYER_LOGOUT, which saves its variables, since this client has no ADDONS_UNLOADING. - An engine event signalled by a number with no name arrives with a nil event and is not logged. - An event's table arguments are copied when logged, and the tooltip lists their contents. UNIT_AURA_DELTA refills the same tables on every fire, so a kept reference shows only the latest delta. - No tool windows, ImGui debug tools or secret values. The window's templates are new shared templates in !!!ClassicAPI: ButtonFrameTemplate and PortraitFrameBaseTemplate (with PortraitFrameMixin / TitledPanelMixin), UIPanelCloseButtonNoScripts, PanelResizeButtonTemplate, InputBoxInstructionsTemplate, SharedTooltipTemplate, VisibleWhilePlayingAnimGroupTemplate, and GameTooltip_AddHighlightLine / GameTooltip_AddColoredDoubleLine. Art this client lacks is drawn with its own textures: tooltip border chrome, the world map magnifier, the cancel button, a turned chat expand arrow for the resize grip, and the panel button in three slices. The scroll bars are the 1.12 bar, whose art is wider than its frame, so the lists leave room for it. Retail's search box is ClassicAPISearchBoxTemplate. Turtle's FrameXML registers its own SearchBoxTemplate first, and 1.12 keeps the first template of a name, so the retail one takes that name only through a TOC line marked [ExcludeLoadGameType turtle]. The EVENTTRACE_* strings and SLASH_EVENTTRACE1-4 come from Classic Era's GlobalStrings for each client locale but koKR. |
||
|
|
f1843afc0f |
feat(addons): ExcludeLoadGameType and the turtle game type in TOC lines
A TOC file line can now end in [ExcludeLoadGameType ...] as well as [AllowLoadGameType ...]. An unknown condition drops its line, so a line excluded for some other game type used to be dropped here too. Both lists may name "turtle", a ClassicAPI extension like the _Turtle.toc flavor: it matches when Turtle::Detected() (the engine's TURTLE_WOW_VERSION or the glue TURTLE_* globals), and "vanilla" matches on every client. So [ExcludeLoadGameType turtle] loads a line everywhere but Turtle. The TOCs of the addons embedded in the DLL now go through the same rewrite. The FUN_FILE_READ hook serves an embedded addon's file from disk or from the DLL as before, now in ReadAddonFile, and passes a read that succeeded to TocRewrite::Transform, which rewrites only TOCs. |
||
|
|
f8304c06f7 |
fix(xml): frames loaded from XML lay out after OnLoad
When a frame finishes loading from XML, CSimpleFrame::PostLoadXML (0x0076A2F0) clears the loading flag and, for a visible frame, ends the layout deferral of the frame, its title region and its registered regions with 0x00768060(0). That call resolves a pending layout at once (0x007680E0 with force 1), so OnSizeChanged runs before the frame's OnLoad, and before its children, built next, run theirs. Building the children first does not help: resolving a child ends the deferral of the frame it anchors to and lays that frame out too (0x007A2F90). Retail lays these frames out later, from its end-of-frame resize list. Its EventFrame, ScrollBox and scroll bars trigger callbacks from OnSizeChanged on the registry their OnLoad creates, so a retail window that loads visible raised "executingEvents (a nil value)" from each of them. The three calls (0x0076A310, 0x0076A324, 0x0076A35B) now go to EndLoadDeferral: it clears the deferred bit (0x02 of the layout flags at +0x3C) the same way, and sends a pending layout (0x00768310) to the engine's layout queue with 0x007680E0(0), the path SetPoint takes. The queue drains on the top's update and in the interface build, after every OnLoad of the load. A script that reads a size or an edge still lays its frame out at once. The minimap and tooltip finalizers call the base first and read no rect after it. Each redirect checks the call's target first, so a site another DLL has patched keeps its code. |
||
|
|
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.
|