From 39e199523c06a65e80948a47ad614ab3bb93764c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 2 Aug 2018 11:25:03 +0200 Subject: [PATCH] Performance improvements --- REFlex.lua | 23 +++++++++-------- REFlex.toc | 2 +- REFlexStructures.lua | 4 +-- REFlexUpdater.lua | 61 ++++++++++++++++++++++---------------------- 4 files changed, 47 insertions(+), 43 deletions(-) diff --git a/REFlex.lua b/REFlex.lua index 4df98ba..d6efdc2 100644 --- a/REFlex.lua +++ b/REFlex.lua @@ -62,7 +62,7 @@ local RegisterAddonMessagePrefix = _G.C_ChatInfo.RegisterAddonMessagePrefix local SendAddonMessage = _G.C_ChatInfo.SendAddonMessage local ElvUI = _G.ElvUI -RE.Version = 253 +RE.Version = 254 RE.LastSquash = 1531828800 RE.FoundNewVersion = false @@ -79,6 +79,8 @@ RE.Season = 0 RE.LDBTime = 0 RE.LDBA = "" RE.LDBB = "" +RE.LDBUpdate = true +RE.LDBData = {["Won"] = 0, ["Lost"] = 0, ["HK"] = 0, ["Honor"] = 0} RE.SessionStart = time(date('!*t', GetServerTime())) RE.PlayerName = UnitName("PLAYER") @@ -387,6 +389,7 @@ function RE:OnEvent(_, event, ...) if RE.LDBTime == 0 then RE:UpdateLDBTime() end + RE.LDBUpdate = true RE:UpdateLDB() elseif event == "CHAT_MSG_COMBAT_HONOR_GAIN" then local d = GetDate() @@ -396,9 +399,7 @@ function RE:OnEvent(_, event, ...) RE.HDatabase[today] = 0 end RE.HDatabase[today] = RE.HDatabase[today] + points - if points >= 100 then - RE:UpdateLDB() - end + RE:UpdateLDB() end end @@ -792,8 +793,7 @@ function RE:UpdateLDBTime() if RE.Settings.LDBMode == 2 then RE.LDBTime = time(t) - RE.PlayerTimezone elseif RE.Settings.LDBMode == 3 then - local resetday, hour = RE:GetWeeklyResetDay(d.weekday) - t.hour = hour + local resetday = RE:GetWeeklyResetDay(d.weekday) RE.LDBTime = time(t) - (resetday * 86400) - RE.PlayerTimezone end end @@ -801,12 +801,15 @@ end function RE:UpdateLDB() local savedFilters = RE.Settings.Filters RE.Settings.Filters = {["Spec"] = _G.ALL, ["Map"] = 1, ["Bracket"] = 1, ["Date"] = {RE.LDBTime, 0}, ["Season"] = 0} - local _, _, hk = RE:GetStats(1, nil, false) - local honor = RE:GetHonor() - local won, lost = RE:GetWinNumber(1, nil) + if RE.LDBUpdate then + RE.LDBUpdate = false + RE.LDBData.HK = select(3, RE:GetStats(1, nil, false)) + RE.LDBData.Won, RE.LDBData.Lost = RE:GetWinNumber(1, nil) + end + RE.LDBData.Honor = RE:GetHonor() RE.Settings.Filters = savedFilters - RE.LDBA = "|cFF00FF00"..won.."|r|cFF9D9D9D-|r|cFFFF141C"..lost.."|r |cFF9D9D9D|||r |cFFCC9900"..honor.."|r |cFF9D9D9D|||r "..hk + RE.LDBA = "|cFF00FF00"..RE.LDBData.Won.."|r|cFF9D9D9D-|r|cFFFF141C"..RE.LDBData.Lost.."|r |cFF9D9D9D|||r |cFFCC9900"..RE.LDBData.Honor.."|r |cFF9D9D9D|||r "..RE.LDBData.HK RE.LDBB = RE:RatingChangeClean(RE.RatingChange[1], false).." |cFF9D9D9D|||r "..RE:RatingChangeClean(RE.RatingChange[2], false).." |cFF9D9D9D|||r "..RE:RatingChangeClean(RE.RatingChange[4], false) if ElvUI then RE.LDBA = "|TInterface\\PvPRankBadges\\PvPRank09:0|t "..RE.LDBA diff --git a/REFlex.toc b/REFlex.toc index 74f6dfc..0b149a9 100644 --- a/REFlex.toc +++ b/REFlex.toc @@ -1,7 +1,7 @@ ## Interface: 80000 ## Title: |cFF74D06CRE|rFlex ## Notes: Collect statistics of played arena matches and battlegrounds. -## Version: 2.5.3 +## Version: 2.5.4 ## Author: AcidWeb ## SavedVariablesPerCharacter: REFlexSettings, REFlexDatabase, REFlexHonorDatabase ## X-Website: https://www.curseforge.com/wow/addons/reflex-battleground-historian diff --git a/REFlexStructures.lua b/REFlexStructures.lua index 2f5b04c..b5eac52 100644 --- a/REFlexStructures.lua +++ b/REFlexStructures.lua @@ -186,7 +186,7 @@ RE.AceConfig = { [2] = _G.HONOR_TODAY, [3] = _G.GUILD_CHALLENGES_THIS_WEEK }, - set = function(_, val) RE.Settings.LDBMode = val; RE:UpdateLDBTime(); RE:UpdateLDB() end, + set = function(_, val) RE.Settings.LDBMode = val; RE.LDBUpdate = true; RE:UpdateLDBTime(); RE:UpdateLDB() end, get = function(_) return RE.Settings.LDBMode end }, deletebase = { @@ -196,7 +196,7 @@ RE.AceConfig = { width = "double", confirm = true, order = 5, - func = function() _G.REFlexDatabase = {}; ReloadUI() end + func = function() _G.REFlexDatabase = {}; _G.REFlexHonorDatabase = {}; ReloadUI() end }, deleteoldseason = { name = L["Purge previous seasons"], diff --git a/REFlexUpdater.lua b/REFlexUpdater.lua index 4cd8615..310adcb 100644 --- a/REFlexUpdater.lua +++ b/REFlexUpdater.lua @@ -4,62 +4,63 @@ local _, RE = ... local mfloor = _G.math.floor function RE:UpdateSettings() - if RE.Settings.ConfigVersion ~= RE.Version then + if RE.Settings.ConfigVersion < 250 then if RE.Settings.ConfigVersion < 220 then RE.Settings.CurrentTab = 1 RE.Settings.Filters = {["Spec"] = _G.ALL, ["Map"] = 1, ["Bracket"] = 1, ["Date"] = {0, 0}, ["DateMode"] = 1} RE.Settings.ConfigVersion = 220 end + if RE.Settings.ConfigVersion < 234 then RE.Settings.Filters.Season = 0 RE.Settings.ConfigVersion = 234 end + if RE.Settings.ConfigVersion < 240 then RE.Settings.LDBMode = 2 RE.Settings.LDBSide = "A" RE.Settings.ConfigVersion = 240 end - if RE.Settings.ConfigVersion < 250 then - if not RE.Settings.Filters.DateMode then - RE.Settings.Filters.DateMode = 1 - end - RE.Settings.ConfigVersion = 250 + + if not RE.Settings.Filters.DateMode then + RE.Settings.Filters.DateMode = 1 end + RE.Settings.ConfigVersion = 250 end end function RE:UpdateDatabase() for i=1, #RE.Database do - if RE.Database[i].Version < 224 then - if RE.Database[i].Map == 1681 then - RE.Database[i].Map = 529 - RE.Database[i].isBrawl = true - else - RE.Database[i].isBrawl = false + if RE.Database[i].Version < 235 then + if RE.Database[i].Version < 224 then + if RE.Database[i].Map == 1681 then + RE.Database[i].Map = 529 + RE.Database[i].isBrawl = true + else + RE.Database[i].isBrawl = false + end + RE.Database[i].Version = 224 end - RE.Database[i].Version = 224 - end - if RE.Database[i].Version < 225 then - if RE.Database[i].Map == 562 then - RE.Database[i].Map = 1672 + if RE.Database[i].Version < 225 then + if RE.Database[i].Map == 562 then + RE.Database[i].Map = 1672 + end + if RE.Database[i].Map == 559 then + RE.Database[i].Map = 1505 + end + RE.Database[i].Version = 225 end - if RE.Database[i].Map == 559 then - RE.Database[i].Map = 1505 - end - RE.Database[i].Version = 225 - end - if RE.Database[i].Version < 230 then - if not RE.Database[i].PlayerNum or RE.Database[i].Map == 1170 then - RE.Database[i].Hidden = true - else - RE.Database[i].Hidden = false + if RE.Database[i].Version < 230 then + if not RE.Database[i].PlayerNum or RE.Database[i].Map == 1170 then + RE.Database[i].Hidden = true + else + RE.Database[i].Hidden = false + end + RE.Database[i].Version = 230 end - RE.Database[i].Version = 230 - end - if RE.Database[i].Version < 235 then if RE.Database[i].isArena and RE.Database[i].isRated and RE.Database[i].isBrawl then RE.Database[i].Hidden = true end