Skip to content

Commit

Permalink
Fixed modules attempting to use resources before their initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonaza committed Sep 26, 2019
1 parent d793d7e commit 708641f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.1.0
* Patch 8.2.5.
* Fixed modules attempting to use resources before their initialization.

## 3.0.6
* Patch 8.2.0.
* Attempted blind fix for artifact module GetItemInfo error.
Expand Down
4 changes: 2 additions & 2 deletions Experiencer.toc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Interface: 80200
## Interface: 80205
## Title: Experiencer
## Notes: Simple but advanced tracking progress bar addon
## Author: Sonaza
## Version: 3.0.6
## Version: 3.1.0
## OptionalDeps: Ace3
## SavedVariables: ExperiencerDB, ExperiencerDB_module_experience, ExperiencerDB_module_reputation, ExperiencerDB_module_artifact, ExperiencerDB_module_honor, ExperiencerDB_module_conquest

Expand Down
18 changes: 11 additions & 7 deletions core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ function Addon:InitializeModules()

module:Initialize();
end

Addon.modulesInitialized = true;
end

function Addon:RegisterModule(moduleId, prototype)
Expand Down Expand Up @@ -1390,13 +1392,15 @@ function Experiencer_OnUpdate(self, elapsed)

Addon:CheckDisabledStatus();

for _, module in Addon:IterateModules() do
module:Update(elapsed);
end

for _, moduleFrame in Addon:GetModuleFrameIterator() do
if(moduleFrame:IsVisible() and moduleFrame.module) then
moduleFrame:OnUpdate(elapsed);
if (Addon.modulesInitialized) then
for _, module in Addon:IterateModules() do
module:Update(elapsed);
end

for _, moduleFrame in Addon:GetModuleFrameIterator() do
if(moduleFrame:IsVisible() and moduleFrame.module) then
moduleFrame:OnUpdate(elapsed);
end
end
end

Expand Down
34 changes: 19 additions & 15 deletions modules/experience.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,30 @@ function module:AllowedToBufferUpdate()
end

function module:Update(elapsed)
local lastPaused = module.session.Paused;
module.session.Paused = UnitIsAFK("player");

if(module.session.Paused and lastPaused ~= module.session.Paused) then
module:Refresh();
elseif(not module.session.Paused and lastPaused ~= module.session.Paused) then
module.session.LoginTime = module.session.LoginTime + math.floor(module.session.PausedTime);
module.session.PausedTime = 0;
local lastPaused = self.session.Paused;
self.session.Paused = UnitIsAFK("player");

if(self.session.Paused and lastPaused ~= self.session.Paused) then
self:Refresh();
elseif(not self.session.Paused and lastPaused ~= self.session.Paused) then
self.session.LoginTime = self.session.LoginTime + math.floor(self.session.PausedTime);
self.session.PausedTime = 0;
end

if(module.session.Paused) then
module.session.PausedTime = module.session.PausedTime + elapsed;
if(self.session.Paused) then
self.session.PausedTime = self.session.PausedTime + elapsed;
end

if(module.db.global.KeepSessionData) then
module.db.char.session.Exists = true;
if (self.db == nil) then
return;
end

if(self.db.global.KeepSessionData) then
self.db.char.session.Exists = true;

module.db.char.session.Time = time() - (module.session.LoginTime + math.floor(module.session.PausedTime));
module.db.char.session.TotalXP = module.session.GainedXP;
module.db.char.session.AverageQuestXP = module.session.AverageQuestXP;
self.db.char.session.Time = time() - (self.session.LoginTime + math.floor(self.session.PausedTime));
self.db.char.session.TotalXP = self.session.GainedXP;
self.db.char.session.AverageQuestXP = self.session.AverageQuestXP;
end
end

Expand Down

0 comments on commit 708641f

Please sign in to comment.