Skip to content

Commit af6a784

Browse files
committed
Cache spells right away
Add global SimulationcraftAPI that is used to expose some of the functions fix some global variable leakage
1 parent d82f618 commit af6a784

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

core.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ function Simulationcraft:GetItemUpgradeAchievements()
713713
local achieves = {}
714714
for i=1, #Simulationcraft.upgradeAchievements do
715715
local achId = Simulationcraft.upgradeAchievements[i]
716-
_, name, points, complete = GetAchievementInfo(achId)
716+
local _, name, points, complete = GetAchievementInfo(achId)
717717
if complete then
718718
achieves[#achieves + 1] = achId
719719
end
@@ -726,7 +726,7 @@ local function LoadSpellsAsync(callback)
726726

727727
-- Build up the SpellCache asynchronously
728728
local numLoaded = 0
729-
function onLoad()
729+
local function onLoad()
730730
numLoaded = numLoaded + 1
731731

732732
if numLoaded == #spellIds then
@@ -1138,7 +1138,7 @@ function Simulationcraft:GetSimcProfile(debugOutput, noBags, showMerchant, links
11381138
local level, _, _ = GetDetailedItemLevelInfo(itemLink)
11391139
simulationcraftProfile = simulationcraftProfile .. '#\n'
11401140
if itemName and level then
1141-
itemNameComment = itemName .. ' ' .. '(' .. level .. ')'
1141+
local itemNameComment = itemName .. ' ' .. '(' .. level .. ')'
11421142
simulationcraftProfile = simulationcraftProfile .. '# ' .. itemNameComment .. '\n'
11431143
end
11441144
simulationcraftProfile = simulationcraftProfile .. '# ' .. itemStr .. "\n"
@@ -1231,9 +1231,16 @@ end
12311231
-- This is the workhorse function that constructs the profile
12321232
function Simulationcraft:PrintSimcProfile(debugOutput, noBags, showMerchant, links)
12331233
LoadSpellsAsync(function()
1234-
simulationcraftProfile, simcPrintError = Simulationcraft:GetSimcProfile(debugOutput, noBags, showMerchant, links)
1234+
local simulationcraftProfile, simcPrintError = Simulationcraft:GetSimcProfile(debugOutput, noBags, showMerchant, links)
12351235

12361236
local f = Simulationcraft:GetMainFrame(simcPrintError or simulationcraftProfile)
12371237
f:Show()
12381238
end)
12391239
end
1240+
1241+
LoadSpellsAsync()
1242+
1243+
-- Expose GetSimcProfile so addons can fetch the profile without goin through awkward wordarounds, added inside a global table so its easier to add more things under it later on if needed
1244+
SimulationcraftAPI = {
1245+
GetSimcProfile = Simulationcraft.GetSimcProfile
1246+
}

0 commit comments

Comments
 (0)