Skip to content

Commit a9b9796

Browse files
committed
Fixing an issue tracking debuffs by spellID with multiple raid-debuffs statuses (GH issue #289)
Added a clean database option in raiddebuffs configuration.
1 parent e71d780 commit a9b9796

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

RaidDebuffs/Grid2RaidDebuffs.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ function class:LoadZoneSpells()
339339
end
340340
spells_count = spells_count + self.spells_count
341341
if GSRD.debugging then
342-
GSRD:Debug("Zone[%s] C_MapID[%d] EjID[%d] mapID[%d] Status [%s]: %d raid debuffs loaded from [%d]", instance_map_name, instance_bmap_id, instance_ej_id, instance_map_id, self.name, spells_count, (debuffs[instance_map_id] and instance_map_id) or (debuffs[instance_ej_id] and instance_ej_id) )
342+
GSRD:Debug("Zone[%s] C_MapID[%d] EjID[%d] mapID[%d] Status [%s]: %d raid debuffs loaded from [%d]", instance_map_name, instance_bmap_id, instance_ej_id, instance_map_id, self.name, self.spells_count, (debuffs[instance_map_id] and instance_map_id) or (debuffs[instance_ej_id] and instance_ej_id) )
343343
end
344344
end
345345
end

RaidDebuffsOptions/OptionsAdvanced.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ local function StatusDisableDebuff(spellId)
342342
local status = debuffsStatuses[spellId]
343343
if status then
344344
local index = debuffsIndexes[spellId]
345-
DbDelTableValue( spellId, status.dbx.debuffs, visibleInstance)
345+
DbDelTableValue(spellId, status.dbx.debuffs, visibleInstance)
346+
DbDelTableValue(-spellId, status.dbx.debuffs, visibleInstance)
346347
debuffsStatuses[spellId] = nil
347348
debuffsIndexes[spellId] = nil
348349
for k,v in pairs(debuffsStatuses) do

RaidDebuffsOptions/OptionsGeneral.lua

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,57 @@ do
279279
} }
280280
end
281281

282+
-- db maintenance
283+
do
284+
local function IsZoneEnabled(zoneID) -- check if the zone belongs to any enabled module.
285+
for module in pairs(RDO.db.profile.enabledModules) do
286+
local zones = RDO.RDDB[module]
287+
if zones and zones[zoneID] then
288+
return true
289+
end
290+
end
291+
return RDO.RDDB['[Custom Debuffs]'][zoneID] ~= nil
292+
end
293+
294+
local function RemoveDisabledZones()
295+
local delete, zcount, dcount = {}, 0, 0
296+
for _,status in ipairs(RDO.statuses) do
297+
local debuffs = status.dbx.debuffs
298+
for zone in pairs(debuffs) do
299+
if not IsZoneEnabled(zone) then
300+
delete[zone] = debuffs
301+
zcount = zcount + 1
302+
dcount = dcount + #debuffs[zone]
303+
end
304+
end
305+
end
306+
if zcount>0 or dcount>0 then
307+
Grid2Options:ConfirmDialog(string.format(L["Raid Debuffs Warning:\n %d zones and %d orphan raid debuffs has been detectetd. Do you want to remove this information ?"], zcount, dcount), function()
308+
for zone, debuffs in pairs(delete) do
309+
debuffs[zone] = nil
310+
end
311+
RDO:UpdateZoneSpells()
312+
RDO:RefreshAdvancedOptions()
313+
print("Grid2RaidDebuffs database maintenance finished.")
314+
end)
315+
else
316+
Grid2Options:MessageDialog(L["Raid debuffs database is OK, nothing to clean."])
317+
end
318+
end
319+
320+
options.maintenance = { type = "group", order = 20, name = L["Maintenance"], inline= true, args = {
321+
clean = {
322+
type = "execute",
323+
order = 10,
324+
name = L["Clean Database"],
325+
desc = L["Clean the database removing orphan raid debuffs."],
326+
func = function(info)
327+
RemoveDisabledZones()
328+
end,
329+
}
330+
} }
331+
end
332+
282333
----------------------------------------------------------------------
283334
--
284335
----------------------------------------------------------------------

0 commit comments

Comments
 (0)