code cleanup - merge had duplicated some lines; removed GetBSI func

AssemblerManiac [02-16-18 - 16:14]
code cleanup - merge had duplicated some lines; removed GetBSI func
Filename
IIfA/IIfA.lua
IIfA/IIfABackpack.lua
IIfA/IIfADataCollection.lua
IIfA/IIfAEvents.lua
IIfA/IIfA_xml_adapter.lua
diff --git a/IIfA/IIfA.lua b/IIfA/IIfA.lua
index b631331..c55ff36 100644
--- a/IIfA/IIfA.lua
+++ b/IIfA/IIfA.lua
@@ -258,21 +258,21 @@ function IIfA_onLoad(eventCode, addOnName)

 	IIfA.filterGroup = "All"
 	IIfA.filterTypes = nil
-
+
 	-- grabs data from bagpack, and worn bag when we first open the inventory
-	-- ZO_PreHook(PLAYER_INVENTORY, "ApplyBackpackLayout", IIfA.OnFirstInventoryOpen)
-	ZO_PreHook(BACKPACK_GUILD_BANK_LAYOUT_FRAGMENT, "ApplyBackpackLayout", IIfA.CollectGuildBank)
-
-	-- ZO_PreHook(SHARED_INVENTORY, "GetOrCreateBagCache", function(self, bagId)
+	-- ZO_PreHook(PLAYER_INVENTORY, "ApplyBackpackLayout", IIfA.OnFirstInventoryOpen)
+	ZO_PreHook(BACKPACK_GUILD_BANK_LAYOUT_FRAGMENT, "ApplyBackpackLayout", IIfA.CollectGuildBank)
+
+	-- ZO_PreHook(SHARED_INVENTORY, "GetOrCreateBagCache", function(self, bagId)
 		-- d("SHARED_INVENTORY: GetOrCreateBagCache: " .. tostring(bagId))
 	-- end)
-	-- ZO_PreHook(SHARED_INVENTORY, "PerformFullUpdateOnBagCache", function(self, bagId)
+	-- ZO_PreHook(SHARED_INVENTORY, "PerformFullUpdateOnBagCache", function(self, bagId)
 		-- d("SHARED_INVENTORY: PerformFullUpdateOnBagCache: " .. tostring(bagId))
 	-- end)

-
-	-- http://esodata.uesp.net/100016/src/libraries/utility/zo_savedvars.lua.html#67
-
+
+	-- http://esodata.uesp.net/100016/src/libraries/utility/zo_savedvars.lua.html#67
+

 	IIfA.settings 	= ZO_SavedVars:NewCharacterIdSettings("IIfA_Settings", 1, nil, default)
 	IIfA.data 		= ZO_SavedVars:NewAccountWide("IIfA_Data", 1, "Data", defaultGlobal)
@@ -300,7 +300,7 @@ function IIfA_onLoad(eventCode, addOnName)
 		end
 	end
 	nukePositioning()
-
+
 	if IIfA.settings.in2ToggleGuildBankDataCollection ~= nil then
 		IIfA.settings.in2ToggleGuildBankDataCollection = nil
 	end
@@ -356,10 +356,10 @@ function IIfA_onLoad(eventCode, addOnName)
 	IIfA:SetupCharLookups()

 	-- overwrite non-global tables if present
-
+
 	IIfA.settings.accountCharacters = nil
 	IIfA.settings.guildBanks = nil
-
+

 	-- this MUST remain in this location, otherwise it's possible that CollectAll will remove ALL characters data from the list (because they haven't been converted)
 	if IIfA.data.accountCharacters ~= nil then
@@ -481,16 +481,16 @@ function IIfA_onLoad(eventCode, addOnName)
 		end
 		IIfA.data.DBv3 = dbv3
 	end
-
+
 	-- keep EU and US items apart
 	local worldName = GetWorldName():gsub(" Megaserver", "")
 	IIfA.data[worldName] = IIfA.data[worldName] or {}
-	if nil == IIfA.data[worldName].DBv3 then
+	if nil == IIfA.data[worldName].DBv3 then
 		 IIfA.data[worldName].DBv3 = IIfA.data.DBv3
 	end
 	IIfA.data.DBv3 = nil
 	IIfA.database = IIfA.data[worldName].DBv3
-
+
 	IIfA:ActionLayerInventoryUpdate()

 	if not ObjSettings.frameSettings.hud.hidden then
@@ -499,19 +499,19 @@ function IIfA_onLoad(eventCode, addOnName)

 	IIfA:RegisterForEvents()
 	IIfA:RegisterForSceneChanges() -- register for callbacks on scene statechanges using user preferences or defaults
-
-	IIfA.trackedBags[BAG_WORN] 		= not IIfA:IsCharacterEquipIgnored(IIfA.currentCharacterId)
+
+	IIfA.trackedBags[BAG_WORN] 		= not IIfA:IsCharacterEquipIgnored(IIfA.currentCharacterId)
 	IIfA.trackedBags[BAG_BACKPACK] 	= not IIfA:IsCharacterInventoryIgnored(IIfA.currentCharacterId)
-
+
 	IIfA:CollectAll()
-
+

 end

 EVENT_MANAGER:RegisterForEvent("IIfALoaded", EVENT_ADD_ON_LOADED, IIfA_onLoad)

 function IIfA:ScanCurrentCharacterAndBank()
-
+
 	IIfA:ScanBank()
 	IIfA:ScanCurrentCharacter()
 	zo_callLater(function()
@@ -543,6 +543,7 @@ function IIfA:MakeBSI()
 		end
 	end
 	IIfA.BagSlotInfo = bs
+	return bs	-- return only used in IIfA:SaveBagSlotIndex when IIfA.BagSlotInfo is nil
 end


diff --git a/IIfA/IIfABackpack.lua b/IIfA/IIfABackpack.lua
index 9b9564e..749def0 100644
--- a/IIfA/IIfABackpack.lua
+++ b/IIfA/IIfABackpack.lua
@@ -192,9 +192,6 @@ local function getQualityDict()
 	end
 	return qualityDictionary
 end
-function IIfA:getQualityDict()
-	return qualityDictionary or getQualityDict()
-end

 function IIfA:getQualityDict()
 	return qualityDictionary or getQualityDict()
@@ -750,8 +747,7 @@ function IIfA:SetupBackpack()
 		local qualityDict = getQualityDict()

 		IIFA_GUI_Header_Dropdown_Quality.comboBox = IIFA_GUI_Header_Dropdown_Quality.comboBox or ZO_ComboBox_ObjectFromContainer(IIFA_GUI_Header_Dropdown_Quality)
-		local qualityDict = getQualityDict()
-
+
 		local validChoices =  {}
 		table.insert(validChoices, "Any")
 		table.insert(validChoices, getColoredString(ITEM_QUALITY_TRASH, "Junk"))
diff --git a/IIfA/IIfADataCollection.lua b/IIfA/IIfADataCollection.lua
index cc69ac1..2337080 100644
--- a/IIfA/IIfADataCollection.lua
+++ b/IIfA/IIfADataCollection.lua
@@ -109,7 +109,7 @@ function IIfA:ScanCurrentCharacter()
 	end
 	task:Call(function()
 		IIfA:MakeBSI()
-	end)
+	end)
 end

 local function tryScanHouseBank()
@@ -283,13 +283,13 @@ function IIfA:RescanHouse(houseCollectibleId)
 	houseCollectibleId = houseCollectibleId or GetCollectibleIdForHouse(GetCurrentZoneHouseId())
 	if not houseCollectibleId then return end

-
+
 	IIfA.data.collectHouseData[houseCollectibleId] = IIfA.data.collectHouseData[houseCollectibleId] or IIfA:GetHouseTracking()
-
-	if not IIfA.data.collectHouseData[houseCollectibleId] then
-		if IIfA:GetHouseTracking() and IIfA:GetIgnoredHousIds()[houseCollectibleId] then
+
+	if not IIfA.data.collectHouseData[houseCollectibleId] then
+		if IIfA:GetHouseTracking() and IIfA:GetIgnoredHousIds()[houseCollectibleId] then
 			IIfA.trackedBags[houseCollectibleId] = false
-			return
+			return
 		end
 		IIfA.trackedBags[houseCollectibleId] = true
 	end
@@ -318,7 +318,7 @@ function IIfA:RescanHouse(houseCollectibleId)
 			-- (bagId, slotId, fromXfer, itemCount, itemLink, itemName, locationID)
 			IIfA:DebugOut("furniture item <<1>> x<<2>>", itemLink, itemCount)
 			IIfA:EvalBagItem(houseCollectibleId, IIfA:GetItemID(itemLink), false, itemCount, itemLink, GetItemLinkName(itemLink), houseCollectibleId)
-
+
 		end
 	end)

