Skip to content

Commit 4530161

Browse files
committed
Create workaround for group loot duplicate item messages
Some servers duplicate LOOT_ITEM_SELF and LOOT_ROLL_WON for the same item in groups. This is a bug, and this commit detects the duplication within a short time (1 second) to discard the duplicate.
1 parent bb5d09f commit 4530161

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

FonzAppraiser.toc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
## Title: FonzAppraiser
33
## Notes: Tracks the value of personal loot. Command: /fa.
44
## Author: fondlez
5-
## Version: 3.1.0
6-
## OptionalDeps: aux-addon, Auctioneer, Auctionator, TradeSkillMaster
5+
## Version: 3.1.1
6+
## OptionalDeps: aux-addon, Auctioneer, Auc-Advanced, Auctionator, TradeSkillMaster
77
## X-Website: http://github.com/fondlez
88
## X-Category: Inventory
99
## SavedVariables: FonzAppraiserDB

changelog.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
local A = FonzAppraiser
22

3-
A.HELP_VERSION = [[Version 3.1.0 - 2024-11-02 |cffffffff
3+
A.HELP_VERSION = [[Version 3.1.1 - 2024-11-16 |cffffffff
4+
[*] Updated the detection method for money from personal loot.
5+
[*] Workaround for bug on some servers where group loot messages duplicate items.
6+
7+
|rVersion 3.1.0 - 2024-11-02 |cffffffff
48
[+] Auctioneer Advanced Suite ("Auc-Advanced" addon) added into the Auctioneer
59
pricing system.
610

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.1.1] - 2024-11-16
9+
10+
### Changed
11+
12+
- Updated the detection method for money from personal loot.
13+
14+
## Fixed
15+
16+
- Workaround for bug on some servers where group loot messages duplicate items.
17+
818
## [3.1.0] - 2024-11-02
919

1020
### Added

core.lua

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ do
6464
end
6565

6666
do
67+
local GetTime = GetTime
68+
6769
local find = string.find
6870
local makeStoreToken = util.makeStoreToken
6971
local parseItemLink = util.parseItemLink
@@ -78,20 +80,53 @@ do
7880
-- e.g. "You won: [Heavy Leather]"
7981
local PATTERN_ITEM_LOOT_WON = "^You won: (.+)"
8082

83+
local LOOT_TYPE_SELF = 0
84+
local LOOT_TYPE_WON = 1
85+
86+
local loot_type
87+
local last_loot_time, last_won_code, last_self_code
88+
89+
local function seenTooSoon(loot_time)
90+
return (GetTime() - loot_time) < 1
91+
end
92+
8193
function A:CHAT_MSG_LOOT(msg)
8294
local loot_string
8395
_, _, loot_string = find(msg, PATTERN_ITEM_LOOT_SELF)
84-
if not loot_string then
96+
if loot_string then
97+
loot_type = LOOT_TYPE_SELF
98+
else
8599
_, _, loot_string = find(msg, PATTERN_ITEM_LOOT_WON)
86100
if not loot_string then return end
101+
loot_type = LOOT_TYPE_WON
87102
end
88103

89104
local item_link, _, id, code = parseItemLink(loot_string)
90-
local _, _, count = find(loot_string, PATTERN_ITEM_LOOT_SELF_COUNT)
91-
count = count and tonumber(count) or 1
105+
if code then
106+
-- Check for immediate duplicate item loot messages across loot types
107+
if last_loot_time then
108+
if loot_type == LOOT_TYPE_SELF then
109+
last_self_code = code
110+
if last_won_code and code == last_won_code
111+
and seenTooSoon(last_loot_time) then
112+
last_loot_time = nil -- Found the Self duplicate message, so reset
113+
return
114+
end
115+
elseif loot_type == LOOT_TYPE_WON then
116+
last_won_code = code
117+
if last_self_code and code == last_self_code
118+
and seenTooSoon(last_loot_time) then
119+
last_loot_time = nil -- Found the Won duplicate message, so reset
120+
return
121+
end
122+
end
123+
end
124+
125+
last_loot_time = GetTime()
92126

93-
if code then
94127
local token = makeStoreToken(code)
128+
local _, _, count = find(loot_string, PATTERN_ITEM_LOOT_SELF_COUNT)
129+
count = count and tonumber(count) or 1
95130

96131
if A:isEnabled() and filter.itemMatchQuality(id) then
97132
local value = pricing.value(token)

0 commit comments

Comments
 (0)