added "Func Call Spam Protection" for "BAG_UPDATE" Event in "DataStore_Containers" file
This commit is contained in:
@@ -12,7 +12,7 @@ if not DataStore then return end
|
|||||||
|
|
||||||
local addonName = "DataStore_Containers"
|
local addonName = "DataStore_Containers"
|
||||||
|
|
||||||
_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceComm-3.0", "AceSerializer-3.0")
|
_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceComm-3.0", "AceSerializer-3.0", "AceTimer-3.0")
|
||||||
|
|
||||||
local addon = _G[addonName]
|
local addon = _G[addonName]
|
||||||
|
|
||||||
@@ -22,6 +22,9 @@ local BI = LibStub("LibBabble-Inventory-3.0"):GetLookupTable()
|
|||||||
|
|
||||||
local guildMembers = {} -- hash table containing guild member info (tab timestamps)
|
local guildMembers = {} -- hash table containing guild member info (tab timestamps)
|
||||||
|
|
||||||
|
-- Func Call Spam Protection
|
||||||
|
local FCSP_timer_table_OnBagUpdate = {}
|
||||||
|
|
||||||
-- Message types
|
-- Message types
|
||||||
local MSG_SEND_BANK_TIMESTAMPS = 1 -- broacast at login
|
local MSG_SEND_BANK_TIMESTAMPS = 1 -- broacast at login
|
||||||
local MSG_BANK_TIMESTAMPS_REPLY = 2 -- reply to someone else's login
|
local MSG_BANK_TIMESTAMPS_REPLY = 2 -- reply to someone else's login
|
||||||
@@ -396,19 +399,38 @@ end
|
|||||||
|
|
||||||
-- *** Event Handlers ***
|
-- *** Event Handlers ***
|
||||||
local function OnBagUpdate(event, bag)
|
local function OnBagUpdate(event, bag)
|
||||||
if bag < 0 then
|
FCSP_timer_table_OnBagUpdate[bag] = nil -- manual reset (safety redundancy)
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if (bag >= 5) and (bag <= 11) and not addon.isBankOpen then
|
-- if bag < 0 then
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
|
|
||||||
|
-- if (bag >= 5) and (bag <= 11) and not addon.isBankOpen then
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- print("DataStore_Containers.lua -- OnBagUpdate(event, ",bag,")", DEBUG_CNT, format("%.3f",GetTime()%100)) -- DEBUG 2025 07 21 - 2
|
||||||
|
|
||||||
if bag == 0 then -- bag is 0 for both the keyring and the original backpack
|
if bag == 0 then -- bag is 0 for both the keyring and the original backpack
|
||||||
ScanKeyRing()
|
ScanKeyRing()
|
||||||
end
|
end
|
||||||
ScanBag(bag)
|
ScanBag(bag)
|
||||||
end
|
end
|
||||||
|
local function FCSP_OnBagUpdate(event, bag)
|
||||||
|
-- this function limits calls to "OnBagUpdate" to max 1 every second
|
||||||
|
|
||||||
|
-- old limitations from "OnBagUpdate"
|
||||||
|
if bag < 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if (bag >= 5) and (bag <= 11) and not addon.isBankOpen then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if FCSP_timer_table_OnBagUpdate[bag] then return end
|
||||||
|
FCSP_timer_table_OnBagUpdate[bag] = addon:ScheduleTimer(OnBagUpdate, 1, event, bag)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
local function OnBankFrameClosed()
|
local function OnBankFrameClosed()
|
||||||
addon.isBankOpen = nil
|
addon.isBankOpen = nil
|
||||||
@@ -806,7 +828,8 @@ function addon:OnEnable()
|
|||||||
end
|
end
|
||||||
ScanKeyRing()
|
ScanKeyRing()
|
||||||
|
|
||||||
addon:RegisterEvent("BAG_UPDATE", OnBagUpdate)
|
-- addon:RegisterEvent("BAG_UPDATE", OnBagUpdate)
|
||||||
|
addon:RegisterEvent("BAG_UPDATE", FCSP_OnBagUpdate)
|
||||||
addon:RegisterEvent("BANKFRAME_OPENED", OnBankFrameOpened)
|
addon:RegisterEvent("BANKFRAME_OPENED", OnBankFrameOpened)
|
||||||
addon:RegisterEvent("GUILDBANKFRAME_OPENED", OnGuildBankFrameOpened)
|
addon:RegisterEvent("GUILDBANKFRAME_OPENED", OnGuildBankFrameOpened)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user