public Item(int ID) { ItemAttributes = new List<AOItemAttribute>(); ItemEvents = new List<AOEvents>(); SqlWrapper ms = new SqlWrapper(); DataTable dt = ms.ReadDT("SELECT * FROM items WHERE AOID='" + ID.ToString() + "'"); if (dt.Rows.Count > 0) { AOID = (Int32)dt.Rows[0]["AOID"]; isnano = (Int32)dt.Rows[0]["IsNano"]; QL = (Int32)dt.Rows[0]["QL"]; itemtype = (Int32)dt.Rows[0]["ItemType"]; byte[] blob = (byte[])dt.Rows[0]["EFR"]; int blobc = 0; // Read Attack Stat/Values int cc = BitConverter.ToInt32(blob, blobc); AOItemAttribute mm_a; blobc += 4; while (cc > 0) { mm_a = new AOItemAttribute(); mm_a.Stat = BitConverter.ToInt32(blob, blobc); blobc += 4; mm_a.Value = BitConverter.ToInt32(blob, blobc); blobc += 4; attack.Add(mm_a); cc--; } // Read Defend Stat/Values cc = BitConverter.ToInt32(blob, blobc); blobc += 4; while (cc > 0) { mm_a = new AOItemAttribute(); mm_a.Stat = BitConverter.ToInt32(blob, blobc); blobc += 4; mm_a.Value = BitConverter.ToInt32(blob, blobc); blobc += 4; defend.Add(mm_a); cc--; } // Read Item Attributes int c = BitConverter.ToInt32(blob, blobc); blobc += 4; AOItemAttribute tempa; while (c > 0) { tempa = new AOItemAttribute(); tempa.Stat = BitConverter.ToInt32(blob, blobc); blobc += 4; tempa.Value = BitConverter.ToInt32(blob, blobc); blobc += 4; ItemAttributes.Add(tempa); c--; } // Read Item Events AOEvents tempe; c = BitConverter.ToInt32(blob, blobc); blobc += 4; while (c > 0) { tempe = new AOEvents(); blobc = tempe.readEventfromBlob(ref blob, blobc); ItemEvents.Add(tempe); c--; } /* // Read Item Actions AOActions tempac; c = BitConverter.ToInt32(blob, blobc); blobc += 4; while (c > 0) { tempac = new AOActions(); blobc = tempac.readActionfromBlob(ref blob, blobc); c--; } */ } else { // Setting QL to -1 as "invalid item" flag QL = -1; } }