Quantcast

fixed isAtVendor always being true after visiting a merchant once. fixed not selling at all if repairs need to be done (same error)

ckaotik [05-22-10 - 22:21]
fixed isAtVendor always being true after visiting a merchant once. fixed not selling at all if repairs need to be done (same error)
Filename
core.lua
helper.lua
diff --git a/core.lua b/core.lua
index 212d197..9dfe90a 100644
--- a/core.lua
+++ b/core.lua
@@ -73,12 +73,13 @@ local function eventHandler(self, event, ...)
 		end

 	elseif event == "MERCHANT_SHOW" then
+		BrokerGarbage.isAtVendor = true
+
 		local disable = BrokerGarbage.disableKey[BG_GlobalDB.disableKey]
 		if not (disable and disable()) then
 			BrokerGarbage:AutoRepair()
 			BrokerGarbage:AutoSell()
 		end
-		BrokerGarbage.isAtVendor = true

 	elseif locked and event == "MERCHANT_CLOSED" then
 		-- fallback unlock
@@ -88,6 +89,10 @@ local function eventHandler(self, event, ...)
 		locked = false
 		BrokerGarbage:Debug("Fallback Unlock: Merchant window closed, scan lock released.")
 		UpdateLDB()
+
+	elseif event == "MERCHANT_CLOSED" then
+		-- we are unlocked, but still need to update this state
+		BrokerGarbage.isAtVendor = false

 	elseif event == "AUCTION_HOUSE_CLOSED" then
 		-- Update cache auction values if needed
@@ -512,10 +517,8 @@ function BrokerGarbage:FindSlotToDelete(itemID, ignoreFullStack)
 				local _,count,_,_,_,_,link = GetContainerItemInfo(container, slot)

 				if link and BrokerGarbage:GetItemID(link) == itemID then
-					BrokerGarbage:Debug("item found")
 					if not ignoreFullStack or (ignoreFullStack and count < maxStack) then
 						-- found one
-						BrokerGarbage:Debug("item stack ok")
 						table.insert(locations, {
 							slot = slot,
 							bag = container,
diff --git a/helper.lua b/helper.lua
index 4105ab0..69fccad 100644
--- a/helper.lua
+++ b/helper.lua
@@ -511,6 +511,10 @@ function BrokerGarbage:UpdateCache(itemID)
 	end

 	-- save to items cache
+	if not value and not class then
+		BrokerGarbage:Debug("Caching item "..itemID.." failed!")
+		return
+	end
 	if not BrokerGarbage.itemsCache[itemID] then
 		BrokerGarbage.itemsCache[itemID] = {
 			classification = class,