Quantcast
RepByZone does not revert to zone data if subzone has no data - WoWInterface
Thread Tools Display Modes
03-09-21, 03:41 PM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,186
RepByZone does not revert to zone data if subzone has no data

Man, that title is awkward. Anyway, the idea is that your watched reputation bar should switch if RBZ has data for either a subzone's associated faction, or zone-wide associated faction. The user can set a default faction to watch if RBZ does not have data for either a zone or subzone. That works fine, even if the user selects None from the list, in which case the reputation bar is cleared. So far, so good.

Here's the rub: Oribos should be watching the user's Covenant faction if joined, or the fallback racial reputation, which is not the user's default watched faction. That sounds confusing, so here's an explanation.

RBZ internally assigns a faction based on the character race, like Dwarf == Ironforge or Orc == Orgrimmar. The user can watch any known faction. Let's say the user selects Rustbolt Resistance.

Currently, RBZ does not have data for Shattrath because I haven't added it yet. There is data for Lower City. When the player enters Lower City, the bar switches to Lower City, and when the user goes anywhere else in Shattrath, the bar switches to Rustbolt Resistance. Again, so far, so good.

Now for Oribos. I have added all known uiMapIDs, of which there are four. But RBZ often switches to Rustbolt Resistance when going between the areas. RBZ should be watching the Covenant or racial faction. It should never be watching Rustbolt Resistance in Oribos.

People have also said in bug reports that if you enter an instance that has data, RBZ switches, but when you zone out, the correct faction is not watched.

It's behaving as though, should no subzone data exist, the zone data is ignored. All I can possibly think of is instead of using break, use if/then to see if data is found, and if yes, use return instead of break. I haven't tested it, mostly because that feels like throwing darts blindly at a map.

Below is the code that switches the reputation bar if data exists; if the user selects None as the default faction to watch, the bar is cleared at the bottom.

Lua Code:
  1. -- Table to localize subzones that Blizzard does not provide areaIDs
  2. local CitySubZonesAndFactions = CitySubZonesAndFactions or {
  3.     -- ["Subzone"] = factionID
  4.     ["Dwarven District"] = 47, -- Ironforge
  5.     ["The Salty Sailor Tavern"] = 21, -- Booty Bay
  6.     ["Tinker Town"] = 54, -- Gnomeregan Exiles
  7.     ["Valley of Spirits"] = 530, -- Darkspear Trolls
  8.     ["Valley of Wisdom"] = 81, -- Thunder Bluff
  9. }
  10.  
  11. -- Player switched zones, subzones, or instances, set watched faction
  12. function RepByZone:SwitchedZones()
  13.     if isOnTaxi and not db.watchOnTaxi then
  14.         -- On taxi but don't switch
  15.         return
  16.     end
  17.  
  18.     if WorldMapFrame:IsShown() then
  19.         -- Don't switch while the map is open
  20.         return
  21.     end
  22.  
  23.     local faction -- Predefine the variable for later use like tabards and bodyguards. Still need it now, however
  24.     local UImapID = IsInInstance() and select(8, GetInstanceInfo()) or C_Map.GetBestMapForUnit("player")
  25.     local locationsAndFactions = IsInInstance() and self:InstancesAndFactionList() or self:ZoneAndFactionList()
  26.     local subZone = GetMinimapZoneText()
  27.  
  28.     -- Apply subzones
  29.     if db.watchSubZones then
  30.         -- Blizzard provided areaIDs
  31.         for areaID, factionID in pairs(subZonesAndFactions) do
  32.             if C_Map.GetAreaInfo(areaID) == subZone then
  33.                 self:SetWatchedFactionByFactionID(factionID)
  34.                 break
  35.             end
  36.         end
  37.         -- Our localized missing Blizzard areaIDs
  38.         for areaName, factionID in pairs(CitySubZonesAndFactions) do
  39.             if L[areaName] == subZone then
  40.                 self:SetWatchedFactionByFactionID(factionID)
  41.                 break
  42.             end
  43.         end
  44.     end
  45.  
  46.     -- Apply zoneID data
  47.     for zoneID, factionID in pairs(locationsAndFactions) do
  48.         if zoneID == UImapID then
  49.             self:SetWatchedFactionByFactionID(factionID)
  50.             break
  51.         end
  52.     end
  53.  
  54.     -- If no data is found, use default watched faction or race/class faction
  55.     faction = db.watchedRepID or self.racialRepID
  56.     if not self:SetWatchedFactionByFactionID(faction) then
  57.         -- Player does not want a default watched faction
  58.         SetWatchedFactionIndex(0) -- Clear watched faction
  59.     end
  60. end

