Skip to content

Commit

Permalink
release 1.2.0: performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Sentilix committed Jul 10, 2022
1 parent 97624d1 commit 17120b6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 16 deletions.
Binary file added Releases/nrg-1.2.0.zip
Binary file not shown.
19 changes: 14 additions & 5 deletions nrg/Battery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,28 @@ function A:HandleRXVersion(message, sender)
self:echo(string.format("[%s] is using NRG version %s", sender, message))
end;

A.frameSkipDefault = 4; -- Skip every Nth frame
A.frameSkipCounter = 0; -- (Internal) frame counter
A.lastManaValue = -1; -- (Internal) last mana value
A.lastManaAlphaValue = 0.00; -- (Internal) last alpha value
A.manaAlphaValueDecay = 0.05;

function A:OnTimer(elapsed)
self.timerTick = self.timerTick + elapsed

if A.enabledForPlayer then
A:CheckManaUpdates();
self.frameSkipCounter = self.frameSkipCounter - 1;
if self.frameSkipCounter < 0 then
self.frameSkipCounter = self.frameSkipDefault;
self:CheckManaUpdates();
end;
end;

if self.timerTick > (self.nextPowerStep + self.powerFrequency) then
self:AdvancePower();
self.nextPowerStep = self.timerTick;

A.manaAlphaValueDecay = 1 / (GetFramerate() * 2 / A.frameSkipDefault);
end;
end;

Expand All @@ -320,9 +332,6 @@ function A:IsEligibleForReset(unitid, spellID)
return true;
end;

A.lastManaValue = -1;
A.lastManaAlphaValue = 0.00;
A.manaAlphaValueDecay = 0.5 / GetFramerate();
function A:CheckManaUpdates()
if disableUpdates then
return;
Expand Down Expand Up @@ -371,7 +380,7 @@ function A:OnEvent(object, event, ...)
-- TODO: Do we need Dispell actions too?
if NRG_ValidSubEvents[subevent] then
-- Only react on magic stuff:
local spellId, _, spellSchool = select(12, CombatLogGetCurrentEventInfo());
local spellId, spellName, spellSchool = select(12, CombatLogGetCurrentEventInfo());
if spellSchool and bit.band(spellSchool, 0x07e) > 0 then
self:ResetPower();
end;
Expand Down
16 changes: 8 additions & 8 deletions nrg/DigamAddonLib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


local DIGAM_IsDebugBuild = false;
local DIGAM_BuildVersion = 5;
local DIGAM_BuildVersion = 6;

local DIGAM_COLOR_BEGIN = "|c80";
local DIGAM_CHAT_END = "|r";
Expand Down Expand Up @@ -66,7 +66,7 @@ function DigamAddonLib:new(addonSettings)
addonAuthor = GetAddOnMetadata(_addonName, "Author") or "",
addonExpansionLevel = tonumber(GetAddOnMetadata(_addonName, "X-Expansion-Level")),

localPlayerName = self:getPlayerAndRealm("player", true),
localPlayerName = self:getPlayerAndRealm("player"),
localPlayerClass = self:getUnitClass("player"),
localPlayerRealm = self:getPlayerRealm("player"),
localPlayerGUID = UnitGUID("player"),
Expand Down Expand Up @@ -290,7 +290,7 @@ function DigamAddonLib:stripRealmName(nameAndRealm)
end;

function DigamAddonLib:getFullPlayerName(playerName)
local _, _, name, realm = string.find(playerName, "([^-]*)-(%S*)");
local _, _, name, realm = string.find(playerName, "([^-]*)-([%S ]*)");

if realm then
if string.find(realm, " ") then
Expand All @@ -305,15 +305,15 @@ function DigamAddonLib:getFullPlayerName(playerName)
return name .."-".. realm;
end;

function DigamAddonLib:getPlayerAndRealm(unitid, stripSpaces)
function DigamAddonLib:getPlayerAndRealm(unitid, keepRealmnameSpaces)
local playername, realmname = UnitName(unitid);
if not playername then return nil; end;

if not realmname or realmname == "" then
realmname = GetRealmName();
end;

if stripSpaces and string.find(realmname, " ") then
if not keepRealmnameSpaces and string.find(realmname, " ") then
local _, _, name1, name2 = string.find(realmname, "([a-zA-Z]*) ([a-zA-Z]*)");
realmname = name1 .. name2;
end;
Expand Down Expand Up @@ -364,15 +364,15 @@ function DigamAddonLib:unitClass(unitid)
return classname;
end;

function DigamAddonLib:getUnitidFromName(playerName)
function DigamAddonLib:getUnitidFromName(playerName, keepRealmnameSpaces)
local unitid, unitname;
if IsInRaid() then
for n = 1, 40, 1 do
unitid = "raid"..n;
unitname = UnitName(unitid);
if not unitname then return nil; end;

unitname = self:getPlayerAndRealm(unitid);
unitname = self:getPlayerAndRealm(unitid, keepRealmnameSpaces);
if playerName == unitname then
return unitid;
end;
Expand All @@ -385,7 +385,7 @@ function DigamAddonLib:getUnitidFromName(playerName)
unitid = "player";
end;

unitname = self:getPlayerAndRealm(unitid);
unitname = self:getPlayerAndRealm(unitid, keepRealmnameSpaces);
if playerName == unitname then
return unitid;
end;
Expand Down
4 changes: 4 additions & 0 deletions nrg/ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ No config, no switches, no nothing. Well almost: you can move the power button b

Version history:
----------------
NRG version 1.2.0
* Lowered the update rate by 1/4; saving CPU ressources


NRG version 1.1.0
* Filtering events, so only magic events are now considered.
Still not perfect but far better than before: dismounting does no longer trigger mp5 cooldown for example!
Expand Down
2 changes: 1 addition & 1 deletion nrg/nrg-Classic.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Title: NRG - mp5 Power Button
## Notes: Addon to check mp5 rule
## Version: 1.1.0
## Version: 1.2.0
## Author: Mimma @ <EU-Pyrewood Village>
## Interface: 11403
## SavedVariables: NRG_Options
Expand Down
2 changes: 1 addition & 1 deletion nrg/nrg-TBC.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Title: NRG - mp5 Power Button
## Notes: Addon to check mp5 rule
## Version: 1.1.0
## Version: 1.2.0
## Author: Mimma @ <EU-Pyrewood Village>
## Interface: 20504
## SavedVariables: NRG_Options
Expand Down
2 changes: 1 addition & 1 deletion nrg/nrg.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Title: NRG - mp5 Power Button
## Notes: Addon to check mp5 rule (yeah, I know .. irrelevant for retail, but anyway)
## Version: 1.1.0
## Version: 1.2.0
## Author: Mimma @ <EU-Pyrewood Village>
## Interface: 90205
## SavedVariables: NRG_Options
Expand Down

0 comments on commit 17120b6

Please sign in to comment.