Esempio n. 1
0
        public bool removeOffer(GEItem offer)
        {
            Dictionary <int, GEItem[]> offers = offer is BuyOffer ? buyOffers : sellOffers;

            lock (offers)
            {
                if (!offers.ContainsKey(offer.getDisplayItem()))
                {
                    Misc.WriteError("Invalid GE item removal = Name: " + offer.getPlayerName() + " Item: " + offer.getItem() + " Amount: " + offer.getTotalAmount() + " Price: " + offer.getPriceEach());
                    return(false);
                }
                foreach (KeyValuePair <int, GEItem[]> eachOffer in offers)
                {
                    if (eachOffer.Key == offer.getDisplayItem())
                    {
                        for (int i = 0; i < eachOffer.Value.Length; i++)
                        {
                            if (eachOffer.Value[i] != null)
                            {
                                if (eachOffer.Value[i].Equals(offer))
                                {
                                    eachOffer.Value[i] = null;
                                    int entries = 0;
                                    for (int j = 0; j < eachOffer.Value.Length; j++)
                                    {
                                        if (eachOffer.Value[i] != null)
                                        {
                                            entries++;
                                        }
                                    }
                                    if (entries == 0)
                                    {
                                        offers.Remove(offer.getDisplayItem());
                                    }
                                    return(true);
                                }
                            }
                        }
                        return(false);
                    }
                }
            }
            return(false);
        }
Esempio n. 2
0
        public void addOffer(GEItem offer)
        {
            Dictionary <int, GEItem[]> offers = offer is BuyOffer ? buyOffers : sellOffers;

            lock (offers)
            {
                if (!offers.ContainsKey(offer.getDisplayItem()))
                {
                    offers.Add(offer.getDisplayItem(), new GEItem[1]);
                }

                foreach (KeyValuePair <int, GEItem[]> eachOffer in offers)
                {
                    if (eachOffer.Key == offer.getDisplayItem()) //item shown in GE.
                    {
                        bool space = false;
                        for (int i = 0; i < eachOffer.Value.Length; i++)
                        {
                            if (eachOffer.Value[i] == null)
                            {
                                space = true;
                                eachOffer.Value[i] = offer;
                                break;
                            }
                        }
                        if (!space)
                        {
                            GEItem[] items    = eachOffer.Value;
                            GEItem[] newItems = new GEItem[items.Length + 1];
                            int      ptr      = 0;
                            for (int i = 0; i < items.Length; i++)
                            {
                                if (items != null)
                                {
                                    newItems[ptr++] = items[i];
                                }
                            }
                            newItems[ptr] = offer;
                            if (!offers.ContainsKey(offer.getDisplayItem()))
                            {
                                offers.Add(offer.getDisplayItem(), newItems);
                            }
                            else
                            {
                                offers[offer.getDisplayItem()] = newItems;
                            }
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
 public void updateGEProgress(GEItem offer)
 {
     connection.SendPacket(new PacketBuilder().setId(116)
         .addByte((byte)offer.getSlot())
         .addByte((byte)offer.getProgress())
         .addUShort(offer.getDisplayItem())
         .addInt(offer.getPriceEach())
         .addInt(offer.getTotalAmount())
         .addInt(offer.getAmountTraded())
         .addInt(offer.getTotalAmount() * offer.getPriceEach()).toPacket());
 }
Esempio n. 4
0
 public bool removeOffer(GEItem offer)
 {
     Dictionary<int, GEItem[]> offers = offer is BuyOffer ? buyOffers : sellOffers;
     lock (offers)
     {
         if (!offers.ContainsKey(offer.getDisplayItem()))
         {
             Misc.WriteError("Invalid GE item removal = Name: " + offer.getPlayerName() + " Item: " + offer.getItem() + " Amount: " + offer.getTotalAmount() + " Price: " + offer.getPriceEach());
             return false;
         }
         foreach (KeyValuePair<int, GEItem[]> eachOffer in offers)
         {
             if (eachOffer.Key == offer.getDisplayItem())
             {
                 for (int i = 0; i < eachOffer.Value.Length; i++)
                 {
                     if (eachOffer.Value[i] != null)
                     {
                         if (eachOffer.Value[i].Equals(offer))
                         {
                             eachOffer.Value[i] = null;
                             int entries = 0;
                             for (int j = 0; j < eachOffer.Value.Length; j++)
                             {
                                 if (eachOffer.Value[i] != null)
                                 {
                                     entries++;
                                 }
                             }
                             if (entries == 0)
                             {
                                 offers.Remove(offer.getDisplayItem());
                             }
                             return true;
                         }
                     }
                 }
                 return false;
             }
         }
     }
     return false;
 }
Esempio n. 5
0
        public void addOffer(GEItem offer)
        {
            Dictionary<int, GEItem[]> offers = offer is BuyOffer ? buyOffers : sellOffers;
            lock (offers)
            {
                if (!offers.ContainsKey(offer.getDisplayItem()))
                    offers.Add(offer.getDisplayItem(), new GEItem[1]);

                foreach (KeyValuePair<int, GEItem[]> eachOffer in offers)
                {
                    if (eachOffer.Key == offer.getDisplayItem()) //item shown in GE.
                    {
                        bool space = false;
                        for (int i = 0; i < eachOffer.Value.Length; i++)
                        {
                            if (eachOffer.Value[i] == null)
                            {
                                space = true;
                                eachOffer.Value[i] = offer;
                                break;
                            }
                        }
                        if (!space)
                        {
                            GEItem[] items = eachOffer.Value;
                            GEItem[] newItems = new GEItem[items.Length + 1];
                            int ptr = 0;
                            for (int i = 0; i < items.Length; i++)
                            {
                                if (items != null)
                                {
                                    newItems[ptr++] = items[i];
                                }
                            }
                            newItems[ptr] = offer;
                            if (!offers.ContainsKey(offer.getDisplayItem()))
                                offers.Add(offer.getDisplayItem(), newItems);
                            else
                                offers[offer.getDisplayItem()] = newItems;
                        }
                        break;
                    }
                }
            }
        }