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); }
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; }