Originally Posted by myrroddin
Do I need to/should I be calling self:SwitchedZones() in Options.lua? I can't tell if that is causing a stack overflow that isn't being caught, as commenting out the lines or leaving them in doesn't seem to make BugSack unhappy.
|
If any particular option changes the behavior of
RepByZone:SwitchedZones(), then go ahead and call it. The stack overflow was caused by the infinite loop we just fixed.
Originally Posted by myrroddin
Also, now that I no longer have any errors, something else is confusing me. After your explanation, I fixed the code in self:CheckSolazarBasin(). So far so good.... until I zoned into my garrison.
Once there, I still don't get any errors (woot~ ) but now my bodyguard's faction isn't being set as the watched faction. My Night Elf Demon Hunter is watching Darnassus in both the garrison and the mine/excavation. Heading out to Shadowmoon Valley watches Council of Exarchs, which would be correct if I wasn't supposed to be watching Delvar Ironfist.
|
This line in
RepByZone:SwitchedZones() stands out to me.
Code:
local isWoDZone = #self.WoDFollowerZones > 0 and self.WoDFollowerZones[UImapID] or self.WoDFollowerZones[parentMapID]
The table is defined with this.
Code:
RepByZone.WoDFollowerZones = {
[525] = true, -- Frostfire Ridge
[534] = true, -- Tanaan Jungle
[535] = true, -- Talador
[539] = true, -- Shadowmoon Valley
[542] = true, -- Spires of Arak
[543] = true, -- Gorgrond
[550] = true, -- Nagrand
[579] = true, -- Lunarfall Excavation 1
[580] = true, -- Lunarfall Excavation 2
[581] = true, -- Lunarfall Excavation 3
[582] = true, -- Lunarfall
[585] = true, -- Frostwall Mine 1
[586] = true, -- Frostwall Mine 2
[587] = true, -- Frostwall Mine 3
[588] = true, -- Ashran
[590] = true, -- Frostwall
}
The problem is the length operator (#) only operates on sequential indices, meaning it'll always return zero in your code. You could just remove the length check and let the lookup do its work anyway.
Another unrelated issue is you should reinitialize your data tables when a Pandaren chooses their faction. Otherwise, the faction-specific reps won't load correctly. The following additions should correct this.
Code:
function RepByZone:CheckPandaren(event, success)
if success then
A = UnitFactionGroup("player") == "Alliance" and ALLIANCE
H = UnitFactionGroup("player") == "Horde" and HORDE
if UnitFactionGroup("player") ~= nil then
instancesAndFactions = self:InstancesAndFactionList()
zonesAndFactions = self:ZoneAndFactionList()
subZonesAndFactions = self:SubZonesAndFactions()
self:GetRacialRep()
if db.watchedRepID == 1216 then
db.watchedRepID, db.watchedRepName = self:GetRacialRep()
self:Print(L["You have joined the faction %s, switching watched saved variable to %s."]:format(A or H, db.watchedRepName))
self:SwitchedZones()
end
end
end
if A or H then
self:UnregisterEvent(event)
end
end
Looks like
CitySubZonesAndFactions is also affected by this bug, but is not accessible by this function because the local is defined later in the file.