From 235f5395a5ac5615ef310d08d0c05f61d7564193 Mon Sep 17 00:00:00 2001 From: Vapok Date: Thu, 18 Jun 2020 15:44:56 -0400 Subject: [PATCH] - Fixing additional race conditions on event firing and solving an issue with guild events not being ready at a specific time. --- init.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 5bd7cb95..01f1c371 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,7 @@ local L = core.L; local waitTable = {}; local waitFrame = nil; local lockouts = CreateFrame("Frame", "LockoutsFrame"); +local eventDelay = {}; -------------------------------------- -- Slash Command @@ -249,20 +250,29 @@ function MonDKP_OnEvent(self, event, arg1, ...) if event == "ADDON_LOADED" then if (arg1 ~= "MonolithDKP") then return end - core.InitStart = false core.IsOfficer = nil core.Initialized = false MonDKP_wait(2, DoInit, event, arg1); ---DoInit(event,arg1); self:UnregisterEvent("ADDON_LOADED") + return; end -- If core.DB is nil, that means that the addon hasn't fully initialized.. so let's wait 1 second and try again. if core.DB == nil then - C_Timer.After(1, function () MonDKP_OnEvent(self, event, arg1); end); + if eventDelay[event] == nil then + eventDelay[event] = 1; + else + eventDelay[event] = eventDelay[event] + 2; + end + C_Timer.After(eventDelay[event], function () MonDKP_OnEvent(self, event, arg1); end); return; end + if eventDelay[event] ~= nil then + eventDelay[event] = nil; + end + -- unregister unneccessary events if event == "CHAT_MSG_WHISPER" and not core.DB.modes.channels.whisper then self:UnregisterEvent("CHAT_MSG_WHISPER") @@ -341,7 +351,7 @@ function MonDKP_OnEvent(self, event, arg1, ...) end end elseif event == "GUILD_ROSTER_UPDATE" then - + if not core.InitStart then DoGuildUpdate(); end