Skip to content

Commit

Permalink
Fix LuaLS warnings
Browse files Browse the repository at this point in the history
This exposed a real bug: Ashran had a typo in UnregisterShortTermEvents,
this wasn't detected before because LuaLS didn't know the type of the
self parameter.
  • Loading branch information
emmericp committed Mar 2, 2024
1 parent 4c5e3bb commit 3cc13a3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
8 changes: 5 additions & 3 deletions DBM-PvP/Battlegrounds/Alterac.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod:AddBoolOption("AutoTurnIn")
do
local bgzone = false

local function Init(self)
function mod:Init()
local zoneID = DBM:GetCurrentArea()
if not bgzone and (zoneID == 30 or zoneID == 2197) then -- Regular AV (retail and classic), Korrak
bgzone = true
Expand Down Expand Up @@ -53,7 +53,7 @@ do
end

function mod:LOADING_SCREEN_DISABLED()
self:Schedule(1, Init, self)
self:ScheduleMethod(1, "Init")
end
mod.ZONE_CHANGED_NEW_AREA = mod.LOADING_SCREEN_DISABLED
mod.PLAYER_ENTERING_WORLD = mod.LOADING_SCREEN_DISABLED
Expand Down Expand Up @@ -103,7 +103,9 @@ do
end
end
elseif quest then
if GetItemCount(quest[1]) > quest[2] then
local questId = quest[1]
---@cast questId number
if GetItemCount(questId) > quest[2] then
SelectGossipAvailableQuest(1)
end
end
Expand Down
10 changes: 4 additions & 6 deletions DBM-PvP/Battlegrounds/Ashran.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ mod:AddBoolOption("AutoTurnIn")
do
local bgzone = false

local function Init(self)
function mod:Init()
local zoneID = DBM:GetCurrentArea()
if not bgzone and zoneID == 1191 then
bgzone = true
self:RegisterShortTermEvents(
"GOSSIP_SHOW",
"QUEST_PROGRESS",
"QUEST_COMPLETE"
"GOSSIP_SHOW"
)
if not self.tracker then
local generalMod = DBM:GetModByName("PvPGeneral")
Expand All @@ -35,7 +33,7 @@ do
end
elseif bgzone and zoneID ~= 1191 then
bgzone = false
self:UnregisterShormTermEvents()
self:UnregisterShortTermEvents()
if self.tracker then
self.tracker:Cancel()
self.tracker = nil
Expand All @@ -44,7 +42,7 @@ do
end

function mod:LOADING_SCREEN_DISABLED()
self:Schedule(1, Init, self)
self:ScheduleMethod(1, "Init")
end
mod.ZONE_CHANGED_NEW_AREA = mod.LOADING_SCREEN_DISABLED
mod.PLAYER_ENTERING_WORLD = mod.LOADING_SCREEN_DISABLED
Expand Down
4 changes: 2 additions & 2 deletions DBM-PvP/Battlegrounds/SeethingShore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod:RegisterEvents(
do
local bgzone = false

local function Init(self)
function mod:Init()
local zoneID = DBM:GetCurrentArea()
if not bgzone and zoneID == 1803 then
bgzone = true
Expand All @@ -27,7 +27,7 @@ do
end

function mod:LOADING_SCREEN_DISABLED()
self:Schedule(1, Init, self)
self:ScheduleMethod(1, "Init")
end
mod.ZONE_CHANGED_NEW_AREA = mod.LOADING_SCREEN_DISABLED
mod.PLAYER_ENTERING_WORLD = mod.LOADING_SCREEN_DISABLED
Expand Down
4 changes: 2 additions & 2 deletions DBM-PvP/Battlegrounds/SilvershardMines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod:RegisterEvents(
do
local bgzone = false

local function Init(self)
function mod:Init()
local zoneID = DBM:GetCurrentArea()
if not bgzone and zoneID == 727 then
bgzone = true
Expand All @@ -34,7 +34,7 @@ do
end

function mod:LOADING_SCREEN_DISABLED()
self:Schedule(1, Init, self)
self:ScheduleMethod(1, "Init")
end
mod.ZONE_CHANGED_NEW_AREA = mod.LOADING_SCREEN_DISABLED
mod.PLAYER_ENTERING_WORLD = mod.LOADING_SCREEN_DISABLED
Expand Down
3 changes: 1 addition & 2 deletions DBM-PvP/BloodMoon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ mod:RegisterEvents(
"LOADING_SCREEN_DISABLED",
"ZONE_CHANGED_NEW_AREA",
"PLAYER_ENTERING_WORLD",
"UPDATE_UI_WIDGET",
"UNIT_AURA player"
"UPDATE_UI_WIDGET"
)

local startTimer = mod:NewNextTimer(0, 436097)
Expand Down
24 changes: 15 additions & 9 deletions DBM-PvP/PvPGeneral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -657,26 +657,32 @@ do
end
if widgetID == 1671 or widgetID == 2074 then -- Standard battleground score predictor: 1671. Deepwind rework: 2074
local info = GetDoubleStatusBarWidgetVisualizationInfo(widgetID)
self:UpdateWinTimer(info.leftBarMax, info.leftBarValue, info.rightBarValue, allyBases, hordeBases)
if info then
self:UpdateWinTimer(info.leftBarMax, info.leftBarValue, info.rightBarValue, allyBases, hordeBases)
end
end
if widgetID == 1893 or widgetID == 1894 then -- Classic Arathi Basin
local totalScore = isWrath and 1600 or 2000
self:UpdateWinTimer(totalScore, tonumber(smatch(GetIconAndTextWidgetVisualizationInfo(1893).text, '(%d+)/' .. tostring(totalScore))), tonumber(smatch(GetIconAndTextWidgetVisualizationInfo(1894).text, '(%d+)/' .. tostring(totalScore))), allyBases, hordeBases)
end
elseif widgetID == 1683 then -- Temple Of Kotmogu
local widgetInfo = GetDoubleStateIconRowVisualizationInfo(1683)
for _, v in pairs(widgetInfo.leftIcons) do
if v.iconState == 1 then
allyBases = allyBases + 1
if widgetInfo then
for _, v in pairs(widgetInfo.leftIcons) do
if v.iconState == 1 then
allyBases = allyBases + 1
end
end
end
for _, v in pairs(widgetInfo.rightIcons) do
if v.iconState == 1 then
hordeBases = hordeBases + 1
for _, v in pairs(widgetInfo.rightIcons) do
if v.iconState == 1 then
hordeBases = hordeBases + 1
end
end
end
local info = GetDoubleStatusBarWidgetVisualizationInfo(1689)
self:UpdateWinTimer(info.leftBarMax, info.leftBarValue, info.rightBarValue, allyBases, hordeBases)
if info then
self:UpdateWinTimer(info.leftBarMax, info.leftBarValue, info.rightBarValue, allyBases, hordeBases)
end
end
end
mod.UPDATE_UI_WIDGET = mod.AREA_POIS_UPDATED
Expand Down

0 comments on commit 3cc13a3

Please sign in to comment.