Skip to content

Commit

Permalink
Performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Aug 3, 2018
1 parent f49db01 commit 39e1995
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 43 deletions.
23 changes: 13 additions & 10 deletions REFlex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -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

Expand Down Expand Up @@ -792,21 +793,23 @@ 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

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
Expand Down
2 changes: 1 addition & 1 deletion REFlex.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions REFlexStructures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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"],
Expand Down
61 changes: 31 additions & 30 deletions REFlexUpdater.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 39e1995

Please sign in to comment.