Beispiel #1
0
        static SettlementInfoLookup()
        {
            _settlementList        = new Dictionary <uint, SettlementInfo>();
            _itemsToSettlementList = new Dictionary <uint, string>();

            try
            {
                string appdir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                XmlDocument doc = new XmlDocument();
                doc.Load(File.OpenRead(Path.Combine(Path.Combine(appdir, "SettlementsInfo"), "Settlements.xml")));

                XmlNodeList itemNodes = doc.GetElementsByTagName("settlementitems");
                foreach (XmlNode n in itemNodes)
                {
                    string id = n.Attributes["id"].Value;
                    foreach (XmlNode c in n.ChildNodes)
                    {
                        string siid = c.Attributes["iid"].Value;
                        uint   iid  = uint.Parse(siid, System.Globalization.NumberStyles.HexNumber, null);
                        _itemsToSettlementList.Add(iid, id);
                    }
                }

                itemNodes = doc.GetElementsByTagName("settlement");
                foreach (XmlNode n in itemNodes)
                {
                    SettlementInfo i = new SettlementInfo(n);
                    uint           index;
                    if (n.Attributes["index"] == null)
                    {
                        if (n.Attributes["name"] == null)
                        {
                            throw new Exception("need name or index...");
                        }
                        index = NameLookup.GetHash(n.Attributes["name"].Value);
                    }
                    else
                    {
                        index = uint.Parse(n.Attributes["index"].Value);
                    }
                    _settlementList.Add(index, i);
                }
            }
            catch { }
        }
Beispiel #2
0
 public KnownChunkAttribute(string name)
 {
     this.Name = name;
     this.Hash = NameLookup.GetHash(name);
 }