private void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();
            FileStream  fileStream  = new FileStream(path, FileMode.Open);
            bool        flag        = fileStream.Length == 0L;

            if (flag)
            {
                CLogger.getInstance().warning("|[SIIP]| File is Empty: " + path);
            }
            else
            {
                try
                {
                    xmlDocument.Load(fileStream);
                    for (XmlNode xmlNode = xmlDocument.FirstChild; xmlNode != null; xmlNode = xmlNode.NextSibling)
                    {
                        bool flag2 = "list".Equals(xmlNode.Name);
                        if (flag2)
                        {
                            for (XmlNode xmlNode2 = xmlNode.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                            {
                                bool flag3 = "initial".Equals(xmlNode2.Name);
                                if (flag3)
                                {
                                    XmlNamedNodeMap attributes          = xmlNode2.Attributes;
                                    List <PlayerTemplateInventory> list = new List <PlayerTemplateInventory>();
                                    int    id    = int.Parse(attributes.GetNamedItem("id").Value);
                                    string value = attributes.GetNamedItem("name").Value;
                                    int    slot  = int.Parse(attributes.GetNamedItem("slot").Value);
                                    int    num   = int.Parse(attributes.GetNamedItem("equip").Value);
                                    int    count = int.Parse(attributes.GetNamedItem("count").Value);
                                    PlayerTemplateInventory playerTemplate = new PlayerTemplateInventory
                                    {
                                        id         = id,
                                        name       = value,
                                        slot       = slot,
                                        onEquip    = num,
                                        count      = count,
                                        equip_type = num
                                    };
                                    this._holder.addInventoryStatic(playerTemplate);
                                }
                            }
                        }
                    }
                }
                catch (XmlException ex)
                {
                    CLogger.getInstance().warning("[RankExpInfoParser]: Error in file: " + path);
                    CLogger.getInstance().info(ex.Message);
                }
                fileStream.Close();
            }
        }
Ejemplo n.º 2
0
        private void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();
            FileStream  fileStream  = new FileStream(path, FileMode.Open);

            if (fileStream.Length == 0L)
            {
                CLogger.getInstance().info("[PlayerTemplateParser]: File is Empty: " + path);
            }
            else
            {
                try
                {
                    xmlDocument.Load((Stream)fileStream);
                    for (XmlNode xmlNode1 = xmlDocument.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
                    {
                        if ("list".Equals(xmlNode1.Name))
                        {
                            for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                            {
                                if ("template".Equals(xmlNode2.Name))
                                {
                                    XmlNamedNodeMap xmlNamedNodeMap = (XmlNamedNodeMap)xmlNode2.Attributes;
                                    List <PlayerTemplateInventory> _startInventory = new List <PlayerTemplateInventory>();
                                    int id   = int.Parse(xmlNamedNodeMap.GetNamedItem("id").Value);
                                    int rank = int.Parse(xmlNamedNodeMap.GetNamedItem("rank").Value);
                                    int gp   = int.Parse(xmlNamedNodeMap.GetNamedItem("gp").Value);
                                    int exp  = int.Parse(xmlNamedNodeMap.GetNamedItem("exp").Value);

                                    string   itemid = xmlNamedNodeMap.GetNamedItem("itemid").Value;
                                    string[] _temp  = itemid.Split(new char[] { ';' });
                                    for (int i = 0; i < _temp.Length - 1; i++)
                                    {
                                        string[] _temp2 = _temp[i].Split(new char[] { ',' });
                                        PlayerTemplateInventory _invTemp = new PlayerTemplateInventory();
                                        _invTemp.id      = Int32.Parse(_temp2[0]);
                                        _invTemp.slot    = Int32.Parse(_temp2[1]);
                                        _invTemp.onEquip = Int32.Parse(_temp2[2]);
                                        _startInventory.Add(_invTemp);
                                    }
                                    PlayerTemplate playerTemplate = new PlayerTemplate(id, rank, exp, gp, _startInventory);
                                    _holder.addPlayerTemplateInfo(playerTemplate);
                                }
                            }
                        }
                    }
                }
                catch (XmlException ex)
                {
                    CLogger.getInstance().info("[PlayerTemplateParser]: Error in file: " + path);
                    throw ex;
                }
                fileStream.Close();
            }
        }
 public void addInventoryStatic(PlayerTemplateInventory playerTemplate)
 {
     StartedInventoryItemsHolder._templates.Add(playerTemplate);
 }
        private void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();
            FileStream  fileStream  = new FileStream(path, FileMode.Open);
            bool        flag        = fileStream.Length == 0L;

            if (flag)
            {
                CLogger.getInstance().info("[PlayerTemplateParser]: File is Empty: " + path);
            }
            else
            {
                try
                {
                    xmlDocument.Load(fileStream);
                    for (XmlNode xmlNode = xmlDocument.FirstChild; xmlNode != null; xmlNode = xmlNode.NextSibling)
                    {
                        bool flag2 = "list".Equals(xmlNode.Name);
                        if (flag2)
                        {
                            for (XmlNode xmlNode2 = xmlNode.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                            {
                                bool flag3 = "template".Equals(xmlNode2.Name);
                                if (flag3)
                                {
                                    XmlNamedNodeMap attributes          = xmlNode2.Attributes;
                                    List <PlayerTemplateInventory> list = new List <PlayerTemplateInventory>();
                                    int      id    = int.Parse(attributes.GetNamedItem("id").Value);
                                    int      rank  = int.Parse(attributes.GetNamedItem("rank").Value);
                                    int      gp    = int.Parse(attributes.GetNamedItem("gp").Value);
                                    int      exp   = int.Parse(attributes.GetNamedItem("exp").Value);
                                    string[] array = attributes.GetNamedItem("itemid").Value.Split(new char[]
                                    {
                                        ';'
                                    });
                                    for (int i = 0; i < array.Length - 1; i++)
                                    {
                                        string[] array2 = array[i].Split(new char[]
                                        {
                                            ','
                                        });
                                        PlayerTemplateInventory item = new PlayerTemplateInventory
                                        {
                                            id      = int.Parse(array2[0]),
                                            slot    = int.Parse(array2[1]),
                                            onEquip = int.Parse(array2[2])
                                        };
                                        list.Add(item);
                                    }
                                    PlayerTemplate gsi = new PlayerTemplate(id, rank, exp, gp, list);
                                    this._holder.addPlayerTemplateInfo(gsi);
                                }
                            }
                        }
                    }
                }
                catch (XmlException ex)
                {
                    CLogger.getInstance().info("[PlayerTemplateParser]: Error in file: " + path);
                    throw ex;
                }
                fileStream.Close();
            }
        }