Rework duel detectioner
The prevoius implementation was so stupid...
This commit is contained in:
@@ -13,8 +13,6 @@ function data.DeathReporter.Init()
|
||||
local recentDeaths = {}
|
||||
---@type table<string, number>
|
||||
local recentDuels = {}
|
||||
---@type table<string, number>
|
||||
local notifyTimers = {}
|
||||
|
||||
---@param source string
|
||||
---@param destination string
|
||||
@@ -38,7 +36,18 @@ function data.DeathReporter.Init()
|
||||
end
|
||||
|
||||
recentDeaths[destination] = GetTime()
|
||||
local timer = C_Timer.NewTimer(3, function()
|
||||
C_Timer.NewTimer(3, function()
|
||||
if recentDuels[destination]
|
||||
and GetTime() - recentDuels[destination] < data.config.deathReporter.duelThrottle then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||
return
|
||||
end
|
||||
if recentDuels[source]
|
||||
and GetTime() - recentDuels[source] < data.config.deathReporter.duelThrottle then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||
return
|
||||
end
|
||||
|
||||
local zone = data.config.deathReporter.zoneOverride
|
||||
if not zone then
|
||||
zone = string.format("%s (%s)", GetZoneText(), GetSubZoneText())
|
||||
@@ -68,9 +77,7 @@ function data.DeathReporter.Init()
|
||||
table.insert(data.messenger.queue, msg)
|
||||
end
|
||||
end
|
||||
notifyTimers[destination] = nil
|
||||
end)
|
||||
notifyTimers[destination] = timer
|
||||
end
|
||||
|
||||
local cleuFrame = CreateFrame("Frame")
|
||||
@@ -97,9 +104,7 @@ function data.DeathReporter.Init()
|
||||
systemMessageFrame:SetScript("OnEvent", function(self, event, msg)
|
||||
local source, destination = string.match(msg, "(.+) has defeated (.+) in a duel")
|
||||
if source and destination then
|
||||
print(string.format("Cancelling death reports for %s and %s", source, destination))
|
||||
if notifyTimers[source] then notifyTimers[source]:Cancel() end
|
||||
if notifyTimers[destination] then notifyTimers[destination]:Cancel() end
|
||||
print(string.format("Detected duel between %s and %s", source, destination))
|
||||
local now = GetTime()
|
||||
recentDuels[source] = now
|
||||
recentDuels[destination] = now
|
||||
|
||||
Reference in New Issue
Block a user