-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdeathlog.lua
More file actions
executable file
·813 lines (750 loc) · 29 KB
/
deathlog.lua
File metadata and controls
executable file
·813 lines (750 loc) · 29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
--[[
Copyright 2026 Yazpad & Deathwing
The Deathlog AddOn is distributed under the terms of the GNU General Public License (or the Lesser GPL).
This file is part of Deathlog.
The Deathlog AddOn is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The Deathlog AddOn is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Deathlog AddOn. If not, see <http://www.gnu.org/licenses/>.
--]]
local addonName, addon = ...
-- API compatibility: Classic Era uses GetAddOnMetadata, TBC Anniversary uses C_AddOns.GetAddOnMetadata
local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata
local SOURCE = DeathNotificationLib.SOURCE
local function initVariables()
---@diagnostic disable: lowercase-global
deathlog_settings = deathlog_settings or {}
deathlog_data = deathlog_data or {}
deathlog_data_map = deathlog_data_map or {}
deathlog_watchlist_entries = deathlog_watchlist_entries or {}
deathlog_record_econ_stats = deathlog_record_econ_stats or {}
deathlog_entry_counts = deathlog_entry_counts or {}
deathlog_purged = deathlog_purged or {}
deathlog_precomputed = deathlog_precomputed or {}
deathlog_dev_data = deathlog_dev_data or {}
deathlog_char_data = deathlog_char_data or {}
---@diagnostic enable: lowercase-global
end
initVariables()
local sync_options -- forward declaration; populated after options table
local deathlog_sync_options_registered = false
local deathlog_minimap_button_stub = nil
local deathlog_minimap_button = LibStub("LibDataBroker-1.1"):NewDataObject(addonName, {
type = "data source",
text = addonName,
icon = "Interface\\TARGETINGFRAME\\UI-TargetingFrame-Skull",
OnClick = function(self, btn)
if btn == "LeftButton" then
if IsShiftKeyDown() then
DeathlogResetMenuPosition()
else
DeathlogToggleMenu(deathlog_data, DeathlogDataCopy.PRECOMPUTED_GENERAL_STATS, DeathlogDataCopy.PRECOMPUTED_LOG_NORMAL_PARAMS)
end
else
Settings.OpenToCategory(addonName)
end
end,
OnTooltipShow = function(tooltip)
tooltip:AddLine(addonName)
tooltip:AddLine(Deathlog_L.minimap_btn_left_click)
tooltip:AddLine(Deathlog_L.minimap_btn_shift_click)
tooltip:AddLine(Deathlog_L.minimap_btn_right_click .. GAMEOPTIONS_MENU)
end,
})
local function initMinimapButton()
deathlog_minimap_button_stub = LibStub("LibDBIcon-1.0", true)
if deathlog_minimap_button_stub:IsRegistered(addonName) then
return
end
if deathlog_settings.minimap == nil then
deathlog_settings.minimap = {}
end
deathlog_minimap_button_stub:Register(addonName, deathlog_minimap_button, deathlog_settings.minimap)
if deathlog_settings["show_minimap"] ~= nil and deathlog_settings["show_minimap"] == false then
deathlog_minimap_button_stub:Hide(addonName)
end
end
local function loadWidgets()
Deathlog_minilog_applySettings(true)
Deathlog_CRTWidget_applySettings()
Deathlog_CTTWidget_applySettings()
Deathlog_HIWidget_applySettings()
Deathlog_HWMWidget_applySettings()
DeathNotificationLib.UpdateDeathAlert()
Deathlog_ReportWidget_ApplySettings()
end
--- Initialize entry counters from existing data on first load.
--- Classifies legacy entries by inspecting available fields:
--- - Has both class_id and race_id → "self_death" (older clients only had addon-reported deaths with full data)
--- - Missing class_id or race_id → "blizzard" (Blizzard's HARDCORE_DEATHS channel reports lack these fields)
local function initEntryCounters()
if deathlog_entry_counts["initialized"] then
return
end
local total = 0
local self_death = 0
local blizzard = 0
for _, entries in pairs(deathlog_data) do
if type(entries) == "table" then
for _, entry in pairs(entries) do
total = total + 1
if entry["class_id"] and entry["race_id"] then
self_death = self_death + 1
else
blizzard = blizzard + 1
end
end
end
end
deathlog_entry_counts[SOURCE.SELF_DEATH] = self_death
deathlog_entry_counts[SOURCE.BLIZZARD] = blizzard
deathlog_entry_counts["total"] = total
deathlog_entry_counts["initialized"] = true
end
function Deathlog_LoadFromHardcore()
if Hardcore_Settings and Hardcore_Settings["death_log_entries"] then
print("Retrieving deathlog entries...")
local c = 0
local new_entries = 0
if deathlog_data == nil or deathlog_data["legacy"] == nil then
deathlog_data["legacy"] = {}
end
local local_deathlog_fletcher16 = Deathlog_fletcher16
for _, v in ipairs(Hardcore_Settings["death_log_entries"]) do
c = c + 1
local checksum = local_deathlog_fletcher16(v["name"], v["guild"], v["level"], v["source_id"])
local converted_date = DeathlogConvertStringDateUnix(v["date"])
if converted_date then
if deathlog_data["legacy"][checksum] == nil then
new_entries = new_entries + 1
end
deathlog_data["legacy"][checksum] = {
["class_id"] = v["class_id"],
["guild"] = v["guild"],
["date"] = converted_date,
["map_pos"] = v["map_pos"],
["source_id"] = v["source_id"],
["name"] = v["name"],
["race_id"] = v["race_id"],
["level"] = v["level"],
["map_id"] = v["map_id"],
["instance_id"] = v["instance_id"],
["played"] = v["played"],
["last_words"] = v["last_words"],
}
else
print("failed")
end
end
print("Complete. New entries: " .. new_entries .. ". Scanned: " .. c)
end
end
-- sync_options registered in handleEvent after loadWidgets() so it appears last in the sidebar
-- In-memory index: name_index[realmName][player_name] = { [checksum] = true, ... }
-- Allows efficient lookup of ALL existing entries for a player name (not just the latest).
-- Built lazily on first access per realm, maintained on insert/remove.
local name_index = {}
local function ensureNameIndex(realmName)
if name_index[realmName] then return end
name_index[realmName] = {}
for checksum, entry in pairs(deathlog_data[realmName] or {}) do
local n = entry["name"]
if n then
if not name_index[realmName][n] then
name_index[realmName][n] = {}
end
name_index[realmName][n][checksum] = true
end
end
end
local function newEntry(_player_data, _checksum, num_peer_checks, in_guild, source)
local realmName = GetRealmName()
if deathlog_data[realmName] == nil then
deathlog_data[realmName] = {}
end
if deathlog_data_map[realmName] == nil then
deathlog_data_map[realmName] = {}
end
ensureNameIndex(realmName)
local player_name = _player_data["name"]
local current_time = _player_data["date"] or GetServerTime()
-- Reject entries that were previously purged (e.g. false Feign Death)
local modified_cs = DeathNotificationLib.Fletcher16(_player_data)
if deathlog_purged[realmName] and deathlog_purged[realmName][modified_cs] then
return
end
if DeathlogDataCopy.PRECOMPUTED_PURGES[realmName] and DeathlogDataCopy.PRECOMPUTED_PURGES[realmName][modified_cs] then
return
end
-- Check ALL existing entries for this player name for near-duplicate deaths.
-- The old approach only checked the single latest entry via deathlog_data_map,
-- which missed duplicates when the latest entry was a different (newer) death.
local existing_checksums = name_index[realmName][player_name]
if existing_checksums then
for cs, _ in pairs(existing_checksums) do
local entry = deathlog_data[realmName][cs]
if entry then
local effective_level = math.max(tonumber(_player_data["level"]) or 0, tonumber(entry["level"]) or 0)
local time_diff = math.abs(current_time - (entry["date"] or 0))
if time_diff <= DeathNotificationLib.GetDedupWindow(effective_level) then
local existing_quality = DeathNotificationLib.EntryQuality(entry)
local new_quality = DeathNotificationLib.EntryQuality(_player_data)
if new_quality > existing_quality then
-- New entry has more data - merge and replace
_player_data = DeathNotificationLib.MergeEntries(_player_data, entry)
deathlog_data[realmName][cs] = nil
existing_checksums[cs] = nil
break
elseif new_quality < existing_quality then
-- Existing is better - merge new data into existing, skip
local merged = DeathNotificationLib.MergeEntries(entry, _player_data)
deathlog_data[realmName][cs] = merged
return
else
-- Equal quality - merge into existing, skip
local merged = DeathNotificationLib.MergeEntries(entry, _player_data)
deathlog_data[realmName][cs] = merged
return
end
end
else
-- Stale index entry, clean up
existing_checksums[cs] = nil
end
end
end
local modified_checksum = DeathNotificationLib.Fletcher16(_player_data)
deathlog_data[realmName][modified_checksum] = _player_data
-- Maintain name index
if not name_index[realmName][player_name] then
name_index[realmName][player_name] = {}
end
name_index[realmName][player_name][modified_checksum] = true
-- Only create widgets for self-reported deaths, peer broadcasts, and Blizzard notifications.
-- Death alert is now handled internally by DNL (~DeathAlert.lua) via createEntry().
if source == SOURCE.SELF_DEATH or source == SOURCE.PEER_BROADCAST or source == SOURCE.BLIZZARD then
Deathlog_widget_minilog_createEntry(_player_data)
end
deathlog_data_map[realmName][player_name] = modified_checksum
source = source or SOURCE.UNKNOWN
if deathlog_entry_counts then
deathlog_entry_counts[source] = (deathlog_entry_counts[source] or 0) + 1
deathlog_entry_counts["total"] = (deathlog_entry_counts["total"] or 0) + 1
end
end
--- One-time cleanup: scan existing deathlog_data for near-duplicate entries
--- (same player name, same level, date within getDedupWindow(level)) and merge
--- them, keeping the highest-quality entry. Runs synchronously on login.
--- Marks completion in deathlog_settings so it only runs once.
local DEDUP_CLEANUP_VERSION = 1 -- bump to re-run cleanup after future fixes
local function deathlog_runDedupCleanup()
if deathlog_settings["dedup_cleanup_version"] and deathlog_settings["dedup_cleanup_version"] >= DEDUP_CLEANUP_VERSION then
return
end
local total_removed = 0
for realmName, entries in pairs(deathlog_data) do
if type(entries) == "table" then
-- Build a local name → [{checksum, date, level, quality}] index
local by_name = {}
for cs, entry in pairs(entries) do
local n = entry["name"]
if n then
if not by_name[n] then by_name[n] = {} end
by_name[n][#by_name[n] + 1] = {
cs = cs,
date = entry["date"] or 0,
level = entry["level"] or 0,
quality = DeathNotificationLib.EntryQuality(entry),
}
end
end
-- For each name, detect and merge near-duplicates
for player_name, entry_list in pairs(by_name) do
if #entry_list > 1 then
-- Sort by date ascending
table.sort(entry_list, function(a, b) return a.date < b.date end)
local i = 1
while i <= #entry_list do
local j = i + 1
while j <= #entry_list do
local effective_level = math.max(entry_list[i].level, entry_list[j].level)
local time_diff = math.abs(entry_list[j].date - entry_list[i].date)
if time_diff <= DeathNotificationLib.GetDedupWindow(effective_level) then
-- Near-duplicate: keep the higher quality entry, merge data
local keep = entry_list[i]
local remove = entry_list[j]
if remove.quality > keep.quality then
keep, remove = remove, keep
entry_list[i] = keep
end
local keep_entry = entries[keep.cs]
local remove_entry = entries[remove.cs]
if keep_entry and remove_entry then
local merged = DeathNotificationLib.MergeEntries(keep_entry, remove_entry)
entries[keep.cs] = merged
entries[remove.cs] = nil
-- Update name_index if it exists
if name_index[realmName] and name_index[realmName][player_name] then
name_index[realmName][player_name][remove.cs] = nil
end
total_removed = total_removed + 1
end
table.remove(entry_list, j)
else
j = j + 1
end
end
i = i + 1
end
end
end
end
end
deathlog_settings["dedup_cleanup_version"] = DEDUP_CLEANUP_VERSION
if total_removed > 0 then
print("|cFF00FF00[Deathlog]|r Database cleanup: removed " .. total_removed .. " duplicate entries.")
end
end
local deathlog_initialized = false
local function deathlog_watchlistIconProvider(playerName)
if type(playerName) ~= "string" then return nil end
if type(deathlog_watchlist_entries) ~= "table" then return nil end
local watch = deathlog_watchlist_entries[playerName]
if type(watch) ~= "table" then return nil end
if type(watch.Icon) ~= "string" or watch.Icon == "" then return nil end
return watch.Icon
end
local function handleEvent(self, event, ...)
if event == "ADDON_LOADED" then
local loaded_addon = ...
if loaded_addon == addonName then
initVariables()
self:UnregisterEvent("ADDON_LOADED")
end
elseif event == "PLAYER_ENTERING_WORLD" then
if deathlog_initialized then return end
deathlog_initialized = true
initMinimapButton()
-- Write project id into settings
deathlog_settings["wow_project_id"] = WOW_PROJECT_ID
deathlog_settings["DeathAlert"] = deathlog_settings["DeathAlert"] or {}
deathlog_settings["DeathAlert"]["death_alert_options_parent"] = "Deathlog"
-- Ensure realm sub-tables exist so AttachAddon receives valid table
-- references (not nil) that remain in sync with newEntry.
local realmName = GetRealmName()
if deathlog_data[realmName] == nil then
deathlog_data[realmName] = {}
end
if deathlog_data_map[realmName] == nil then
deathlog_data_map[realmName] = {}
end
if deathlog_purged[realmName] == nil then
deathlog_purged[realmName] = {}
end
-- One-time dedup cleanup of existing data (runs before stats/widgets)
deathlog_runDedupCleanup()
local version = GetAddOnMetadata("Deathlog", "Version")
DeathNotificationLib.AttachAddon({
name = "Deathlog",
tag = "DLG",
isUnitTracked = Deathlog_isUnitTracked,
watchlistIconProvider = deathlog_watchlistIconProvider,
settings = deathlog_settings,
db = deathlog_data[realmName],
db_map = deathlog_data_map[realmName],
dev_data = deathlog_dev_data,
addon_version = version,
})
DeathNotificationLib.HookOnNewAddonEntry("Deathlog", newEntry)
if DeathlogDataCopy.PRECOMPUTED_GENERAL_STATS and DeathlogDataCopy.PRECOMPUTED_LOG_NORMAL_PARAMS and DeathlogDataCopy.PRECOMPUTED_KAPLAN_MEIER and DeathlogDataCopy.PRECOMPUTED_MOST_DEADLY_BY_ZONE and DeathlogDataCopy.PRECOMPUTED_PURGES then
deathlog_precomputed.PRECOMPUTED_GENERAL_STATS = nil
deathlog_precomputed.PRECOMPUTED_LOG_NORMAL_PARAMS = nil
deathlog_precomputed.PRECOMPUTED_KAPLAN_MEIER = nil
deathlog_precomputed.PRECOMPUTED_MOST_DEADLY_BY_ZONE = nil
deathlog_precomputed.PRECOMPUTED_PURGES = nil
else
if not (version == deathlog_precomputed.DD_VERSION and deathlog_precomputed.PRECOMPUTED_GENERAL_STATS and deathlog_precomputed.PRECOMPUTED_LOG_NORMAL_PARAMS and deathlog_precomputed.PRECOMPUTED_KAPLAN_MEIER and deathlog_precomputed.PRECOMPUTED_MOST_DEADLY_BY_ZONE and deathlog_precomputed.PRECOMPUTED_PURGES) then
deathlog_precomputed.DD_VERSION = version
deathlog_precomputed.PRECOMPUTED_GENERAL_STATS = Deathlog_calculate_statistics(deathlog_data)
deathlog_precomputed.PRECOMPUTED_LOG_NORMAL_PARAMS = Deathlog_calculateLogNormalParameters(deathlog_data)
deathlog_precomputed.PRECOMPUTED_KAPLAN_MEIER = Deathlog_calculateKaplanMeier(deathlog_data)
deathlog_precomputed.PRECOMPUTED_MOST_DEADLY_BY_ZONE = Deathlog_calculateMostDeadlyByZone(deathlog_data)
deathlog_precomputed.PRECOMPUTED_PURGES = Deathlog_calculatePurges(deathlog_data)
end
DeathlogDataCopy.PRECOMPUTED_GENERAL_STATS = deathlog_precomputed.PRECOMPUTED_GENERAL_STATS
DeathlogDataCopy.PRECOMPUTED_LOG_NORMAL_PARAMS = deathlog_precomputed.PRECOMPUTED_LOG_NORMAL_PARAMS
DeathlogDataCopy.PRECOMPUTED_KAPLAN_MEIER = deathlog_precomputed.PRECOMPUTED_KAPLAN_MEIER
DeathlogDataCopy.PRECOMPUTED_MOST_DEADLY_BY_ZONE = deathlog_precomputed.PRECOMPUTED_MOST_DEADLY_BY_ZONE
DeathlogDataCopy.PRECOMPUTED_PURGES = deathlog_precomputed.PRECOMPUTED_PURGES
end
if DeathNotificationLibDataCopy.HEATMAP_INTENSITY and DeathNotificationLibDataCopy.HEATMAP_CREATURE_SUBSET then
deathlog_precomputed.HEATMAP_INTENSITY = nil
deathlog_precomputed.HEATMAP_CREATURE_SUBSET = nil
else
if not (version == deathlog_precomputed.DNLD_VERSION and deathlog_precomputed.HEATMAP_INTENSITY and deathlog_precomputed.HEATMAP_CREATURE_SUBSET) then
local skull_locs = Deathlog_calculateSkullLocs(deathlog_data)
deathlog_precomputed.DNLD_VERSION = version
deathlog_precomputed.HEATMAP_INTENSITY = Deathlog_calculateHeatmapIntensity(skull_locs)
deathlog_precomputed.HEATMAP_CREATURE_SUBSET = Deathlog_calculateHeatmapCreatureSubset(skull_locs)
end
DeathNotificationLibDataCopy.HEATMAP_INTENSITY = deathlog_precomputed.HEATMAP_INTENSITY
DeathNotificationLibDataCopy.HEATMAP_CREATURE_SUBSET = deathlog_precomputed.HEATMAP_CREATURE_SUBSET
end
loadWidgets()
-- Check if we should show changelog popup (version upgrade)
if Deathlog_CheckShowChangelog then
Deathlog_CheckShowChangelog()
end
initEntryCounters()
C_Timer.After(2.5, function()
Deathlog_CheckCTA()
Deathlog_startHunterCleanup()
end)
if not deathlog_sync_options_registered then
deathlog_sync_options_registered = true
LibStub("AceConfig-3.0"):RegisterOptionsTable("DeathlogSync", sync_options)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("DeathlogSync", "Database Sync", "Deathlog")
end
end
end
local function SlashHandler(msg, editbox)
if msg == "option" or msg == "options" then
Settings.OpenToCategory(addonName)
elseif msg == "alert" then
DeathNotificationLib.TestDeathAlert()
elseif msg == "sync" then
DeathNotificationLib.SyncStatus()
elseif msg == "changelog" then
if Deathlog_ShowChangelog then
Deathlog_ShowChangelog()
end
else
DeathlogShowMenu(deathlog_data, DeathlogDataCopy.PRECOMPUTED_GENERAL_STATS, DeathlogDataCopy.PRECOMPUTED_LOG_NORMAL_PARAMS)
end
end
SLASH_DEATHLOG1, SLASH_DEATHLOG2 = "/deathlog", "/dl"
SlashCmdList["DEATHLOG"] = SlashHandler
local deathlog_event_handler = CreateFrame("Frame", "deathlog", nil, "BackdropTemplate")
deathlog_event_handler:RegisterEvent("ADDON_LOADED")
deathlog_event_handler:RegisterEvent("PLAYER_ENTERING_WORLD")
deathlog_event_handler:SetScript("OnEvent", handleEvent)
local LSM30 = LibStub("LibSharedMedia-3.0", true)
local options = {
name = addonName,
handler = Hardcore,
type = "group",
args = {
load_from_hc = {
type = "execute",
name = "Import deathlog from hardcore",
desc = "Import deathlog from hardcore. This will append entries.",
width = 1.3,
order = 1,
func = function()
Deathlog_LoadFromHardcore()
end,
},
clear_cache_button = {
type = "execute",
name = "Clear cache",
desc = "WARNING: This will remove deathlog data. Do this if your log is getting too long. The data is stored at _classic_era_/WTF/Account/<your_account_name>/SavedVariables/Deathlog.lua. Reload after doing this.",
width = 1.3,
order = 2,
func = function()
wipe(deathlog_data)
wipe(deathlog_data_map)
end,
},
peer_reporting = {
type = "toggle",
name = "Allow peer-reported deaths",
desc = "When enabled, deaths reported by party/raid members and tarnished soul detections from other players are accepted. When disabled, only self-reported deaths and Blizzard's hardcore death channel notifications are shown.",
width = 1.3,
order = 10,
get = function()
if deathlog_settings["peer_reporting"] == nil then
deathlog_settings["peer_reporting"] = true
end
return deathlog_settings["peer_reporting"]
end,
set = function()
deathlog_settings["peer_reporting"] = not deathlog_settings["peer_reporting"]
end,
},
accept_legacy_messages = {
type = "toggle",
name = "Accept legacy protocol messages",
desc = "When enabled, death messages from older addon versions (v0–v2 protocol) are accepted. When disabled, only current (v3) protocol messages are processed.",
width = 1.5,
order = 20,
get = function()
if deathlog_settings["legacy_messages"] == nil then
deathlog_settings["legacy_messages"] = true
end
return deathlog_settings["legacy_messages"]
end,
set = function()
deathlog_settings["legacy_messages"] = not deathlog_settings["legacy_messages"]
end,
},
show_addonless_deaths = {
type = "toggle",
name = "Allow addonless death logging",
desc = "When enabled, deaths received from Blizzard's HardcoreDeaths channel are converted into Deathlog entries. These entries have less detail (no race, class, or precise location) since the dying player isn't running the addon. Disable this if you only want full-quality addon-reported deaths in your log.",
width = 1.3,
order = 30,
get = function()
if deathlog_settings["addonless_logging"] == nil then
deathlog_settings["addonless_logging"] = false
end
return deathlog_settings["addonless_logging"]
end,
set = function()
deathlog_settings["addonless_logging"] = not deathlog_settings["addonless_logging"]
end,
},
auto_blizzard_deaths = {
type = "toggle",
name = "Auto-configure Blizzard death tracking",
desc = "When enabled, Deathlog automatically configures the Blizzard hardcore death CVars, joins the HardcoreDeaths channel (hidden), and periodically verifies they remain active. This lets us convert Blizzard's built-in death notifications into full Deathlog entries. If you don't want lower-quality data from these notifications, you can leave this on and disable 'Allow addonless death logging' instead.",
width = 1.5,
order = 35,
get = function()
if deathlog_settings["auto_blizzard_deaths"] == nil then
deathlog_settings["auto_blizzard_deaths"] = true
end
return deathlog_settings["auto_blizzard_deaths"]
end,
set = function()
deathlog_settings["auto_blizzard_deaths"] = not deathlog_settings["auto_blizzard_deaths"]
end,
},
auto_hide_chat_channels = {
type = "toggle",
name = "Auto-hide addon chat channels",
desc = "When enabled, Deathlog automatically hides its chat channels (death alerts, sync) from all chat frames so they don't clutter your chat windows. Disable this if you want to see the raw channel traffic for debugging.",
width = 1.3,
order = 36,
get = function()
if deathlog_settings["auto_hide_chat_channels"] == nil then
deathlog_settings["auto_hide_chat_channels"] = true
end
return deathlog_settings["auto_hide_chat_channels"]
end,
set = function()
deathlog_settings["auto_hide_chat_channels"] = not deathlog_settings["auto_hide_chat_channels"]
end,
},
share_playtime = {
type = "toggle",
name = "Include playtime in death report",
desc = "When enabled, your total /played time is included in your death broadcast so others can see how long you survived. Disable this if you prefer to keep your playtime private.",
width = 1.3,
order = 37,
get = function()
if deathlog_settings["share_playtime"] == nil then
deathlog_settings["share_playtime"] = true
end
return deathlog_settings["share_playtime"]
end,
set = function()
deathlog_settings["share_playtime"] = not deathlog_settings["share_playtime"]
end,
},
show_minimap_button = {
type = "toggle",
name = "Show minimap button",
desc = "Toggles whether the minimap button is visible.",
width = 1.3,
order = 40,
get = function()
if deathlog_settings["show_minimap"] == nil then
deathlog_settings["show_minimap"] = true
end
return deathlog_settings["show_minimap"]
end,
set = function()
deathlog_settings["show_minimap"] = not deathlog_settings["show_minimap"]
if not deathlog_minimap_button_stub then return end
if deathlog_settings["show_minimap"] then
deathlog_minimap_button_stub:Show(addonName)
else
deathlog_minimap_button_stub:Hide(addonName)
end
end,
},
colored_tooltips = {
type = "toggle",
name = "Colored tooltips",
desc = "Toggles whether tooltips have colored fields.",
width = 1.3,
order = 50,
get = function()
if deathlog_settings["colored_tooltips"] == nil then
deathlog_settings["colored_tooltips"] = false
end
return deathlog_settings["colored_tooltips"]
end,
set = function()
deathlog_settings["colored_tooltips"] = not deathlog_settings["colored_tooltips"]
end,
},
auto_refresh_search = {
type = "toggle",
name = "Auto-refresh search results",
desc = "When enabled, the Log tab automatically refreshes every 10 seconds so new deaths appear without reopening the UI. Only fires when on page 1 with no active filters.",
width = 1.3,
order = 55,
get = function()
if deathlog_settings["auto_refresh_search"] == nil then
deathlog_settings["auto_refresh_search"] = false
end
return deathlog_settings["auto_refresh_search"]
end,
set = function()
deathlog_settings["auto_refresh_search"] = not deathlog_settings["auto_refresh_search"]
end,
},
prediction_radius = {
type = "range",
name = "Source prediction radius",
desc = "Search radius (in map cells) when predicting the death source from heatmap data. Higher values may find matches further away but could be less accurate.",
width = 1.5,
order = 60,
min = 0,
max = 20,
step = 1,
get = function()
if deathlog_settings["prediction_radius"] == nil then
deathlog_settings["prediction_radius"] = 5
end
return deathlog_settings["prediction_radius"]
end,
set = function(_, val)
deathlog_settings["prediction_radius"] = val
end,
},
},
}
LibStub("AceConfig-3.0"):RegisterOptionsTable(addonName, options)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addonName, "Deathlog", nil)
sync_options = {
name = "Database Sync",
type = "group",
args = {
sync_desc = {
type = "description",
name = "Continuously sync death entries with other Deathlog users in the background. Peers exchange watermarks, manifests, and entries over a dedicated addon channel.",
fontSize = "medium",
order = 1,
},
sync_enabled = {
type = "toggle",
name = "Enable database sync",
desc = "Toggle background database sync on or off.",
width = 1.3,
order = 10,
get = function()
if deathlog_settings["sync_enabled"] == nil then
deathlog_settings["sync_enabled"] = true
end
return deathlog_settings["sync_enabled"]
end,
set = function()
deathlog_settings["sync_enabled"] = not deathlog_settings["sync_enabled"]
end,
},
sync_window_days = {
type = "range",
name = "Sync window (days)",
desc = "Only sync entries from the last N days. Larger windows exchange more data but cover more history. Set to -1 to sync ALL data.",
width = 1.5,
min = -1,
max = 30,
step = 1,
order = 20,
get = function()
if deathlog_settings["sync_window_days"] == nil then
deathlog_settings["sync_window_days"] = 7
end
return deathlog_settings["sync_window_days"]
end,
set = function(_, val)
deathlog_settings["sync_window_days"] = val
end,
},
sync_interval = {
type = "range",
name = "Watermark interval (seconds)",
desc = "How often to broadcast your watermark to other peers. Lower values detect gaps faster but generate more traffic.",
width = 1.5,
min = 60,
max = 3600,
step = 30,
order = 30,
get = function()
if deathlog_settings["sync_interval"] == nil then
deathlog_settings["sync_interval"] = 300
end
return deathlog_settings["sync_interval"]
end,
set = function(_, val)
deathlog_settings["sync_interval"] = val
end,
},
sync_max_entries = {
type = "range",
name = "Max entries per sync",
desc = "Maximum number of entries to request in a single sync session. Higher values catch up faster but use more bandwidth.",
width = 1.5,
min = 10,
max = 2000,
step = 10,
order = 40,
get = function()
if deathlog_settings["sync_max_entries"] == nil then
deathlog_settings["sync_max_entries"] = 500
end
return deathlog_settings["sync_max_entries"]
end,
set = function(_, val)
deathlog_settings["sync_max_entries"] = val
end,
},
sync_cooldown = {
type = "range",
name = "Sync cooldown (seconds)",
desc = "Minimum time between sync sessions. Lower values re-sync sooner after finishing but generate more traffic. Set to 0 to sync continuously.",
width = 1.5,
min = 0,
max = 3600,
step = 30,
order = 45,
get = function()
if deathlog_settings["sync_cooldown"] == nil then
deathlog_settings["sync_cooldown"] = 300
end
return deathlog_settings["sync_cooldown"]
end,
set = function(_, val)
deathlog_settings["sync_cooldown"] = val
end,
},
sync_status = {
type = "execute",
name = "Show sync status",
desc = "Print current sync status to chat (state, peer count, last sync time, cooldown).",
width = 1.3,
order = 50,
func = function()
DeathNotificationLib.SyncStatus()
end,
},
},
}