Ejemplo n.º 1
0
        private static Entity ReadRow(Entity parent, System.Xml.XmlTextReader r)
        {
            if (parent != null && r.AttributeCount <= 1) //tabular section, no attributes or "key"
            {
                String tsName = r.Name;

                if (r.MoveToFirstAttribute())
                {
                    if (r.Name.ToLower().Equals("key")) //only key attrbute is allowed
                    {
                        parent.AddTabularSection(tsName, r.Value);
                    }
                    else
                    {
                        throw new Exception(String.Format("Invalid tabular section attribute '{0}'", r.Name));
                    }
                }
                else
                {
                    parent.AddTabularSection(tsName);
                }

                return(parent);
            }
            else
            {
                Entity entity = new Entity(r.Depth);
                if (r.MoveToFirstAttribute())
                {
                    do
                    {
                        String name = r.Name;
                        r.ReadAttributeValue();
                        entity.Attributes.Add(name, r.ReadContentAsString());
                    }while (r.MoveToNextAttribute());
                }

                if (parent != null)
                {
                    parent.CurrentTabularSection.AddEntity(entity);
                    return(parent);
                }
                else
                {
                    return(entity);
                }
            }
        }
Ejemplo n.º 2
0
        public static void initialize(Main pMain)
        {
            m_pMain = pMain;
            m_pWebClient = new CGWebClient();
            m_pWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(m_pWebClient_DownloadFileCompleted);
            m_pWebClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(m_pWebClient_DownloadProgressChanged);

            if (!System.IO.File.Exists(@"pak\Files\tile.p000"))
                m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml");
            else if (!System.IO.File.Exists(@"pak\World\_test$sample_1.p000"))
                m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml");
            else
                m_pWebClient.DownloadFile(WEBSITE + "launcher/patch.xml", "patch.xml");

            try
            {
                using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader(Directory.GetCurrentDirectory() + "/patch.xml"))
                //using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader( WEBSITE + "files/patch.xml"))
                {
                    int x = 0;

                    while (pXmlTextReader.ReadToFollowing("PATCHNODE"))
                    {
                        x++;
                        m_pMain.Status = "Interpreting Patch Information " + x + "...";
                        if (pXmlTextReader.MoveToFirstAttribute())
                        {
                            string strFilename = pXmlTextReader.GetAttribute("file").Replace("./", "");
                            string strCurrDir = System.IO.Directory.GetCurrentDirectory();
                            try
                            {
                                string Dir = Path.GetDirectoryName(strFilename);
                                if (!Directory.Exists(Dir) && Dir != "")
                                    Directory.CreateDirectory(Dir);
                            }
                            catch
                            {
                                m_pMain.Status = "Failed to create or read folder info.";
                            }
                            //foreach (string strTemp in strFilename.Split('/'))
                            //{
                            //    if (!strTemp.Contains("."))
                            //    {
                            //        System.IO.Directory.CreateDirectory(strTemp);
                            //        continue;
                            //    }
                            //}

                            uint nChecksum = 0;

                            if (pXmlTextReader.ReadToFollowing("CHECKSUM"))
                            {
                                nChecksum = (uint)pXmlTextReader.ReadElementContentAs(typeof(uint), null);
                            }
                            try
                            {
                                FileInfo FI = new FileInfo(strFilename);
                                if (strFilename.ToLower() == Path.GetFileName(Application.ExecutablePath).ToLower())
                                {
                                    FileInfo FI2 = new FileInfo(strFilename + "_");
                                    if (FI2.Exists)
                                        FI2.Delete();
                                    Thread.Sleep(500);
                                    FI.CopyTo(strFilename + "_");
                                    uint crc = getFileCrc(strFilename + "_");
                                    FI2 = new FileInfo(strFilename + "_");
                                    if (FI2.Exists)
                                        FI2.Delete();
                                    if (crc != nChecksum)
                                    {
                                        PatchSelf = true;
                                        m_pUpdateList.Add(strFilename);
                                    }
                                    continue;
                                }
                                if (!FI.Exists)
                                    m_pUpdateList.Add(strFilename);
                                else
                                {
                                    uint crc = getFileCrc(strFilename);
                                    if (crc != nChecksum)
                                    {
                                        m_pUpdateList.Add(strFilename);
                                    }
                                }
                            }
                            catch (Exception E)
                            {
                                if (E.Message.Contains("msvcr71.dll' because it is being used by another process"))
                                {
                                    //ignore because it's used by .net and gunz needs it...  note that this is a possible abuse for exploitation
                                }
                                else
                                {
                                    MessageBox.Show("Some of the files (" + strFilename + ") that need to be patched/edited are currently in use.  Make sure SoulHunterZ is closed.  If this error persists, restart your computer.", "Fatal Error");
                                    Application.Exit();
                                }
                            }

                            System.IO.Directory.SetCurrentDirectory(strCurrDir);
                        }
                    }
                }
            }
            catch
            {
                m_pMain.Status = "Failed to get or read patch info.";
                m_pWebClient.Dispose();
                return;
            }

            m_pMain.BarTotalMax = m_pUpdateList.Count;
            m_pMain.BarTotalVal = m_pMain.BarTotalMax;
            m_pMain.BarCurVal = m_pMain.BarCurMax;
            updateNext();
        }