示例#1
0
        public void AddObjects(XElement root)
        {
            foreach (var elem in root.XPathSelectElements("//Object"))
            {
                if (elem.Element("Class") == null)
                {
                    continue;
                }
                string cls = elem.Element("Class").Value;
                string id  = elem.Attribute("id").Value;

                ushort type;
                var    typeAttr = elem.Attribute("type");
                if (typeAttr == null)
                {
                    type = assign.Assign(id, elem);
                }
                else
                {
                    type = (ushort)Utils.FromString(typeAttr.Value);
                }

                if (cls == "PetBehavior" || cls == "PetAbility")
                {
                    continue;
                }

                if (typeToId.ContainsKey(type))
                {
                    log.Warn($"\"{id}\" and \"{typeToId[type]}\" has the same ID of 0x{type:x4}!");
                }
                if (idToType.ContainsKey(id))
                {
                    log.Warn($"0x{type:x4} and 0x{idToType[id]:x4} has the same name of {id}!");
                }

                typeToId[type]   = id;
                idToType[id]     = type;
                typeToElem[type] = elem;

                switch (cls)
                {
                case "Equipment":
                case "Dye":
                    items[type] = new Item(type, elem);
                    break;

                case "Portal":
                case "GuildHallPortal":
                    try
                    {
                        portals[type] = new PortalDesc(type, elem);
                    }
                    catch
                    {
                        log.Error($"Error for portal \"{type}\":\"{id}\"");

                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                         *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                    }
                    break;

                case "Pet":
                case "PetSkin":
                case "PetBehavior":
                case "PetAbility":
                    break;

                default:
                    objDescs[type] = new ObjectDesc(type, elem);
                    break;
                }

                var  extAttr = elem.Attribute("ext");
                bool ext;
                if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
                {
                    if (elem.Attribute("type") == null)
                    {
                        elem.Add(new XAttribute("type", type));
                    }
                    addition.Add(elem);
                    updateCount++;
                }
            }
        }
示例#2
0
        public void AddObjects(XElement root)
        {
            foreach (var elem in root.XPathSelectElements("//Object"))
            {
                if (elem.Element("Class") == null)
                {
                    continue;
                }
                string cls = elem.Element("Class").Value;
                string id  = elem.Attribute("id").Value;

                ushort type;
                var    typeAttr = elem.Attribute("type");
                if (typeAttr == null)
                {
                    type = assign.Assign(id, elem);
                }
                else
                {
                    type = (ushort)Utils.FromString(typeAttr.Value);
                }

                if (type2id_obj.ContainsKey(type))
                {
                    log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type);
                }
                if (id2type_obj.ContainsKey(id))
                {
                    log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id);
                }

                type2id_obj[type]   = id;
                id2type_obj[id]     = type;
                type2elem_obj[type] = elem;

                switch (cls)
                {
                case "Equipment":
                    items[type] = new Item(type, elem);
                    break;

                case "Dye":
                    items[type] = new Item(type, elem);
                    break;

                case "Portal":
                    try
                    {
                        portals[type] = new PortalDesc(type, elem);
                    }
                    catch
                    {
                        Console.WriteLine("Error for portal: " + type + " id: " + id);

                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                         *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                    }
                    break;

                default:
                    objDescs[type] = new ObjectDesc(type, elem);
                    break;
                }

                var  extAttr = elem.Attribute("ext");
                bool ext;
                if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
                {
                    if (elem.Attribute("type") == null)
                    {
                        elem.Add(new XAttribute("type", type));
                    }
                    this.addition.Add(elem);
                    updateCount++;
                }
            }
        }