Skip to content

Commit

Permalink
Workaround reputation issue when encountering broken/empty/duplicate …
Browse files Browse the repository at this point in the history
…TWW headers
  • Loading branch information
DJScias committed Aug 23, 2024
1 parent e1352f4 commit 0620021
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 75 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [6.1.6] - 2024-08-23

### Fixed
- Workaround reputation issue when encountering broken/empty/duplicate TWW headers.
- This seems to be perhaps an early TWW issue?

## [6.1.5] - 2024-08-22

### Changed
Expand Down
153 changes: 78 additions & 75 deletions modules/reputation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function module:SaveCollapsedHeaders()

for factionIndex = 1, numFactions do
local factionData = C_Reputation.GetFactionDataByIndex(factionIndex);
if factionData.isCollapsed then
if factionData and factionData.isCollapsed then
tinsert(collapsedHeaders, factionData.factionID);
end
end
Expand All @@ -460,7 +460,7 @@ function module:CloseCollapsedHeaders(collapsedHeaders)
local factionData = C_Reputation.GetFactionDataByIndex(factionIndex);

for index, value in pairs(collapsedHeaders) do
if value == factionData.factionID then
if factionData and value == factionData.factionID then
C_Reputation.CollapseFactionHeader(factionIndex);
tremove(collapsedHeaders, index)
break;
Expand Down Expand Up @@ -704,96 +704,99 @@ function module:GetReputationsMenu(currentMenu)
local factionIndex = 1;
while factionIndex <= numFactions do
local factionData = C_Reputation.GetFactionDataByIndex(factionIndex);
local factionID, name, standing, isHeader, isCollapsed, hasRep, isWatched, isChild = factionData.factionID, factionData.name, factionData.reaction, factionData.isHeader, factionData.isCollapsed, factionData.isHeaderWithRep, factionData.isWatched, factionData.isChild;
-- Don't count inactive reps.
if factionID == 0 then
break;
end
if name then
local progressText = "";
if factionID then
local currentRep, nextThreshold, isCapped, isParagon = module:GetReputationProgressByFactionID(factionID);
if (isParagon) then
standing = 9;
-- TWW introduced potential empty headers, only handle below if factionData exists.
if factionData then
local factionID, name, standing, isHeader, isCollapsed, hasRep, isWatched, isChild = factionData.factionID, factionData.name, factionData.reaction, factionData.isHeader, factionData.isCollapsed, factionData.isHeaderWithRep, factionData.isWatched, factionData.isChild;
-- Don't count inactive reps.
if factionID == 0 then
break;
end
if name then
local progressText = "";
if factionID then
local currentRep, nextThreshold, isCapped, isParagon = module:GetReputationProgressByFactionID(factionID);
if (isParagon) then
standing = 9;
end

if (currentRep and not isCapped) then
progressText = string.format(" (|cfffff2ab%s|r / %s)", BreakUpLargeNumbers(currentRep), BreakUpLargeNumbers(nextThreshold));
end
end

if (currentRep and not isCapped) then
progressText = string.format(" (|cfffff2ab%s|r / %s)", BreakUpLargeNumbers(currentRep), BreakUpLargeNumbers(nextThreshold));
local standingText = "";

if not isHeader or hasRep then
local reputationInfo = C_GossipInfo.GetFriendshipReputation(factionID);
local majorFactionData = C_MajorFactions.GetMajorFactionData(factionID);
if (majorFactionData and standing ~= 9) then
standingText = string.format("|cnHEIRLOOM_BLUE_COLOR:Renown %s|r", majorFactionData.renownLevel);
elseif (reputationInfo and reputationInfo.friendshipFactionID > 0) then
standingText, _ = module:GetFriendShipColorText(reputationInfo.friendshipFactionID, reputationInfo.reaction);
else
standingText, _ = module:GetStandingColorText(standing);
end
end
end

local standingText = "";

if not isHeader or hasRep then
local reputationInfo = C_GossipInfo.GetFriendshipReputation(factionID);
local majorFactionData = C_MajorFactions.GetMajorFactionData(factionID);
if (majorFactionData and standing ~= 9) then
standingText = string.format("|cnHEIRLOOM_BLUE_COLOR:Renown %s|r", majorFactionData.renownLevel);
elseif (reputationInfo and reputationInfo.friendshipFactionID > 0) then
standingText, _ = module:GetFriendShipColorText(reputationInfo.friendshipFactionID, reputationInfo.reaction);
else
standingText, _ = module:GetStandingColorText(standing);
if isHeader and isCollapsed then
C_Reputation.ExpandFactionHeader(factionIndex);
tinsert(collapsedHeaders, factionData.factionID);
numFactions = C_Reputation.GetNumFactions();
end
end

if isHeader and isCollapsed then
C_Reputation.ExpandFactionHeader(factionIndex);
tinsert(collapsedHeaders, factionData.factionID);
numFactions = C_Reputation.GetNumFactions();
end
if isHeader and isChild and current then -- Second tier header
if depth == 2 then
current = previous;
previous = nil;
end

if not hasRep then
tinsert(current, {
name = name,
isHeader = true,
menuList = {},
})
else
tinsert(current, {
name = string.format("%s (%s)%s", name, standingText, progressText),
isHeaderWithRep = true,
factionID = factionID,
isWatched = isWatched,
menuList = {},
})
end

previous = current;
current = current[#current].menuList;
tinsert(current, {
name = name,
isSubMenuTitle = true,
})

if isHeader and isChild and current then -- Second tier header
if depth == 2 then
current = previous;
previous = nil;
end
depth = 2

if not hasRep then
tinsert(current, {
elseif isHeader then -- First tier header
tinsert(factions, {
name = name,
isHeader = true,
isMajorHeader = true;
menuList = {},
})
else

current = factions[#factions].menuList;
tinsert(current, {
name = name,
isMajorHeaderTitle = true,
})

depth = 1
elseif not isHeader then -- First and second tier faction
tinsert(current, {
name = string.format("%s (%s)%s", name, standingText, progressText),
isHeaderWithRep = true,
isFaction = true,
factionID = factionID,
isWatched = isWatched,
menuList = {},
})
end

previous = current;
current = current[#current].menuList;
tinsert(current, {
name = name,
isSubMenuTitle = true,
})

depth = 2

elseif isHeader then -- First tier header
tinsert(factions, {
name = name,
isMajorHeader = true;
menuList = {},
})

current = factions[#factions].menuList;
tinsert(current, {
name = name,
isMajorHeaderTitle = true,
})

depth = 1
elseif not isHeader then -- First and second tier faction
tinsert(current, {
name = string.format("%s (%s)%s", name, standingText, progressText),
isFaction = true,
factionID = factionID,
isWatched = isWatched,
})
end
end

Expand Down

0 comments on commit 0620021

Please sign in to comment.