View Bug Report
iLevel without using a list logic errors
Bug #: 7056
File: Sell-O-Matic
Date: 11-23-10 02:01 AM
By: Masasim
Status: Unconfirmed
Hi! I'm really glad that your addon exists, I couldn't find another that did similar things without installing all the bloat of the auctioneer addon.

I did notice some bugs though, which I've found in the code (thanks for making it so easy to read!):

First, if you check "Use iLevel" under "Item Options" (ie, not using the list option), and also "Sell BoP" and "Sell BoE", the addon sells all BoE and BoP in the character's inventory (regardless of iLevel). The reason for this is as follows:

Your code looks like this:
Code:
		-- ONLY SELL GRAY ITEMS
		num = self:SellTrash(num)
		-- Sell iLevel items
		if self.db.profile.useILevel then
			num = self:SellItemLevel(num);
		end;
		-- Sell soulbound items
		if self.db.profile.allowBoP then
			num = self:SellBindItems(ITEM_SOULBOUND,num);
		end;
		-- Sell bind on equip items
		if self.db.profile.allowBoE then
			num = self:SellBindItems(ITEM_BIND_ON_EQUIP,num);
		end;
This is wrong because the addon checks to see if the user wants to sell based on iLevel, then it also sells all soulbound items and all BoE gear as well (if they are flagged as "allowed"). I believe the intended logic is to sell items based on iLevel if the box is flagged, and then to sell soulbound and BoE items if iLevel is not flagged.

This should look more like this:
Code:
-- ONLY SELL GRAY ITEMS
		num = self:SellTrash(num)
		-- Sell iLevel items
		if self.db.profile.useILevel then
			num = self:SellItemLevel(num);
		else -- If just selling all items regardless of iLevel
			if self.db.profile.allowBoP then
				num = self:SellBindItems(ITEM_SOULBOUND,num);
			end;
			if self.db.profile.allowBoE then
				num = self:SellBindItems(ITEM_BIND_ON_EQUIP,num);
			end;
		end;
This way the addon will sell based on iLevel if "Use iLevel" is checked, and then sell all the BoE and BoP if it isn't checked.


Also, there is a bug with your selling logic in the SellItemLevel function:

In the first section (the logic if using a list), it wants to read (changes in bold):

Code:
if item_tooltip:Find(ITEM_BIND_ON_EQUIP,1,3) and self.db.profile.list_allowBoE or item_tooltip:Find(ITEM_SOULBOUND,1,3) and self.db.profile.list_allowBoP then
					if iRarity == 2 or self.db.profile.list_allowBlue and iRarity == 3 or self.db.profile.list_allowEpic and iRarity == 4 then
						num = self:SellItem(name,bag,slot,num);
					end;
				end;
IE, you're using the non-list variable when you mean to use the list variable.

You have a similar error in the second section (the non-list logic). This time, delete the bold text:

Code:
if item_tooltip:Find(ITEM_BIND_ON_EQUIP,1,3) and self.db.profile.allowBoE or item_tooltip:Find(ITEM_SOULBOUND,1,3) and self.db.profile.list_allowBoP then
							if iRarity == 2 or self.db.profile.allowBlue and iRarity == 3 or self.db.profile.allowEpic and iRarity == 4 then
								num = self:SellItem(sLink,sBag,sSlot,num);
							end;
						end;
I gave the rest of it a cursory look, and it looks to function well.

I hope this helps you.