Skip to content

Commit

Permalink
Attempt to fix npe
Browse files Browse the repository at this point in the history
(This didn't happen before tww, so, something else might be broken)
  • Loading branch information
Eliote committed Aug 24, 2024
1 parent e4f4f87 commit f7ba58a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions TitanReputations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,23 @@ local function GetFactionLabel(standingId)
return GetText("FACTION_STANDING_LABEL" .. standingId, SEX)
end

local function GetBalanceForMajorFaction(factionId, currentXp, currentLvl)
local function GetSessionStartTable(factionId)
if (not sessionStartMajorFaction[factionId]) then
local data = GetMajorFactionData(factionId)
sessionStartMajorFaction[factionId] = {
startLvl = data.renownLevel,
[data.renownLevel] = { start = 0, max = data.renownLevelThreshold }
}
end
return sessionStartMajorFaction[factionId]
end

local function GetBalanceForMajorFaction(factionId, currentXp, currentLvl)
local sessionTable = GetSessionStartTable(factionId)
local balance = 0
local start = sessionStartMajorFaction[factionId].startLvl
local start = sessionTable.startLvl
for i = start, currentLvl do
local data = sessionStartMajorFaction[factionId][i]
local data = sessionTable[i]
-- we might not have data yet if we just leveled and UPDATE_FACTION run before MAJOR_FACTION_RENOWN_LEVEL_CHANGED
if (data) then
local endXp = (currentLvl == i) and currentXp or data.max
Expand Down Expand Up @@ -488,7 +493,7 @@ local eventsTable = {
if (C_Reputation.IsMajorFaction) then
eventsTable.MAJOR_FACTION_RENOWN_LEVEL_CHANGED = function(self, factionId, newRenownLevel, oldRenownLevel)
local data = GetMajorFactionData(factionId)
sessionStartMajorFaction[factionId][newRenownLevel] = { start = 0, max = data.renownLevelThreshold }
GetSessionStartTable(factionId)[newRenownLevel] = { start = 0, max = data.renownLevelThreshold }
TitanPanelButton_UpdateButton(self.registry.id)
end
end
Expand Down

0 comments on commit f7ba58a

Please sign in to comment.