Skip to content

Commit

Permalink
Address LuaLS diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
raethkcj committed Nov 7, 2024
1 parent a4f072e commit 7b27ca3
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 54 deletions.
1 change: 1 addition & 0 deletions .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ignore:
- ./*.txt
- *.jpg
- scripts
- LanguageServerOverrides.lua
- **/libs/**/*.rockspec
- **/libs/**/changelog.*
- **/libs/**/CHANGELOG.*
Expand Down
14 changes: 14 additions & 0 deletions LanguageServerOverrides.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---@meta

---@class ClassicGameTooltip : GameTooltip
local ClassicGameTooltip = {}

---@return integer
function ClassicGameTooltip:NumLines() end

---@return Frame?
function ClassicGameTooltip:GetOwner() end

---@param school 1|2|3|4|5|6|7
---@return number
function GetSpellCritChance(school) end
22 changes: 14 additions & 8 deletions RatingBuster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1116,13 +1116,17 @@ local options = {
order = 5,
get = function(info)
local db = RatingBuster.db:GetNamespace("AlwaysBuffed")
return db.profile[info[#info]]
if db then
return db.profile[info[#info]]
end
end,
set = function(info, v)
local db = RatingBuster.db:GetNamespace("AlwaysBuffed")
db.profile[info[#info]] = v
RatingBuster:ClearCache()
StatLogic:InvalidateEvent("UNIT_AURA", "player")
if db then
db.profile[info[#info]] = v
RatingBuster:ClearCache()
StatLogic:InvalidateEvent("UNIT_AURA", "player")
end
end,
args = {
description = {
Expand Down Expand Up @@ -1683,8 +1687,9 @@ do
if not StatLogic.StatModIgnoresAlwaysBuffed[modName] then
for _, mod in ipairs(mods) do
if mod.aura and (not mod.rune or showRunes) then
local name, _, icon = GetSpellInfo(mod.aura)
if name then
local spellInfo = C_Spell.GetSpellInfo(mod.aura)
if spellInfo then
local name, icon = spellInfo.name, spellInfo.iconID
local option = {
type = 'toggle',
name = "|T"..icon..":25:25:-2:0|t"..name,
Expand All @@ -1695,7 +1700,7 @@ do
-- If it's a spell the player knows, use the highest rank for the description
local spellId = mod.spellid or mod.known or mod.aura
if IsPlayerSpell(spellId) then
spellId = select(7,GetSpellInfo(name)) or spellId
spellId = C_Spell.GetSpellIDForSpellIdentifier(name) or spellId
end
local spell = Spell:CreateFromSpellID(spellId)
spell:ContinueOnSpellLoad(function()
Expand Down Expand Up @@ -2022,6 +2027,7 @@ local scanningTooltipOwners = {
["UIParent"] = true,
}

---@param tooltip ClassicGameTooltip
function RatingBuster.ProcessTooltip(tooltip)
-- Do nothing if the tooltip is being used as a hidden scanning tooltip
if tooltip:GetAnchorType() == "ANCHOR_NONE" and (not tooltip:GetOwner() or scanningTooltipOwners[tooltip:GetOwner():GetName()]) then
Expand Down Expand Up @@ -4010,7 +4016,7 @@ function RatingBuster:PerformanceProfile()
for i = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
GameTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE")
GameTooltip:SetInventoryItem("player", i)
self.ProcessTooltip(GameTooltip)
self.ProcessTooltip(GameTooltip --[[@as ClassicGameTooltip]])
GameTooltip:Hide()
end

Expand Down
43 changes: 19 additions & 24 deletions libs/StatLogic/StatLogic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function StatLogic:argCheck(argument, number, ...)
end

-- Tooltip with syntactic sugar
---@class StatLogicTooltip : GameTooltip
---@class StatLogicTooltip : ClassicGameTooltip
local tip = CreateFrame("GameTooltip", "StatLogicTooltip", nil, "GameTooltipTemplate") --[[@as GameTooltip]]
tip:SetOwner(WorldFrame, "ANCHOR_NONE")

Expand Down Expand Up @@ -77,6 +77,7 @@ local pairs = pairs
local ipairs = ipairs
local type = type
local GetInventoryItemLink = GetInventoryItemLink
local GetSpellName = C_Spell.GetSpellName
local IsUsableSpell = IsUsableSpell
local UnitStat = UnitStat
local GetShapeshiftForm = GetShapeshiftForm
Expand All @@ -89,7 +90,7 @@ local tocversion = select(4, GetBuildInfo())
---------------
-- metatable for stat tables
local statTableMetatable = {
__index = function(t, k)
__index = function(_, k)
if k ~= "subclassID" then
return 0
end
Expand Down Expand Up @@ -163,8 +164,9 @@ end

---@class StatTable
---@field link string
---@field numLines number
---@field numLines integer
---@field inventoryType string
---@field subclassID Enum.ItemWeaponSubclass?
---@field [Stat] number

-- New table
Expand Down Expand Up @@ -720,7 +722,7 @@ do
for _, mods in pairs(modList) do
for _, mod in ipairs(mods) do
if mod.aura then -- if we got a buff
local name = GetSpellInfo(mod.aura)
local name = GetSpellName(mod.aura)
if name then
local aura = {}
if not mod.tab and mod.rank then
Expand Down Expand Up @@ -966,7 +968,7 @@ addon.StatModValidators = {
},
aura = {
validate = function(case, statModName)
return not not StatLogic:GetAuraInfo(GetSpellInfo(case.aura), StatLogic.StatModIgnoresAlwaysBuffed[statModName])
return not not StatLogic:GetAuraInfo(GetSpellName(case.aura), StatLogic.StatModIgnoresAlwaysBuffed[statModName])
end,
events = {
["UNIT_AURA"] = "player",
Expand Down Expand Up @@ -1098,7 +1100,7 @@ addon.StatModValidators = {
subclassID = select(7, C_Item.GetItemInfoInstant(weapon))
end
end
return subclassID and case.weapon[subclassID]
return subclassID and case.weapon[subclassID] or false
end,
events = {
["UNIT_INVENTORY_CHANGED"] = "player",
Expand Down Expand Up @@ -1296,11 +1298,11 @@ do
newValue = case.value
end
elseif case.aura and case.rank then
local aura = StatLogic:GetAuraInfo(GetSpellInfo(case.aura))
local aura = StatLogic:GetAuraInfo(GetSpellName(case.aura))
local rank = aura.rank
newValue = case.rank[rank]
elseif case.aura and case.stack then
local aura = StatLogic:GetAuraInfo(GetSpellInfo(case.aura))
local aura = StatLogic:GetAuraInfo(GetSpellName(case.aura))
newValue = case.stack * aura.stacks
elseif case.regen then
newValue = case.regen(level)
Expand All @@ -1309,7 +1311,7 @@ do
elseif case.level then
newValue = case.level[level]
elseif case.tooltip then
local aura = StatLogic:GetAuraInfo(GetSpellInfo(case.aura))
local aura = StatLogic:GetAuraInfo(GetSpellName(case.aura))
newValue = aura.tooltip
end

Expand Down Expand Up @@ -1467,9 +1469,9 @@ end

local function GetTotalWeaponSkill(unit)
if addon.class == "DRUID" and (
StatLogic:GetAuraInfo(GetSpellInfo(768), true)
or StatLogic:GetAuraInfo(GetSpellInfo(5487), true)
or StatLogic:GetAuraInfo(GetSpellInfo(9634), true)
StatLogic:GetAuraInfo(GetSpellName(768), true)
or StatLogic:GetAuraInfo(GetSpellName(5487), true)
or StatLogic:GetAuraInfo(GetSpellName(9634), true)
) then
return UnitLevel("player") * 5
else
Expand Down Expand Up @@ -2106,7 +2108,7 @@ function StatLogic:GetDiffID(item, ignoreEnchant, ignoreGems, ignoreExtraSockets
if inventoryType == "INVTYPE_WEAPON" then
linkDiff1 = GetInventoryItemLink("player", 16) or "NOITEM"
-- If player can Dual Wield, calculate offhand difference
if IsUsableSpell(GetSpellInfo(674)) then -- ["Dual Wield"]
if IsUsableSpell(GetSpellName(674)) then -- ["Dual Wield"]
local _, _, _, _, _, _, _, _, eqItemType = C_Item.GetItemInfo(linkDiff1)
-- If 2h is equipped, copy diff1 to diff2
if eqItemType == "INVTYPE_2HWEAPON" and not HasTitansGrip() then
Expand Down Expand Up @@ -2300,7 +2302,7 @@ if GetCurrentRegion() == 1 or GetCurrentRegion() == 72 and GetLocale() == "enUS"
end)

local sending = false
local function cleanUp(delay)
local function cleanUp()
-- Wait to see if whispers failed to send
C_Timer.After(2, function()
if not failure then
Expand All @@ -2316,17 +2318,10 @@ if GetCurrentRegion() == 1 or GetCurrentRegion() == 72 and GetLocale() == "enUS"
local function SendStoredData()
if failure or sending or UnitName("player") == target then return end
local data = RatingBuster.conversion_data.global
local send = false
for i = 0, 4 do
if data[i] then
send = true
break
end
end
if send then
if data and next(data) then
sending = true
local serialized = LibStub("LibSerialize"):Serialize(data)
local encoded = codec:Encode(serialized)
local encoded = codec and codec:Encode(serialized) or ""
LibStub("AceComm-3.0"):SendCommMessage(prefix, encoded, "WHISPER", target, "BULK", cleanUp, true)
end
end
Expand Down Expand Up @@ -2386,7 +2381,7 @@ if GetCurrentRegion() == 1 or GetCurrentRegion() == 72 and GetLocale() == "enUS"
--@debug@
local receive = {}
function receive:OnCommReceived(_, message)
local decoded = codec:Decode(message)
local decoded = codec and codec:Decode(message)
if not decoded then return end
local success, data = LibStub("LibSerialize"):Deserialize(decoded)
if not success then return end
Expand Down
10 changes: 0 additions & 10 deletions libs/StatLogic/TBC_Logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1341,11 +1341,6 @@ elseif addon.class == "WARLOCK" then
},
},
["MOD_PET_STA"] = {
-- Blessing of Kings
--{
-- ["value"] = 0.1,
-- ["condition"] = "UnitBuff('pet', GetSpellInfo(20217)) or UnitBuff('pet', GetSpellInfo(25898))",
--},
-- Warlock: Fel Stamina (Rank 3) - 2,9
-- Increases the Stamina of your Imp, Voidwalker, Succubus, and Felhunter and Felguard by 5%/10%/15% and increases your maximum health and mana by 1%/2%/3%.
{
Expand Down Expand Up @@ -1377,11 +1372,6 @@ elseif addon.class == "WARLOCK" then
},
},
["MOD_PET_INT"] = {
-- Blessing of Kings
--{
-- ["value"] = 0.1,
-- ["condition"] = "UnitBuff('pet', GetSpellInfo(20217)) or UnitBuff('pet', GetSpellInfo(25898))",
--},
-- Warlock: Fel Intellect (Rank 3) - 2,6
-- Increases the Stamina and Intellect of your Imp, Voidwalker, Succubus, Felhunter and Felguard by 15% and increases your maximum health and mana by 1%/2%/3%.
{
Expand Down
12 changes: 0 additions & 12 deletions libs/StatLogic/Wrath_Logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2699,13 +2699,6 @@ elseif addon.class == "WARLOCK" then
},
},
["MOD_PET_STA"] = {
-- 3.3.0 Imp stam total 233: pet base 118, player base 90, pet sta from player sta 0.75, pet kings 1.1, fel vitality 1.15
-- /dump floor((118+floor(90*0.75))*1.1)*1.05 = 233.45 match
-- /dump (118+floor(90*0.75))*1.1*1.05 = 224.025 wrong
--{
-- ["value"] = 0.1, -- BoK, BoSanc
-- ["condition"] = "UnitBuff('pet', GetSpellInfo(20217)) or UnitBuff('pet', GetSpellInfo(25898)) or UnitBuff('pet', GetSpellInfo(20911)) or UnitBuff('pet', GetSpellInfo(25899))",
--},
-- Warlock: Fel Vitality (Rank 3) - 2,7
-- Increases the Stamina and Intellect of your Imp, Voidwalker, Succubus, Felhunter and Felguard by 15% and increases your maximum health and mana by 1%/2%/3%.
{
Expand Down Expand Up @@ -2737,11 +2730,6 @@ elseif addon.class == "WARLOCK" then
},
},
["MOD_PET_INT"] = {
-- Blessings on pet
--{
-- ["value"] = 0.1,
-- ["condition"] = "UnitBuff('pet', GetSpellInfo(20217)) or UnitBuff('pet', GetSpellInfo(25898)) or UnitBuff('pet', GetSpellInfo(20911)) or UnitBuff('pet', GetSpellInfo(25899))",
--},
-- Warlock: Fel Vitality (Rank 3) - 2,7
-- Increases the Stamina and Intellect of your Imp, Voidwalker, Succubus, Felhunter and Felguard by 15% and increases your maximum health and mana by 1%/2%/3%.
{
Expand Down

0 comments on commit 7b27ca3

Please sign in to comment.