mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Name the macro slot count
Three loops walked 1..36 by hand, two of them re-arguing in comments why 36 is the right number. It is: the client addresses 18 account-wide macros at 1-18 and 18 character-specific ones at 19-36, and that range is what GetMacroInfo and C_Macro.SetMacroDisplay index. Nothing in the API hands it back -- GetNumMacros() returns how many of each tab are used, which cannot be summed into a range, because the character block still starts at 19 when the account block is empty. Blizzard's MAX_MACROS is no better: it lives in the load-on-demand Blizzard_MacroUI and is nil until the macro window is opened. So CleveRoids.MAX_MACRO_SLOTS in Init.lua, carrying that reasoning once. ValidateAllMacros also dropped a numAccountMacros it computed and never read. ReleaseDisplays keeps sweeping the full range rather than the macros it knows it published: PublishAllDisplays clears that record on each re-parse, so a macro claimed before one and gone after it would keep our last published value forever. Releasing a slot we never claimed costs nothing, and it runs once.
This commit is contained in:
@@ -1173,7 +1173,11 @@ end
|
|||||||
-- Hand every macro back to ClassicAPI's own parser and stop claiming ownership.
|
-- Hand every macro back to ClassicAPI's own parser and stop claiming ownership.
|
||||||
function CleveRoids.ReleaseDisplays()
|
function CleveRoids.ReleaseDisplays()
|
||||||
if not CleveRoids.ClassicAPIMacroDisplay then return end
|
if not CleveRoids.ClassicAPIMacroDisplay then return end
|
||||||
for i = 1, 36 do
|
-- Sweep the whole index space rather than the macros we know we published:
|
||||||
|
-- PublishAllDisplays clears that record on every re-parse, so a macro claimed
|
||||||
|
-- before one and gone after it would keep our last value forever. Releasing a
|
||||||
|
-- slot we never claimed costs nothing, and this runs once.
|
||||||
|
for i = 1, CleveRoids.MAX_MACRO_SLOTS do
|
||||||
C_Macro.SetMacroDisplay(i, nil)
|
C_Macro.SetMacroDisplay(i, nil)
|
||||||
end
|
end
|
||||||
publishedDisplay = {}
|
publishedDisplay = {}
|
||||||
|
|||||||
@@ -1180,7 +1180,7 @@ local function ReportAllMacroErrors()
|
|||||||
|
|
||||||
-- Collect body (syntax) errors per macro. Macro names are no longer
|
-- Collect body (syntax) errors per macro. Macro names are no longer
|
||||||
-- restricted (slot/index-based identification), so no name checks here.
|
-- restricted (slot/index-based identification), so no name checks here.
|
||||||
for i = 1, 36 do
|
for i = 1, CleveRoids.MAX_MACRO_SLOTS do
|
||||||
local nameOk, name = pcall(GetMacroInfo, i)
|
local nameOk, name = pcall(GetMacroInfo, i)
|
||||||
if nameOk and name and name ~= "" then
|
if nameOk and name and name ~= "" then
|
||||||
local errors = {}
|
local errors = {}
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ CleveRoids.mouseOverResolvers = {}
|
|||||||
CleveRoids.mouseoverUnit = CleveRoids.mouseoverUnit or nil
|
CleveRoids.mouseoverUnit = CleveRoids.mouseoverUnit or nil
|
||||||
CleveRoids.mouseOverUnit = nil
|
CleveRoids.mouseOverUnit = nil
|
||||||
|
|
||||||
|
-- Every macro slot the client can hold: 18 account-wide (1-18) followed by 18
|
||||||
|
-- character-specific (19-36). This is the index space GetMacroInfo and
|
||||||
|
-- C_Macro.SetMacroDisplay address, and it is fixed -- GetNumMacros() returns how
|
||||||
|
-- many of each tab are *used*, which cannot be summed into a range, because the
|
||||||
|
-- character block starts at 19 no matter how few account macros exist. Blizzard's
|
||||||
|
-- own MAX_MACROS is no help either: it lives in the load-on-demand Blizzard_MacroUI
|
||||||
|
-- and is nil until the player opens the macro window.
|
||||||
|
CleveRoids.MAX_MACRO_SLOTS = 36
|
||||||
|
|
||||||
-- Environment flags
|
-- Environment flags
|
||||||
CleveRoids.hasSuperwow = SetAutoloot and true or false
|
CleveRoids.hasSuperwow = SetAutoloot and true or false
|
||||||
CleveRoids.hasTurtle = (type(_G.TURTLE_WOW_VERSION) ~= "nil")
|
CleveRoids.hasTurtle = (type(_G.TURTLE_WOW_VERSION) ~= "nil")
|
||||||
|
|||||||
+1
-11
@@ -1096,17 +1096,7 @@ function CleveRoids.ValidateAllMacros()
|
|||||||
local results = {}
|
local results = {}
|
||||||
local totalErrors = 0
|
local totalErrors = 0
|
||||||
|
|
||||||
-- Account-wide macros are indexed from 1 up to GetNumMacros().
|
for i = 1, CleveRoids.MAX_MACRO_SLOTS do
|
||||||
-- Character-specific macros occupy the slots immediately following the account-wide ones.
|
|
||||||
-- In Classic clients, the macro UI has 18 General (Account) slots and 18 Character-Specific slots.
|
|
||||||
local numAccountMacros = GetNumMacros()
|
|
||||||
|
|
||||||
-- The WoW API GetMacroInfo(index) supports indexing up to 36 (1-18 for General, 19-36 for Character)
|
|
||||||
-- in Classic clients, even though the total is GetNumMacros() + GetNumCharacterMacros() in Retail.
|
|
||||||
-- To ensure we check all 36 possible slots:
|
|
||||||
local totalSlots = 36
|
|
||||||
|
|
||||||
for i = 1, totalSlots do
|
|
||||||
local nameSuccess, name = pcall(GetMacroInfo, i)
|
local nameSuccess, name = pcall(GetMacroInfo, i)
|
||||||
|
|
||||||
-- Check if GetMacroInfo returned a name (i.e., the slot is used)
|
-- Check if GetMacroInfo returned a name (i.e., the slot is used)
|
||||||
|
|||||||
Reference in New Issue
Block a user