public static void UpdateItemList()
{
List<int> SeenACDGuid = new List<int>();
//Clear New Item List
NewItemList.Clear();
using (ZetaDia.Memory.AcquireFrame())
{
foreach (var thisitem in ZetaDia.Me.Inventory.Backpack)
{
var ACDGuid = thisitem.ACDGuid;
SeenACDGuid.Add(ACDGuid);
if (CacheItemList.ContainsKey(ACDGuid))
{
var cachedItem = CacheItemList[ACDGuid];
//Stackable item that increased
if (CacheItemList[ACDGuid].IsStackableItem)
{
try
{
if (cachedItem.ThisItemStackQuantity != thisitem.ItemStackQuantity)
{
//Update it..
cachedItem.ThisItemStackQuantity = thisitem.ItemStackQuantity;
//Check if stack quanity is maxed to remove it from our list
if (cachedItem.ThisItemStackQuantity >= cachedItem.MaxStackQuanity &&
_stackableItems.Contains(cachedItem.SNO))
_stackableItems.Remove(cachedItem.SNO);
//Add it to new item list..
NewItemList.Add(CacheItemList[ACDGuid]);
}
}
catch (Exception ex)
{
//Logger.DBLog.DebugFormat("Item {0} stack quanity threw exception {1}",
//CacheItemList[ACDGuid].ThisInternalName, ex.Message);
}
}
continue;
}
var thiscacheditem = new CacheACDItem(thisitem);
CacheItemList.Add(thiscacheditem.ACDGUID, thiscacheditem);
//Add it to new item list..
NewItemList.Add(thiscacheditem);
//
_occupiedSlots += thiscacheditem.IsTwoSlot ? 2 : 1;
if (thiscacheditem.IsStackableItem &&
thiscacheditem.ThisItemStackQuantity < thiscacheditem.MaxStackQuanity &&
!_stackableItems.Contains(thiscacheditem.SNO))
_stackableItems.Add(thiscacheditem.SNO);
if (thiscacheditem.invCol >= 0 && thiscacheditem.invCol <= 9 && thiscacheditem.invRow >= 0 &&
thiscacheditem.invRow <= 5)
{
_backpackslotblocked[thiscacheditem.invCol, thiscacheditem.invRow] = true;
if (thiscacheditem.IsTwoSlot)
_backpackslotblocked[thiscacheditem.invCol, thiscacheditem.invRow + 1] = true;
}
}
}
//Trim away items missing..
var UnseenACDGuids = CacheItemList.Keys.Where(k => !SeenACDGuid.Contains(k)).ToList();
foreach (var unseenAcdguiD in UnseenACDGuids)
{
var item = CacheItemList[unseenAcdguiD];
if (item.IsStackableItem && _stackableItems.Contains(item.SNO))
_stackableItems.Remove(item.SNO);
_occupiedSlots -= item.IsTwoSlot ? 2 : 1;
_backpackslotblocked[item.invCol, item.invRow] = false;
if (item.IsTwoSlot)
_backpackslotblocked[item.invCol, item.invRow + 1] = false;
CacheItemList.Remove(unseenAcdguiD);
}
}