Exemple #1
0
        private void LoadItem(object state)
        {
            // check done status
            if (Done)
            {
                return;
            }

            // continue updating
            ItemToUpdate info = state as ItemToUpdate;
            Item         i    = null;

            try
            {
                if (useArmory)
                {
                    i = Item.LoadFromId(info.item.Id, true, false, false, false);
                }
                else
                {
                    i = Item.LoadFromId(info.item.Id, true, false, true, usePTR, Rawr.Properties.GeneralSettings.Default.Locale);
                }
            }
            catch (Exception ex)
            {
                StatusMessaging.ReportError("Load item", ex, string.Format("Unable to update '{0}' due to an error: {1}\r\n\r\n{2}", info.item.Name, ex.Message, ex.StackTrace));
            }

            bool completelyDone = false;

            lock (lockObject)
            {
                if (i != null /* && (i.Stats.ToString().Contains(",") || (i.Stats.Armor + i.Stats.BonusArmor == 0 && i.Stats.ToString().Length > 0))*/)
                {
                    newItems.Add(info.index, i);
                }
                itemsDone++;
                completelyDone = done = finishedInput && itemsDone == itemsToDo;
            }

            if (completelyDone)
            {
                eventDone.Set();
            }
        }
Exemple #2
0
        public void AddItem(int index, Item item)
        {
            if (!multiThreaded)
            {
                Item i = null;
                try
                {
                    if (useArmory)
                    {
                        i = Item.LoadFromId(item.Id, true, false, false, false);
                    }
                    else
                    {
                        i = Item.LoadFromId(item.Id, true, false, true, usePTR, Rawr.Properties.GeneralSettings.Default.Locale);
                    }
                }
                catch (Exception ex)
                {
                    StatusMessaging.ReportError("Load item", ex, string.Format("Unable to update '{0}' due to an error: {1}\r\n\r\n{2}", item.Name, ex.Message, ex.StackTrace));
                }
                if (i != null)
                {
                    newItems.Add(index, i);
                }
                return;
            }

            ItemToUpdate info = new ItemToUpdate()
            {
                index = index,
                item  = item
            };

            lock (lockObject)
            {
                itemsToDo++;
                itemQueue.Enqueue(info);
            }
        }