@@ -401,17 +401,9 @@ local function getLocation(location, bagId)
 	end
 end

--- use getbsi to avoid "trying to access nil" errors
-function IIfA:GetBSI()
-	if nil == IIfA.BagSlotInfo then
-		IIfA:MakeBSI()
-	end
-	return IIfA.BagSlotInfo
-end
-
 function IIfA:SaveBagSlotIndex(bagId, slotId, itemLink)
 	if not bagId or not slotId then return end
-	IIfA.BagSlotInfo = IIfA.BagSlotInfo or {}
+	IIfA.BatSlotInfo = IIfA.BagSlotInfo or IIfA:MakeBSI()
 	IIfA.BagSlotInfo[bagId] = IIfA.BagSlotInfo[bagId] or {}
 	IIfA.BagSlotInfo[bagId][slotId] = IIfA.BagSlotInfo[bagId][slotId] or itemLink
 end
@@ -423,18 +415,18 @@ function IIfA:AddOrRemoveFurnitureItem(itemLink, itemCount, houseCollectibleId,
 end

 function IIfA:EvalBagItem(bagId, slotId, fromXfer, itemCount, itemLink, itemName, locationID)
-
+
 	if not IIfA.trackedBags[bagId] then return end

 	IIfA.database = IIfA.database or {}
 	local DBv3 = IIfA.database
-
+
 	IIfA:DebugOut("trying to save <<1>> x<<2>>", itemLink, itemCount)
-
+
 	-- item link is either passed as arg or we need to read it from the system
 	itemLink = itemLink or getItemLink(bagId, slotId)

-
+
 	-- return if we don't have any item to track
 	if nil == itemLink  then return end

@@ -444,7 +436,7 @@ function IIfA:EvalBagItem(bagId, slotId, fromXfer, itemCount, itemLink, itemName
 	-- item count is either passed or we have to get it from bag/slot ID or item link
 	itemCount = itemCount or getItemCount(bagId, slotId, itemLink)

-
+
 	-- get item key from crafting type
 	local usedInCraftingType, itemType = GetItemCraftingInfo(bagId, slotId)

@@ -460,14 +452,14 @@ function IIfA:EvalBagItem(bagId, slotId, fromXfer, itemCount, itemLink, itemName
 	if itemType == 0 then itemType = nil end

 	local itemKey = getItemKey(itemLink, usedInCraftingType, itemType) or itemLink
-
+
 	IIfA:DebugOut("saving <<1>> x<<2>> -> <<3>>", itemLink, itemCount, itemKey)
-
+

 	if nil == itemKey then return end
-
-
-
+
+
+
 	itemFilterType = GetItemFilterTypeInfo(bagId, slotId) or 0
 	DBitem = DBv3[itemKey]
 	location = locationID or getLocation(location, bagId) or EMPTY_STRING
@@ -560,12 +552,12 @@ function IIfA:CollectAll()
 		task:Call(function()
 			bagItems = GetBagSize(bagId)
 			if(bagId == BAG_WORN) then	--location for BAG_BACKPACK and BAG_WORN is the same so only reset once
-				IIfA:ClearLocationData(IIfA.currentCharacterId)
-				grabBagContent(BAG_WORN)
+				IIfA:ClearLocationData(IIfA.currentCharacterId)
+				grabBagContent(BAG_WORN)
 			elseif(bagId == BAG_BANK) then	-- do NOT add BAG_SUBSCRIBER_BANK here, it'll wipe whatever already got put into the bank on first hit
 				IIfA:ClearLocationData(GetString(IIFA_BAG_BANK))
 				grabBagContent(BAG_BANK)
-			elseif(bagId == BAG_BACKPACK) then
+			elseif(bagId == BAG_BACKPACK) then
 				IIfA:ClearLocationData(GetString(IIFA_BAG_BACKPACK))
 				grabBagContent(BAG_BACKPACK)
 			elseif(bagId == BAG_VIRTUAL)then
diff --git a/IIfA/IIfAEvents.lua b/IIfA/IIfAEvents.lua
index fefbee2..ddf50d8 100644
--- a/IIfA/IIfAEvents.lua
+++ b/IIfA/IIfAEvents.lua
@@ -16,12 +16,13 @@ end
 -- used by an event function
 function IIfA:InventorySlotUpdate(eventCode, bagId, slotId, isNewItem, itemSoundCategory, inventoryUpdateReason, qty)

-	if nil == bagId then return end
+	if nil == bagId or nil == slotId then return end
 	if isNewItem then
 		isNewItem = "True"
 	else
 		isNewItem = "False"
 	end
+
 	local itemLink = GetItemLink(bagId, slotId, LINK_STYLE_BRACKETS) or ""
 	if #itemLink == 0 and IIfA.BagSlotInfo[bagId] ~= nil and IIfA.BagSlotInfo[bagId][slotId] then
 		itemLink = IIfA.BagSlotInfo[bagId][slotId]
@@ -62,7 +63,7 @@ local function IIfA_HouseEntered(eventCode)
 	local houseCollectibleId = GetCollectibleIdForHouse(GetCurrentZoneHouseId())

 	if nil == IIfA.data.collectHouseData[houseCollectibleId] then
-		IIfA:SetTrackingForHouse(houseCollectibleId,  IIfA:GetCollectingHouseData())
+		IIfA:SetTrackingForHouse(houseCollectibleId,  IIfA:GetCollectingHouseData())
 	end
 	IIfA:GetTrackedBags()[houseCollectibleId] = IIfA:GetTrackedBags()[houseCollectibleId] or IIfA.data.collectHouseData[houseCollectibleId]
 	IIfA:RescanHouse(houseCollectibleId)
diff --git a/IIfA/IIfA_xml_adapter.lua b/IIfA/IIfA_xml_adapter.lua
index 5411eeb..2ce7f32 100644
--- a/IIfA/IIfA_xml_adapter.lua
+++ b/IIfA/IIfA_xml_adapter.lua
@@ -496,7 +496,6 @@ function IIfA:RePositionFrame(settings)
 	IIFA_GUI_Header_Dropdown:SetHidden(bMinimize)
 	IIFA_GUI_Header_Dropdown_Quality:SetHidden(bMinimize)
 	IIFA_GUI_Search:SetHidden(bMinimize)
-	IIFA_GUI_Header_Dropdown_Quality:SetHidden(bMinimize)
 	IIFA_GUI_Header_GoldButton:SetHidden(bMinimize)
 	IIFA_GUI_Header_BagButton:SetHidden(bMinimize)
 	IIFA_GUI_Header_SortBar:SetHidden(bMinimize)