diff Modules/Mover.lua @ 111:41f0689dfda1

This implementation of vendor buying did not work well. Too many customizations were needed that made the code hard to read and understand and eventually it was found that vendor buying should be based on refill target, not local stock. The mover/refiller is not meant for this, we should just do this somewhere else.
author Zerotorescue
date Fri, 14 Jan 2011 23:31:12 +0100
parents 67bd5057ecb7
children 239e25a058c7
line wrap: on
line diff
--- a/Modules/Mover.lua	Fri Jan 14 23:25:05 2011 +0100
+++ b/Modules/Mover.lua	Fri Jan 14 23:31:12 2011 +0100
@@ -11,7 +11,6 @@
 	Bank = 1,
 	Guild = 2,
 	Mailbox = 3,
-	Merchant = 4,
 };
 
 local ContainerFunctions = {
@@ -51,37 +50,14 @@
 		Synchronous = true, -- wait after every single move
 		Event = "BAG_UPDATE",
 	},
-	[addon.Locations.Merchant] = {
-		GetItemId = function(_, merchantIndex)
-			return addon:GetItemId(GetMerchantItemLink(merchantIndex));
-		end,
-		PickupItem = function(_, merchantIndex, num)
-			-- The below behavior was changed in patch 4.0.1, it now acts as expected; quantity requested equals exact quantity bought, even with increased batchsize
-			
-			-- Some merchant items are sold in batches (e.g. of 5)
-			-- In that case BuyMerchantItem wants the num stacks, rather than the quantity to be bought
-			--local batchSize = select(4, GetMerchantItemInfo(merchantIndex));
-			
-			--local batches = math.ceil(num / batchSize);
-			
-			--BuyMerchantItem(merchantIndex, batches);
-			
-			return BuyMerchantItem(merchantIndex, num);
-		end,
-		IsLocked = function() return false; end,
-		DoNotDrop = true, -- BuyMerchantItem does not support picking up
-		Burst = true, -- spam buy items, the source can take it
-		Event = "BAG_UPDATE",
-	},
 };
 
-function mod:AddMove(itemId, amount, numMissing, numAvailable, price)
+function mod:AddMove(itemId, amount, numMissing, numAvailable)
 	table.insert(queuedMoves, {
 		["itemId"] = itemId,
 		["num"] = amount, -- can not be unlimited
 		["missing"] = numMissing,
 		["available"] = numAvailable,
-		["price"] = price,
 	});
 end
 
@@ -173,40 +149,12 @@
 		else
 			-- We want to move the smallest stacks first to keep stuff pretty (and minimize space usage, splitting a stack takes 2 slots, moving something only 1)
 			table.sort(sourceItem.locations, function(a, b)
-				-- -1 indicates unlimited, this is always more than an actual amount
-				if a.count == -1 then
-					return false;
-				elseif b.count == -1 then
-					return true;
-				end
-				
 				return a.count < b.count;
 			end);
 			
 			for _, itemLocation in pairs(sourceItem.locations) do
 				-- if this location has more items than we need, only move what we need, otherwise move everything in this stack
-				local movingNum = (((itemLocation.count == -1 or itemLocation.count > singleMove.num) and singleMove.num) or itemLocation.count);
-				
-				if itemLocation.count == -1 then
-					-- If the source has an unlimited quantity, makes moves based on the max stacksize
-					
-					local stackSize = select(8, GetItemInfo(singleMove.itemId)); -- 8 = stacksize
-					
-					if stackSize then
-						while movingNum > stackSize do
-							-- Move a single stack size while the amount remaining to be moved is above the stack size num
-							
-							table.insert(outgoingMoves, {
-								["itemId"] = singleMove.itemId,
-								["num"] = stackSize,
-								["container"] = itemLocation.container,
-								["slot"] = itemLocation.slot,
-							});
-							
-							movingNum = (movingNum - stackSize);
-						end
-					end
-				end
+				local movingNum = ((itemLocation.count > singleMove.num and singleMove.num) or itemLocation.count);
 				
 				table.insert(outgoingMoves, {
 					["itemId"] = singleMove.itemId,