From 16af4b91e6a9785dc07c0036d7dda8c13db8f04c Mon Sep 17 00:00:00 2001 From: Peter Eliasson Date: Tue, 20 Jan 2015 19:34:22 +0100 Subject: [PATCH] Removed the tracking of current encounter from the main module. The tracking of encounters is instead done by the parse providers that needs it. --- src/main.lua | 62 ++++++++++++++++------------------------------------------ 1 file changed, 17 insertions(+), 45 deletions(-) diff --git a/src/main.lua b/src/main.lua index d1676b3..ccf11e5 100644 --- a/src/main.lua +++ b/src/main.lua @@ -85,37 +85,6 @@ function addon:UpdateCurrentZone() local zoneId, _ = GetCurrentMapAreaID() local zoneName = GetRealZoneText(); self.currentZone = {id = zoneId, name = zoneName}; - - if IsInInstance() then - self:Debug("UpdateCurrentZone", zoneId, zoneName) - else - self:UnsetCurrentEncounter(); - end -end - -function addon:SetCurrentEncounter(encounterId, encounterName, difficultyId, raidSize) - local difficultyName = getDifficultyNameById(difficultyId); - - self:Debug("SetCurrentEncounter", encounterId, encounterName, difficultyId, raidSize, difficultyName); - - if difficultyName then - self.currentEncounter = { - zoneId = self.currentZone.id, - zoneName = self.currentZone.name, - id = encounterId, - name = encounterName, - difficultyId = difficultyId, - difficultyName = difficultyName, - raidSize = raidSize - } - end -end - -function addon:UnsetCurrentEncounter() - if self.currentEncounter then - self:Debug("UnsetCurrentEncounter"); - self.currentEncounter = nil - end end function addon:IsInMyGuild(playerName) @@ -139,20 +108,30 @@ function addon:GetGuildPlayersFromSet(skadaSet) return players end -function addon:OnEncounterEndSuccess() +function addon:OnEncounterEndSuccess(encounterId, encounterName, difficultyId, raidSize) self:Debug("OnEncounterEndSuccess") + local difficultyName = getDifficultyNameById(difficultyId); + if not difficultyName then + self:Debug(format("Could not map difficultyId %d to a name", difficultyId)); + return; + end + local guildName = self.guildName; if not guildName then self:Debug("Not in a guild"); return; end - local encounter = self.currentEncounter; - if not encounter then - self:Debug("No current encounter"); - return - end + local encounter = { + zoneId = self.currentZone.id, + zoneName = self.currentZone.name, + id = encounterId, + name = encounterName, + difficultyId = difficultyId, + difficultyName = difficultyName, + raidSize = raidSize + }; local pmc = self.parseModulesCore; pmc:GetParsesForEncounter(encounter, function(success, startTime, duration, players) @@ -164,8 +143,6 @@ function addon:OnEncounterEndSuccess() self.highscore:AddEncounterParsesForPlayers(guildName, encounter, players); end) end) - - self:UnsetCurrentEncounter(); end function addon:PLAYER_GUILD_UPDATE(evt, unitId) @@ -177,10 +154,7 @@ end function addon:ENCOUNTER_END(evt, encounterId, encounterName, difficultyId, raidSize, endStatus) self:Debug("ENCOUNTER_END", encounterId, encounterName, difficultyId, raidSize, endStatus) if endStatus == 1 then -- Success - self:SetCurrentEncounter(encounterId, encounterName, difficultyId, raidSize); - self:OnEncounterEndSuccess(); - else - self:UnsetCurrentEncounter(); + self:OnEncounterEndSuccess(encounterId, encounterName, difficultyId, raidSize); end end @@ -213,7 +187,6 @@ function addon:OnInitialize() end function addon:OnEnable() - self.currentEncounter = nil; self.currentZone = {}; self.guildName = nil; @@ -230,7 +203,6 @@ function addon:OnEnable() end function addon:OnDisable() - self.currentEncounter = nil; self.currentZone = {}; self.guildName = nil; -- 1.7.9.5