public void RemovePremiumItem(PremiumItem pItem) { try { locker.WaitOne(); this.PremiumItems[pItem.PageID].Remove(pItem); } finally { locker.ReleaseMutex(); } }
public static PremiumItem LoadFromDatabase(DataRow row) { var ppItem = new PremiumItem { UniqueID = GetDataTypes.GetInt(row["UniqueID"]), Slot = GetDataTypes.GetByte(row["PageID"]), ShopID = GetDataTypes.GetInt(row["ShopID"]), CharID = GetDataTypes.GetInt(row["CharID"]), PageID = GetDataTypes.GetByte(row["PageID"]) }; return(ppItem); }
public bool GetEmptySlot(out byte pSlot, out ushort PageID) //cpu intensive? { pSlot = 0; PageID = 0; for (byte i = 0; i < this.Count; ++i) { if (!this.PremiumItems.ContainsKey(i)) { for (byte i2 = 0; i2 < (this.PremiumItems[i].Count * 24); ++i2) { PremiumItem Item = this.PremiumItems[i].Find(ss => ss.Slot == i2); if (Item == null) { pSlot = i2; PageID = i; return(true); } } } } return(false); //no more empty slots found }
public void LoadPremiumItems(int pChar) { try { this.locker.WaitOne(); DataTable Premiumdata = null; using (DatabaseClient dbClient = Program.CharDBManager.GetClient()) { Premiumdata = dbClient.ReadDataTable("SELECT *FROM PremiumItem WHERE CharID='" + pChar + "'"); } if (Premiumdata != null) { foreach (DataRow row in Premiumdata.Rows) { PremiumItem pItem = PremiumItem.LoadFromDatabase(row); this.PremiumItems[pItem.PageID].Add(pItem); } } } finally { this.locker.ReleaseMutex(); } }
public void AddPremiumItem(PremiumItem pItem) { pItem.AddToDatabase(); this.PremiumItems[pItem.PageID].Add(pItem); }