Here is the data, because "show your code".
Lua Code:
  1. local RepByZone = LibStub("AceAddon-3.0"):GetAddon("RepByZone")
  2.  
  3. local H = UnitFactionGroup("player") == "Horde"
  4. local A = UnitFactionGroup("player") == "Alliance"
  5.  
  6. function RepByZone:ZoneAndFactionList()
  7.     -- UImapID = factionID
  8.     -- If an UImapID is not listed, that zone has no associated factionID
  9.     -- see [url]https://wow.gamepedia.com/UiMapID[/url] for the list of UImapIDs
  10.     -- see [url]https://wow.gamepedia.com/FactionID[/url] for the list of factionIDs
  11.  
  12.     local covenantRepID = self.covenantRepID
  13.     local db = self.db.char
  14.  
  15.     local zonesAndFactions = {
  16.         --------- Vanilla ----------
  17.         [1]         = 46,       -- Durotar/Orgrimmar
  18.         [3]         = 72,       -- Tiragarde Keep/Stormwind
  19.         [4]         = 72,       -- Tiragarde Keep (Great Hall)/Stormwind
  20.         [7]         = 81,       -- Mulgore/Thunder Bluff
  21.         [10]        = A and 470 or H and 46, -- Northern Barrens/Ratchet or Orgrimmar
  22.         [14]        = A and 72 or H and 46, -- Arathi Highlands/Stormwind or Orgrimmar
  23.         [15]        = A and 47 or H and 46, -- Badlands/Ironforge or Orgrimmar
  24.         [17]        = A and 72 or H and 46, -- Blasted Lands/Stormwind or Orgrimmar
  25.         [18]        = 68,       -- Tirisfal Glades/Undercity
  26.         [21]        = A and 1134 or H and 68, -- Silverpine Forest/Gilneas or Undercity
  27.         [22]        = 1106,      -- Western Plaguelands/Argent Crusade
  28.         [23]        = 529,      -- Eastern Plaguelands/Argent Dawn
  29.         [25]        = 68,       -- Hillsbrad Foothills/Undercity
  30.         [26]        = A and 1174 or H and 530, -- Hinterlands/Wildhammer Clan or Darkspear Trolls
  31.         [27]        = 47,       -- Dun Morogh/Ironforge
  32.         [30]        = 54,       -- New Tinkertown/Gnomeregan
  33.         [32]        = 59,       -- Searing Gorge/Thorium Brotherhood
  34.         [36]        = A and 72 or H and 46, -- Burning Steppes/Stormwind or Orgrimmar
  35.         [37]        = 72,       -- Elwynn Forest/Stormwind
  36.         [41]        = 1090,     -- Dalaran/Kirin Tor
  37.         [42]        = 967,      -- Deadwind Pass/The Violet Eye
  38.         [47]        = A and 72 or H and 68, -- Duskwood/Stormwind or Undercity
  39.         [48]        = 47,       -- Loch Modan/Ironforge
  40.         [49]        = 72,       -- Redridge Mountains/Stormwind
  41.         [50]        = A and 72 or H and 46, -- Northern Stranglethorn/Stormwind or Orgrimmar
  42.         [51]        = 46,       -- Swamp of Sorrows/Orgimmar
  43.         [52]        = 72,       -- Westfall/Stormwind
  44.         [56]        = 47,       -- Wetlands/Ironforge
  45.         [57]        = 69,       -- Teldrassil/Darnassus
  46.         [62]        = 69,       -- Darkshore/Darnassus
  47.         [63]        = A and 69 or H and 1085, -- Ashenvale/Darnassus or Warsong Offensive
  48.         [64]        = A and 54 or H and 1133, -- Thousand Needles/Gnomeregan or Bilgewater Cartel
  49.         [65]        = A and 69 or H and 81, -- Stonetalon Mountains/Darnassus or Thunder Bluff
  50.         [66]        = 609,      -- Desolace/Cenarion Circle
  51.         [69]        = A and 69 or H and 81, -- Feralas/Darnassus or Thunder Bluff
  52.         [70]        = A and 72 or H and 46, -- Dustwallow Marsh/Stormwind or Orgrimmar
  53.         [71]        = 369,      -- Tanaris/Gadgetzan
  54.         [74]        = 989,      -- Timeless Tunnel/Keepers of Time
  55.         [75]        = 989,      -- Caverns of Time/Keepers of Time
  56.         [76]        = 1133,     -- Azshara/Bilgewater Cartel
  57.         [77]        = A and 69 or H and 1133, -- Felwood/Darnassus or Bilgewater Cartel
  58.         [80]        = 609,      -- Moonglade/Cenarion Circle
  59.         [81]        = 609,      -- Silithus/Cenarion Circle
  60.         [83]        = 577,      -- Winterspring/Everlook
  61.         [84]        = 72,       -- Stormwind City/Stormwind
  62.         [85]        = 46,       -- Orgrimmar/Orgrimmar
  63.         [87]        = 47,       -- Ironforge/Ironforge
  64.         [88]        = 81,       -- Thunder Bluff/Thunder Bluff
  65.         [89]        = 69,       -- Darnassus/Darnassus
  66.         [90]        = 68,       -- Undercity/Undercity
  67.  
  68.         --------- TBC ---------
  69.         [94]        = 911,      -- Eversong Woods/Silvermoon City
  70.         [95]        = 922,      -- Ghostlands/Tranquillien
  71.         [97]        = 930,      -- Azuremyst Isle/Exodar
  72.         [100]       = A and 946 or H and 947, -- Hellfire Peninsula/Honor Hold or Thrallmar
  73.         [102]       = 942,      -- Zangarmarsh/Cenarion Expedition
  74.  
  75.         --------- Cataclysm ---------
  76.         [5861]      = 909,      -- Darkmoon Island/Darkmoon Faire
  77.  
  78.         --------- MoP ---------
  79.         [371]       = A and 1242 or H and 1228, -- Jade Forest/Pearlfin Jinyu or Forest Hozen
  80.         [376]       = 1272,     -- Valley of the Four Winds/The Tillers
  81.         [379]       = 1270,     -- Kun-Lai Summit/Shado-Pan
  82.         [388]       = 1270,     -- Towlong Steppes/Shado-Pan
  83.         [390]       = 1269,     -- Vale of Eternal Blossoms/Golden Lotus
  84.         [418]       = 1302,     -- Krasarang Wilds/The Anglers
  85.         [422]       = 1337,     -- Dread Wastes/The Klaxxi
  86.         [433]       = 1359,     -- The Veiled Stair/The Black Prince
  87.         [507]       = A and 72 or H and 46, -- Isle of Giants/Stormwind or Orgrimmar
  88.         [516]       = A and 1387 or H and 1388, -- Isle of Thunder/Kirin Tor Offensive or Sunreaver Onslaught
  89.         [554]       = 1492,     -- Timeless Isle/Emperor Shaohao
  90.  
  91.         --------- WoD ---------
  92.  
  93.         --------- Legion ---------
  94.         [787]       = 609,      -- Moonglade/Cenarion Circle
  95.  
  96.         --------- BfA ---------
  97.         [863]       = A and 2159 or H and 2380, -- Nazmir/7th Legion or Talanji's Expedition
  98.         [864]       = A and 2159 or H and 2382, -- Vol'dun/7th Legion or Voldunai
  99.         [895]       = A and 2160 or H and 2157, -- Tiragarde Sound/Proudmore Admiralty or The Honorbound
  100.         [896]       = A and 2383 or H and 2157, -- Drustvar/Order of Embers or The Honorbound
  101.         [942]       = A and 2381 or H and 2157, -- Stormsong Valley/Storm's Wake or The Honorbound
  102.         [1193]      = A and 2159 or H and 2378, -- Zuldazar/7th Legion or Zandalari Empire
  103.         [1355]      = A and 2401 or H and 2373, -- Nazjatar/Waveblade Ankoan or The Unshackled
  104.         [1462]      = 2391,      -- Mechagon Island/Rustbolt Resistance
  105.  
  106.         --------- Shadowlands ---------
  107.         [1525]      = 2413,     -- Revendreth/Court of Harvesters
  108.         [1536]      = 2410,     -- Maldraxxus/The Undying Army
  109.         [1543]      = 2432,     -- The Maw/Ve'nari
  110.         [1569]      = 2407,     -- Bastion/The Ascended
  111.         -- Oribos has 4 UiMapIDs depending on where in the city you are
  112.         [1670]      = covenantRepID, -- Ring of Fates/Covenant
  113.         [1671]      = covenantRepID, -- Ring of Transference/Covenant
  114.         [1672]      = covenantRepID, -- The Broker's Den/Covenant
  115.         [1673]      = covenantRepID, -- The Crucible/Covenant
  116.         [1740]      = 2465,     -- Ardenweald/The Wild Hunt
  117.     }
  118.     return zonesAndFactions
  119. end
  120.  
  121. function RepByZone:SubZonesAndFactions()
  122.     local covenantRepID = self.covenantRepID
  123.     local db = self.db.char
  124.  
  125.     local subZonesAndFactions = {
  126.         -- areaID = factionID
  127.         -- see [url]https://wow.tools/dbc/?dbc=areatable&build=9.0.2.36949#page=1[/url]
  128.  
  129.         --------- Vanilla ---------
  130.         [19]        = 309,      -- Zul'Gurub/Zandalar Tribe
  131.         [35]        = 21,       -- Booty Bay/Booty Bay
  132.         [36]        = A and 730 or H and 729, -- Alterac Mountains/Stormpike Guard or Frostwolf Clan
  133.         [100]       = 47,       -- Nesingwary's Expedition/Ironforge
  134.         [102]       = 309,      -- Ruins of Zul'Kunda/Zandalar Tribe
  135.         [103]       = 309,      -- Ruins of Zul'Mamwe/Zandalar Tribe
  136.         [122]       = 270,      -- Zuuldaia Ruins/Zandalar Tribe
  137.         [123]       = 309,      -- Bal'lal Ruins/Zandalar Tribe
  138.         [125]       = 270,      -- Kal'ai Ruins/Zandalar Tribe
  139.         [127]       = 309,      -- Balia'mah Ruins/Zandalar Tribe
  140.         [128]       = 270,      -- Ziata'jai Ruins/Zandalar Tribe
  141.         [133]       = 54,       -- New Tinkertown/Gnomeregan
  142.         [150]       = 72,       -- Menethil Harbor/Stormwind
  143.         [152]       = 529,      -- The Bulwark/Argent Dawn
  144.         [193]       = A and 72 or H and 68, -- Ruins of Andorhal/Stormwind or Undercity
  145.         [196]       = 72,       -- Uthor's Tomb/Stormwind
  146.         [197]       = 72,       -- Sorrow Hill/Stormwind
  147.         [199]       = 72,       -- Felstone Field/Stormwind
  148.         [201]       = 68,       -- Gahrron's Withering/Undercity
  149.         [202]       = 68,       -- Writhing Haunt/Undercity
  150.         [204]       = 1134,     -- Pyrewood Village/Gilneas
  151.         [233]       = 1134,     -- Ambermill/Gilneas
  152.         [250]       = 59,       -- Ruins of Thaurissan
  153.         [279]       = 1090,     -- Dalaran Crater/Kirin Tor
  154.         [280]       = 349,      -- Strahnbrad/Ravenholdt
  155.         [288]       = 72,       -- Azurelode Mine/Stormwind
  156.         [297]       = 81,       -- Jaguero Isle/Thunder Bluff
  157.         [299]       = 72,       -- Menethil Bay/Stormwind
  158.         [311]       = 270,      -- Ruins of Aboraz/Zandalar Tribe
  159.         [313]       = 349,      -- Northfold Manor/Ravenholdt
  160.         [321]       = 68,       -- Hammerfall/Undercity
  161.         [324]       = 349,      -- Stromgarde Keep/Ravenholdt
  162.         [327]       = 21,       -- Faldir's Cove/Booty Bay
  163.         [328]       = 21,       -- The Drowned Reef/Booty Bay
  164.         [330]       = 47,       -- Thandol Span/Ironforge
  165.         [350]       = 69,       -- Quel'Danil Lodge/Darnassus
  166.         [359]       = H and 81 or A and 47, -- Bael Modan/Thunder Bluff or Ironforge
  167.         [367]       = 530,      -- Sen'jen Village/Darkspear Trolls
  168.         [368]       = 530,      -- Echo Isles/Darkspear Trolls
  169.         [392]       = 470,      -- Ratchet/Ratchet
  170.         [393]       = 530,      -- Darkspear Strand/Darkspear Trolls
  171.         [439]       = A and 54 or H and 76, -- The Shimmering Flats/Gnomeregan or Orgrimmar
  172.         [477]       = 270,      -- Ruins of Jubuwal/Zandalar Tribe
  173.         [484]       = H and 81 or A and 69, -- Freewind Post/Thunder Bluff or Darnassus
  174.         [501]       = 369,     -- Beezil's Wreck/Gadgetzan
  175.         [517]       = 1358,     -- Tidefury Cove/Nat Pagle
  176.         [530]       = 69,       -- Quel'Danil Lodge/Darnassus
  177.         [596]       = 470,      -- Kodo Graveyard/Ratchet
  178.         [603]       = 69,       -- Sargeron/Darnassus
  179.         [604]       = 93,       -- Magram Village (Shok'Thokar)/Magram Clan Centaur
  180.         [606]       = 92,       -- Gelkis Village/Gelkis Clan Centaur
  181.         [608]       = 69,       -- Nijel's Point/Darnassus
  182.         [609]       = 93,       -- Kolkar Village/Magram Clan Centaur
  183.         [702]       = 69,       -- Rut'theran Village/Darnassus
  184.         [721]       = 54,       -- Gnomeregan/Gnomeregan
  185.         [813]       = 529,      -- The Bulwark/Argent Dawn
  186.         [880]       = 47,       -- Thandol Span/Ironforge
  187.         [881]       = 47,       -- Thandol Span/Ironforge
  188.         [896]       = A and 730 or H and 729, -- Purgation Isle/Stormpike Guard or Frostwolf Clan
  189.         [987]       = 1133,     -- Land's End Beach/Bilgewater Cartel
  190.         [989]       = 1173,     -- Ruins of Uldum/Ramkahen
  191.         [990]       = 1173,     -- Valley of the Watchers/Ramkahen
  192.         [1016]      = 69,       -- Direforge Hill/Darnassus
  193.         [1019]      = 69,       -- The Green Belt/Darnassus
  194.         [1025]      = 69,       -- The Green Belt/Darnassus
  195.         [1216]      = 579,      -- Timbermaw Hold/Timbermaw Hold
  196.         [1220]      = 69,       -- Darnassian Base Camp/Darnassus
  197.         [1336]      = A and 54 or H and 1133, -- Lost Rigger Cove/Gnomeregan or Bilgewater Cartel
  198.         [1446]      = 59,       -- Thorium Point/Thorium Brotherhood
  199.         [1658]      = 609,      -- Cenarion Enclave/Cenarion Circle
  200.         [1677]      = A and 730 or H and 729, -- Gavin's Naze/Stormpike Guard or Frostwolf Clan
  201.         [1678]      = 72,       -- Sofera's Naze/Stormwind
  202.         [1679]      = A and 730 or H and 729, -- Corrahn's Dagger/Stormpike Guard or Frostwolf Clan
  203.         [1680]      = A and 730 or H and 729, -- The Headland/Stormpike Guard or Frostwolf Clan
  204.         [1739]      = 87,       -- Bloodsail Compound/Bloodsail Buccaneers
  205.         [1741]      = 87,       -- Gurubashi Arena/Bloodsail Buccaneers
  206.         [1761]      = 579,      -- Deadwood Village/Timbermaw Hold
  207.         [1762]      = 579,      -- Felpaw Village/Timbermaw Hold
  208.         [1769]      = 579,      -- Timbermaw Hold/Timbermaw Hold
  209.         [1778]      = 369,      -- Sorrowmurk/Gadgetzan
  210.         [1797]      = 1133,     -- Stagalbog/Bilgewater Cartel
  211.         [1858]      = 1174,     -- Boulder'gor/Wildhammer Clan
  212.         [1941]      = 989,      -- Caverns of Time/Keepers of Time
  213.         [1977]      = 309,      -- Zul'Gurub/Zandalar Tribe
  214.         [1998]      = 1134,     -- Talonbranch Glade/Gilneas
  215.         [2079]      = A and 54 or H and 68, -- Alcaz Island/Gnomeregan or Undercity
  216.         [2097]      = H and 81 or A and 69, -- Darkcloud Pinnacle/Thunder Bluff or Darnassus
  217.         [2157]      = H and 81 or A and 47, -- Bael'dun Keep/Thunder Bluff or Ironforge
  218.         [2240]      = A and 54 or H and 1133, -- Mirage Raceway/Gnomeregan or Bilgewater Cartel
  219.         [2241]      = 589,      -- Frostsaber Rock/Wintersaber Trainers
  220.         [2242]      = 69,       -- The Hidden Grove/Darnassus
  221.         [2243]      = 579,      -- Timbermaw Post/Timbermaw Hold
  222.         [2244]      = 579,      -- Winterfall Village/Timbermaw Hold
  223.         [2246]      = 579,      -- Frostfire Hot Springs/Timbermaw Hold
  224.         [2248]      = 47,       -- Dun Mandarr/Ironforge
  225.         [2253]      = 69,       -- Starfall Village/Darnassus
  226.         [2257]      = 72,       -- Deeprun Tram/Stormwind
  227.         [2300]      = 989,      -- Caverns of Time/Keepers of Time
  228.         [2379]      = 72,       -- Azurelode Mine/Stormwind
  229.         [2404]      = 69,       -- Tethris Aran/Darnassus
  230.         [2406]      = 69,       -- Ranazjar Isle/Darnassus
  231.         [2407]      = 470,      -- Kormek's Hut/Ratchet
  232.         [2408]      = 530,      -- Shadowprey Village/Darkspear Trolls
  233.         [2539]      = 530,      -- Malaka'jin/Darkspear Trolls
  234.         [2597]      = A and 730 or H and 729, -- Alterac Valley/Stormpike Guard or Frostwolf Clan
  235.         [2617]      = 470,      -- Scrabblescrew's Camp/Ratchet
  236.         [2738]      = 69,       -- Southwind Village/Darnassus
  237.         [2839]      = A and 730 or H and 729, -- Alterac Valley/Stormpike Guard or Frostwolf Clan
  238.         [2897]      = 530,      -- Zoram'gar Outpost/Darkspear Trolls
  239.         [3137]      = 69,       -- Talrendis Point/Darnassus
  240.         [3197]      = 72,       -- Chillwind Camp/Stormwind
  241.         [3217]      = 809,      -- Dire Maul (The Maul)/Shen'dralar
  242.         [3319]      = 890,      -- Silverwing Grove/Silverwing Sentinels
  243.         [3357]      = 270,      -- Yojamba Isle/Zandalar Tribe
  244.         [3426]      = 69,       -- Staghelm Point/Darnassus
  245.         [3427]      = 47,       -- Bronzebeard Encampment/Ironforge
  246.         [3486]      = 349,      -- Ravenholdt Manor/Ravenholdt
  247.         [4010]      = 369,      -- Mudsprocket/Gadgetzan
  248.         [4241]      = 1098,     -- Archerus: The Ebon Hold/Knights of the Ebon Blade
  249.         [4342]      = 1098,     -- Archerus: The Ebon Hold/Knights of the Ebon Blade
  250.         [4690]      = 1135,     -- Thunder Peak/The Earthen Ring
  251.         [4715]      = 1133,     -- The Skunkworks/Bilgewater Cartel
  252.         [4745]      = 76,       -- Orgrimmar Rear Gate/Orgrimmar
  253.         [4798]      = 1068,     -- Thoargad's Camp/Explorer's League
  254.         [4803]      = 911,      -- Furien's Post/Silvermoon City
  255.         [4882]      = 369,      -- Marshal's Stand/Gadgetzan
  256.         [4883]      = 369,      -- Mossy Pile/Gadgetzan
  257.         [4992]      = 809,      -- Dire Maul (Broken Commons)/Shen'dralar
  258.         [4925]      = 609,      -- Thunk's Abode/Cenarion Circle
  259.         [4927]      = 76,       -- The Fold/Orgimmar
  260.         [4933]      = 76,       -- Krom'gar Fortress/Orgimmar
  261.         [4934]      = 1133,     -- The Sludgewerks/Bilgewater Cartel
  262.         [4940]      = 1068,     -- Northwatch Expedition Base Camp/Explorer's League
  263.         [5011]      = 81,       -- Westrech Summit/Thunder Bluff
  264.         [5028]      = 87,       -- Southsea Holdfast/Bloodsail Buccaneers
  265.         [5041]      = A and 54 or H and 1133, -- Fizzle & Pozzik's Speedbarge/Gnomeregan or Bilgewater Cartel
  266.         [5044]      = 609,      -- The Tainted Forest/Cenarion Circle
  267.         [5048]      = A and 54 or H and 1133, -- Raceway Ruins/Gnomeregan or Bilgewater Cartel
  268.         [5083]      = 911,      -- Sunveil Excursion/Silvermoon City
  269.         [5117]      = 1133,     -- Nozzlepot's Outpost/Bilgewater Cartel
  270.         [5121]      = 68,       -- Galen's Fall/Undercity
  271.         [5305]      = 69,       -- Greenwarden's Grove/Darnassus
  272.         [5317]      = 530,      -- Bambala/Darkspear Trolls
  273.         [5367]      = 942,      -- The Mender's Stead/Cenarion Circle
  274.         [5388]      = 911,      -- Dawnrise Expedition/Silvermoon City
  275.         [5458]      = 369,      -- Bogpaddle/Gadgetzan
  276.         [5476]      = 1134,     -- Pyrewood Chapel/Gilneas
  277.         [5477]      = 1134,     -- Pyrewood Inn/Gilneas
  278.         [5478]      = 1134,     -- Pyrewood Town Hall/Gilneas
  279.         [5480]      = 1134,     -- Gilneas Liberation Base Camp/Gilneas
  280.         [5481]      = 47,       -- 7th Legion Base Camp/Ironforge
  281.         [5495]      = 54,       -- Gnomeregan/Gnomeregan
  282.         [5496]      = 369,      -- Fuselight/Gadgetzan
  283.         [5497]      = 369,      -- Fuselight-by-the-Sea/Gadgetzan
  284.         [5524]      = 911,      -- Bloodwatcher Point/Silvermoon City
  285.         [5564]      = 72,       -- Dragon's Mouth/Stormwind
  286.         [5645]      = 609,      -- Whisperwind Grove/Cenarion Circle
  287.         [5649]      = 609,      -- Wildheart Point/Cenarion Circle
  288.         [5654]      = 59,       -- Chiselgrip/Thorium Brotherhood
  289.         [5675]      = A and 69 or H and 81, -- Arikara's Needle/Darnassus or Thunder Bluff
  290.         [5687]      = 1134,     -- The Howling Oak/Gilneas
  291.         [5705]      = A and 47 or H and 530, -- Snowden Chalet/Ironforge or Darkspear Trolls
  292.         [5706]      = 369,      -- The Steam Pools/Gadgetzan
  293.         [9750]      = 68,       -- Hammerfall (BfA)/Undercity
  294.         [9755]      = 47,       -- Thandol Span (BfA)/Ironforge
  295.  
  296.         --------- TBC ---------
  297.         [3482]      = 922,      -- The Dead Scar/Tranquillien
  298.         [3514]      = 922,      -- The Dead Scar/Tranquillien
  299.         [3530]      = 911,      -- Shadow Ridge/Silvermoon City
  300.         [3547]      = 1077,     -- Throne of Kil'jaeden/Shattered Sun Offensive
  301.         [3552]      = 978,      -- Temple of Telhamat/Kurenai
  302.         [3554]      = 911,      -- Falcon Watch/Silvermoon City
  303.         [3555]      = 941,      -- Mag'har Post/The Mag'har
  304.         [3569]      = 69,       -- Tides' Hollow/Darnassus
  305.         [3573]      = 72,       -- Odesyus' Landing/Stormwind
  306.         [3801]      = 941,      -- Mag'har Grounds/The Mag'har
  307.         [3806]      = 911,      -- Supply Caravan/Silvermoon City
  308.         [3808]      = 942,      -- Cenarion Post/Cenarion Expedition
  309.         [3816]      = 21,       -- Zeppelin Crash/Booty Bay
  310.         [3899]      = 1011,     -- Lower City/Lower City
  311.         [4092]      = 922,      -- The Dead Scar/Tranquillien
  312.         [4140]      = 922,      -- The Dead Scar/Tranquillien
  313.  
  314.         --------- WotLK ---------
  315.         [7679]      = 1098,     -- Archerus: The Ebon Hold/Knights of the Ebon Blade
  316.         [7743]      = 1098,     -- Archerus: The Ebon Hold/Knights of the Ebon Blade
  317.  
  318.         --------- MoP ---------
  319.         [5876]      = 1271,     -- Serpent's Heart/Order of the Cloud Serpent
  320.         [5931]      = 1271,     -- The Arboretum/Order of the Cloud Serpent
  321.         [5974]      = 1341,     -- Jade Temple Grounds/The August Celestials
  322.         [5975]      = 1341,     -- Temple of the Jade Serpent/The August Celestials
  323.         [5976]      = 1270,     -- Gate of the Setting Sun/Shado-Pan
  324.         [6012]      = 1271,     -- Windward Isle/Order of the Cloud Serpent
  325.         [6013]      = 81,       -- Dawnchaser/Thunder Bluff
  326.         [6016]      = 69,       -- Sentinel Basecamp/Darnassus
  327.         [6022]      = 1271,     -- Mistveil Sea/Order of the Cloud Serpent
  328.         [6048]      = 1341,     -- Temple of the Red Crane/The August Celestials
  329.         [6080]      = 1271,     -- Serpent's Overlook/Order of the Cloud Serpent
  330.         [6117]      = 1341,     -- Fountain of the Everseeing/The August Celestials
  331.         [6118]      = 1341,     -- The Scrollkeeper's Sanctum/The August Celestials
  332.         [6119]      = 1341,     -- Terrace of the Twin Dragons/The August Celestials
  333.         [6120]      = 1341,     -- The Heart of Jade/The August Celestials
  334.         [6155]      = 1341,     -- Cradle of Chi-Ji/The August Celestials
  335.         [6160]      = 1341,     -- Angkhal Pavilion/The August Celestials
  336.         [6161]      = 1341,     -- Pedestal of Hope/The August Celestials
  337.         [6162]      = 1341,     -- Dome Balrissa/The August Celestials
  338.         [6174]      = 1341,     -- Temple of the White Tiger/The August Celestials
  339.         [6182]      = 1341,     -- Mogu'shan Palace2/The August Celestials
  340.         [6213]      = 1341,     -- Niuzao Temple/The August Celestials
  341.         [6143]      = 1341,     -- Mogu'shan Palace1/The August Celestials
  342.         [6295]      = 1345,     -- Seat of Knowledge/The Lorewalkers
  343.         [6368]      = 1302,     -- Soggy's Gamble/The Anglers
  344.         [6371]      = A and 1376 or H and 1375, -- The Southern Isles/Operation: Shieldwall or Dominance Offensive
  345.         [6393]      = 1270,     -- Serpent's Spine1/Shado-Pan
  346.         [6394]      = 1270,     -- Serpent's Spine2/Shado-Pan
  347.         [6395]      = 1270,     -- Serpent's Spine3/Shado-Pan
  348.         [6401]      = 1302,     -- Shelf of Mazu/The Anglers
  349.         [6402]      = 1302,     -- Wreck of the Mist-Hopper/The Anglers
  350.         [6433]      = 1302,     -- Lonesome Cove/The Anglers
  351.         [6482]      = A and 1341, -- The Summer Terrace/The August Celestials
  352.         [6498]      = 1341,     -- Gate of the August Celestials/The August Celestials
  353.         [6512]      = 1271,     -- The Widow's Wail/Order of the Cloud Serpent
  354.         [6513]      = 1271,     -- Oona Kagu/Order of the Cloud Serpent
  355.         [6560]      = H and 1341, -- The Golden Terrace/The August Celestials
  356.         [6566]      = A and 1376 or H and 1375, -- Domination Point/Operation: Shieldwall or Dominance Offensive
  357.         [6595]      = A and 1376 or H and 1375, -- The Skyfire/Operation: Shieldwall or Dominance Offensive
  358.         [6596]      = A and 1376 or H and 1375, -- Lion's Landing1/Operation: Shieldwall or Dominance Offensive
  359.         [6597]      = A and 1376 or H and 1375, -- Sparkrocket Outpost/Operation: Shieldwall or Dominance Offensive
  360.         [6600]      = A and 1376 or H and 1375, -- Blacksand Spillway/Operation: Shieldwall or Dominance Offensive
  361.         [6601]      = A and 1376 or H and 1375, -- Bilgewater Beach/Operation: Shieldwall or Dominance Offensive
  362.         [6602]      = A and 1376 or H and 1375, -- The Boiling Crustacean/Operation: Shieldwall or Dominance Offensive
  363.         [6604]      = A and 1376 or H and 1375, -- Quickchop's Lumber Farm/Operation: Shieldwall or Dominance Offensive
  364.         [6609]      = A and 1376 or H and 1375, -- Ruins of Ogudei/Operation: Shieldwall or Dominance Offensive
  365.         [6643]      = A and 1376 or H and 1375, -- Lion's Landing/Operation: Shieldwall or Dominance Offensive
  366.         [6644]      = A and 1376 or H and 1375, -- Domination Point (Horde)/Operation: Shieldwall or Dominance Offensive
  367.         [6701]      = 54,       -- Beeble's Wreck/Gnomeregan
  368.         [6702]      = 1133,     -- Bozzle's Wreck/Bilgewater Cartel
  369.         [6771]      = 1341,     -- Celestial Tournament/The August Celestials
  370.  
  371.  
  372.         --------- BfA ---------
  373.         [9310]      = 2386,     -- The Wound/Champions of Azeroth
  374.         [9329]      = 2387,     -- Seeker's Outpost/Tortollan Seekers
  375.         [9473]      = 69,       -- Staghelm Point/Darnassus
  376.         [9474]      = 1133,     -- Southwind Village/Bilgewater Cartel
  377.         [9494]      = 1133,     -- Warfront: The Battle for Stromgarde (Ar'gorok)/Bilgewater Cartel
  378.         [9556]      = 2387,     -- Tortaka Refuge/Tortollan Seekers
  379.         [9667]      = 2386,     -- Chamber of Heart/Champions of Azeroth
  380.         [9693]      = 2387,     -- Seeker's Vista/Tortollan Seekers
  381.         [9714]      = 2387,     -- Seeker's Expedition/Tortollan Seekers
  382.         [9735]      = 1133,     -- Ar'gorok/Bilgewater Cartel
  383.         [10006]     = 2387,     -- House of Jol/Tortollan Seekers
  384.         [10504]     = 2386,     -- Chamber of Heart (rebuilt)/Champions of Azeroth
  385.         [15539]     = 1098,     -- Archerus: The Ebon Hold (Class Hall)/Knights of the Ebon Blade
  386.  
  387.         --------- Shadowlands ---------
  388.         [10565]     = covenantRepID, -- Oribos/Covenant
  389.         [11533]     = covenantRepID == 3 and 2422 or 2465, -- Tirna Noch/Night Fae or The Wild Hunt
  390.         [12876]     = covenantRepID == 4 and 2410 or 2410, -- Seat of the Primus/The Undying Army
  391.         [13209]     = covenantRepID, -- Netherhollow (Oribos)/Covenant
  392.         [13367]     = covenantRepID == 3 and 2422 or 2465, -- Queen's Conservatory/Night Fae or The Wild Hunt
  393.         [13498]     = covenantRepID, -- Ring of Transference (Oribos)/Covenant
  394.         [13499]     = covenantRepID, -- Ring of Fates (Oribos)/Covenant
  395.     }
  396.     return subZonesAndFactions
  397. end
  Reply With Quote
03-09-21, 03:45 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,186
What I meant about changing the code to use return instead of break would look like this:
Lua Code:
  1. if self:SetWatchedFactionByFactionID(factionID) then
  2.     return
  3. end
If I make that change, it might work, but I feel like I am trying to write code until something sticks; therefore I am asking for more eyes to find anything that I missed.

Oh, and I forgot as part of "show the code", here is the section that sets the reputation bar by factionID.
Lua Code:
  1. -------------------- Reputation code starts here --------------------
  2. local repsCollapsed = {} -- Obey user's settings about headers opened or closed
  3. -- Open all faction headers
  4. function RepByZone:OpenAllFactionHeaders()
  5.     local i = 1
  6.     while i <= GetNumFactions() do
  7.         local name, _, _, _, _, _, _, _, isHeader, isCollapsed = GetFactionInfo(i)
  8.         if isHeader then
  9.             repsCollapsed[name] = isCollapsed
  10.             if name == FACTION_INACTIVE then
  11.                 if not isCollapsed then
  12.                     CollapseFactionHeader(i)
  13.                 end
  14.                 break
  15.             elseif isCollapsed then
  16.                 ExpandFactionHeader(i)
  17.             end
  18.         end
  19.         i = i + 1
  20.     end
  21. end
  22.  
  23. -- Close all faction headers
  24. function RepByZone:CloseAllFactionHeaders()
  25.     local i = 1
  26.     while i <= GetNumFactions() do
  27.         local name, _, _, _, _, _, _, _, isHeader, isCollapsed = GetFactionInfo(i)
  28.         if isHeader then
  29.             if isCollapsed and not repsCollapsed[name] then
  30.                 ExpandFactionHeader(i)
  31.             elseif repsCollapsed[name] and not isCollapsed then
  32.                 CollapseFactionHeader(i)
  33.             end
  34.         end
  35.         i = i + 1
  36.     end
  37.     wipe(repsCollapsed)
  38. end
  39.  
  40. function RepByZone:GetAllFactions()
  41.     -- Will not return factions the user has marked as inactive
  42.     self:OpenAllFactionHeaders()
  43.     local factionList = {}
  44.  
  45.     for i = 1, GetNumFactions() do
  46.         local name, _, _, _, _, _, _, _, isHeader, _, _, _, _, factionID = GetFactionInfo(i)
  47.         if not isHeader then
  48.             factionList[factionID] = name
  49.         end
  50.     end
  51.     factionList["0-none"] = NONE
  52.  
  53.     self:CloseAllFactionHeaders()
  54.     return factionList
  55. end
  56.  
  57. -- Blizzard sets watched faction by index, not by factionID so create our own API
  58. function RepByZone:SetWatchedFactionByFactionID(id)
  59.     if type(id) ~= "number" then return end
  60.  
  61.     self:OpenAllFactionHeaders()
  62.     for i = 1, GetNumFactions() do
  63.         local name, _, standingID, _, _, _, _, _, isHeader, _, _, isWatched, _, factionID = GetFactionInfo(i)
  64.         if id == factionID then
  65.             if not isWatched then
  66.                 SetWatchedFactionIndex(i)
  67.                 if db.verbose then
  68.                     self:Print(L["Now watching %s"]:format(name))
  69.                 end
  70.             end
  71.             self:CloseAllFactionHeaders()
  72.             return name, id
  73.         end
  74.     end
  75.     self:CloseAllFactionHeaders()
  76. end

Last edited by myrroddin : 03-09-21 at 03:48 PM. Reason: More "show the code"
  Reply With Quote
03-10-21, 12:13 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,186
Nevermind people. It turns out I tested the if/then and it works. At least it does so far. I'll do more testing, but thus far it did the trick.
Lua Code:
  1. if self:SetWatchedFactionByFactionID(factionID) then
  2.     return
  3. end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » RepByZone does not revert to zone data if subzone has no data

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off