Skip to content

Commit

Permalink
Remove very old timers to fix scaling issue (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
fstenstrom authored Sep 8, 2024
1 parent 4800d44 commit e165190
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions WorldBossTimers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ local function FilterValidKillInfosStep1()
-- Find invalid:
local invalid = {};
for id, ki in pairs(WBT.db.global.kill_infos) do
--
if not KillInfo.IsValidID(id) then
invalid[id] = ki;
elseif not BossData.BossExists(ki.boss_name) then
Expand All @@ -780,17 +779,24 @@ end

-- Step2 is performed after deserialization and checks the internal data.
local function FilterValidKillInfosStep2()

-- Find invalid.
local invalid = {};
for id, ki in pairs(g_kill_infos) do
if not ki:IsValidVersion() then
table.insert(invalid, id);
invalid[id] = "Invalid version.";
elseif ki:GetSecondsSinceDeath() > (60*60*24) then
-- Discard timers older than a day. They are not useful, and the GUI doesn't
-- scale well. With about 500 timers (on a 2024 system) you'll get an FPS drop
-- every second during the main loop if the GUI is shown, even if no timers are
-- shown in it. This avoids that.
invalid[id] = "Timer is very old.";
end
end

-- Remove invalid.
for _, id in pairs(invalid) do
Logger.Debug("[PostDeserialize]: Removing invalid KI with ID: " .. id);
for id, msg in pairs(invalid) do
Logger.Debug("[PostDeserialize]: Removing KI with ID: " .. id .. ". Reason: " .. msg);
WBT.db.global.kill_infos[id] = nil;
end
end
Expand Down

0 comments on commit e165190

Please sign in to comment.